devops.cpp.ast.checks.no_throw_paren
Flag throw-expressions that wrap the thrown expression in parentheses.
A throw(...) whose parentheses span the entire thrown expression is
reported — the parentheses are redundant and make the throw read like a
function call. Write the throw as throw ...; instead. This does not flag
parentheses that are only part of the thrown expression itself, such as a
constructor or function call (throw E(1);), only redundant parentheses
wrapping the whole expression (throw(E(1));, throw(x + 1);). A bare
rethrow (throw;) is always allowed.
To disable this check for a project set:
[cpp]
ast_check_disabled_ids = ["noThrowParen"]
Classes
Flag |
- class devops.cpp.ast.checks.no_throw_paren.NoThrowParen[source]
Bases:
CheckFlag
throw(...)where parentheses wrap the whole thrown expression.- visit(cursor, filename)[source]
Flag the cursor if it is a parenthesized throw-expression.
- Parameters:
cursor (clang.Cursor) – The AST node currently being visited.
filename (str) – Path of the file being checked.
- Returns:
list[Diagnostic] – A single diagnostic if the cursor is a disallowed
throw(...), otherwise an empty list.- Return type: