The PC-lint Plus Query Language is used to express queries appearing in the -astquery , -equery , and +equery options. The Queries feature provides a facility to extend the functionality of PC-lint Plus by defining custom checks and diagnostics and suppressing messages based on dynamic introspection. AST nodes may be inspected and walked during the execution of queries. Queries are composed of query expressions which constitute the statically-typed, domain-specific language described in this chapter.
While the sections that follow document the details of the Query Language, this section provides a brief overview by
means of a couple of practical motivating examples.
A query provided to a -astquery option will be evaluated for every AST node in an analyzed module, such queries
are typically used to perform custom checks of arbitrary complexity and issue corresponding messages when
user-defined criteria are met.
For example, the below -astquery option contains a query that will cause a custom message to be issued when a non-static data member of a class, structure, or union has an unsigned integral type and a name that does not begin with "u":
-astquery(FieldDecl() : { getType().isUnsignedIntegerType() hasName() && !getNameAsString().startsWith("u") message(8001 "unsigned data member '" currentnode "' missing 'u' prefix") })
The argument to the -astquery option comprises the query. The FieldDecl function is used to ensure that the rest of the query is evaluated in the context of a field and is only executed for AST nodes representing fields. getType yields the type of the field and isUnsignedIntegerType is true if the this type is an unsigned integral type, the query terminates if it is not. If the field has a name, the getNameAsString function extracts it, if it starts with "u" then the query terminates, otherwise the message operator is used to issue a custom message. When this option is used with a module containing:
struct X { unsigned short us; unsigned int ix; };
the message produced will look like:
info 8001: unsigned data member 'X::ix' missing 'u' prefix unsigned int ix; ^
The use of currentnode causes the message to be parameterized with a symbol corresponding to the field which is
automatically rendered as expected and allows the message to be suppressed for specific fields using -esym or
specific types using -etype .
A query may also be used with a -equery or +equery option to suppress messages via criteria that cannot otherwise
be expressed such as by exploration of the AST nodes that correspond to a symbol in a message. A query used with
one of these options is evaluated once for every message that PC-lint Plus considers issuing and will vote against
the issuance of the message if the provided query matches.
For example, message 818 (parameter of function could be pointer to const) is parameterized by two symbols, the parameter and the function. The following -equery option employs a query to suppress the message when the function symbol was instantiated from a template:
-equery(818, msgSymbolParam(2).FunctionDecl().isTemplateInstantiation())
See the Examples section for many more examples.
Every expression has a static type determined at query parse time. Every type, except for the Void type, may either
have the special empty value of None or contain a value representable by its type. The types supported by Queries
are listed in the below table.
| ASTNode | A node in the program AST. |
| ASTType | A type in the program AST. |
| Boolean | The values true and false. |
| Floating | Double precision floating point values. |
| Integral | 64-bit signed integer values. |
| Location | Source code locations. |
| String | Character strings. |
| Void | - |
In a Boolean context, all values are truthy except the Boolean value false and a None value. Note in particular that
0, 0.0, "", and an empty Location value are all truthy values.
For example, if $x and $y are Integral variables, the expression:
$x + $y
will yield either an Integral value or None (if either $x or $y is None, so is the result of adding them together as the None value is generally propagative).
A query consists of one or more query expression components that are executed in order. Evaluation of a query expression is typically terminated when a contained sub-expression yields a falsy value, if a top-level query expression yields a falsy value then evaluation of the query terminates. For example:
$x = SwitchStmt(currentnode) $x.numSwitchCases > 100 message($x 8001 "lots of switch cases!")
If the above query is executed for a non-switch-statement node, the SwitchStmt conversion function will yield an
empty value (None) which will be assigned to the variable $x. When $x is used in the call to numSwitchCases, the
empty value of $x will propagate across the expression causing it to evaluate to None and the message expression
will not be evaluated. Otherwise, if the number of switch cases is <= 100, the second query expression will yield an
empty value and evaluation will terminate before the message expression is reached. If the message expression is
reached, the message is issued and evaluation would continue if there were any other query expressions following
it.
In most cases, the evaluation of an empty value will propagate through enclosing expressions causing them to evaluate as None. Situations where this does not occur include cases where the empty value appears:
in the predicate of a control statement (e.g. if (IfStmt) { ... }, evaluation will unconditionally continue after the if statement).
as the operand to the logical ! operator.
in the LHS of a logical or operator.
as an argument to the str, message, or verbosify operators.
Query expressions are self-terminating, expressions are not delimited with a special character. In the previous example, the entire query could have been written on a single line without changing the behavior.
Multiplicative and Additive Operators The standard multiplicative operators (*, /, and %) and additive operators (+ and -) are available for use with numeric types. When used with two Integral types, the result of the operation is Integral. When at least one operand has Floating type, the result has Floating type. When one operand is Integral and the other is Floating, the Integral operand is implicitly converted to a Floating type. The unary negation operator (-) may be used with Integral and Floating types. All of the numeric operators yield a None value if any of the provided operands is None. The / and % operators will also yield a None value if the RHS operand is zero.
Bitwise Operators The binary infix bitwise operators & and | accept two Integral operands and yield the bitwise AND and bitwise OR result, respectively. The unary prefix complement operator ~ accepts an Integral operand and yields the bitwise complement. All of the bitwise operators yield None only when one of their operands is None.
The following operators are available for operating on strings:
| + | String concatenation | "Hello " + "World" |
| += | Concatenation assignment | $result += "here" |
| ~~ | Regex Matching | $s ~~"^\d+" |
| in | Substring membership | "X" in $s |
| str | String conversion | str("X is " X) |
When the operands to the + operator are both Strings, the result is a String value that represents the concatenation
of the LHS and RHS operands. String variables may be appended to using the += operator with the variable name
appearing on the LHS and a String expression on the RHS.
The ~~ operator is a regular expression pattern matching and extraction operator. The LHS operand is a String
expression and the RHS is a string literal that represents a PCRE regular expression. The result of the
expression is the first substring in the LHS that matches the provided regular expression or None if there
is no match. Regular expression pattern errors are diagnosed when the query is parsed. See Section
16.6 Regular Expression Basics for details on the regular expression syntax supported by the ~~
operator.
The in operator has Boolean type and evaluates to true if the LHS String value appears in the RHS string and
false otherwise.
The str operator takes a parenthesized argument list consisting of one or more arbitrary expressions of non-void type. Each expression is evaluated and its result is converted to a textual representation based on its type as described in the table below.
| ASTNode | If the node value can be converted to a NamedDecl, the fully qualified name of the NamedDecl. Otherwise, if the node is not None, the value of the builtin function getDeclKindName or getStmtClassName enclosed in angle brackets. If the node does not hold a value, the name of the static type of the node enclosed in angle brackets. | B::foo |
| ASTType | The textual value of the string type as per the builtin getAsString function. | int * |
| Boolean | true or false | true |
| Floating | Decimal representation corresponding to the C library’s %f printf specifier. | 123.456 |
| Integral | Decimal representation with negative numbers prefixed with a minus sign. | -123 |
| Location | <Invalid Location>, <Unknown Location>, or the values of the location buffer name, line number, and column number, separated by colons and enclosed in angle brackets. | <test.c:829:25> |
Most queries will access the AST that PC-lint Plus uses to represent a source module. This AST consists of over 100 different kinds of nodes hierarchically related as shown in the diagram on the next page. Queries provides the ASTNode type, which may hold any kind of node used in the AST, as well as derived types corresponding to each node kind which may hold the specified node kind or any node kind derived from it. For example a FunctionDecl type may hold CXXMethodDecl nodes but not VarDecl nodes since VarDecl is not derived from FunctionDecl.
Conversion Functions For each node type there is a conversion function with the same name that will convert a target node to the specified node type if the target node has the specified type or a type derived from it. If the conversion is successful, the result has the specified node type, otherwise the result is None. Conversion functions are used both to query the node type as well as to call node-specific functions available for individual node types. Conversion functions operate on currentnode if no argument is provided. For example, the query:
ContinueStmt()
will match any nodes that represent a continue statment. Within a -astquery option, the currentnode starts out with a type of ASTNode, to invoke functions that operate on a different node type, a conversion function must be called to convert the node to the appropriate type. For example, the builtin function getNumParams may only be called on a node with FunctionDecl type (or a derived node such as CXXMethodDecl, or CXXConstructorDecl). The following query will match functions declared with more than three parameters:
FunctionDecl().getNumParams() > 3
The currentnode Operator During query evaluation there is the concept of a current node which by default corresponds to the AST node currently being visited for -astquery options or the anchored statement or expression of a message (if any) for -equery/+equery options (the +paraminfo option may be used to determine the statement or expression a message is anchored to). The currentnode operator yields the current node with a type of ASTNode. The with-node operator (described below) can be used to change both the value and static type of the currentnode operator. Because currentnode is used as the implicit argument for functions that accepts a compatible type as their first argument, it typically is not used explicitly.
The with-node (:) Operator
The with-node operator allows an expression to be evaluated in the context of a different ASTNode. The syntax for
a with-node expression is:
node-expression : { body }
where node-expression is an expression with ASTNode type and body is one or more arbitrary expressions.
The with-node operator evaluates body with a possibly-modified current node value and/or type and yields the resulting value of body (or None if node-expression was None). For example, to issue a message when a static function definition is encountered which returns void and has no parameters, one could use:
FunctionDecl FunctionDecl.isThisDeclarationADefinition FunctionDecl.isStatic FunctionDecl.getReturnType.isVoidType FunctionDecl.getNumParams == 0 message(8001 "static function returns void but takes no arguments")
The calls to the FunctionDecl conversion operator are necessary because isStatic, etc. can only be called with a FunctionDecl object but implicit current node object has ASTNode type. The query can be rewritten using a with-node expression:
FunctionDecl : { isThisDeclarationADefinition isStatic getReturnType.isVoidType getNumParams == 0 message(8001 "static function returns void but takes no arguments") }
which produces the same behavior but removes the repeated use of FunctionDecl. If the current node is not a
function declaration then FunctionDecl will be None and the body of the with-node expression will not be
evaluated. Otherwise, the body will be evaluated in a context where the current node is a FunctionDecl instead of
an ASTNode and functions expecting a FunctionDecl argument can be called using the implicit default currentnode
argument.
In the above example, the value of the current node did not change, only its type. The value of the current node can also be modified using the with-node operator if the node-expression refers to a different AST node.
The operands to the <, >, <=, and >= binary infix relational operators must both be Numeric, String, or Location types. If one operand is Integral and the other is Floating, the Integral operand is first converted to a Floating type. If the specified relation is true, the result is the value of the LHS operand, otherwise the result is None. If either operand is None, so is the result. For example the result of:
2 < 3
is 2 and the result of:
2 > 3
is None. Relational operators are right associative, this means that:
2 < $x < 5
yields a non-None value if and only if $x has a value of 3 or 4. If either operand is empty, so is the result.
The operands of the == operator must both have the same non-void expression types. The result of == has the same
type as its operands and the value is the value of evaluating the LHS operand if both operands have the same
non-None value and None otherwise.
The operands of the != operator must both have the same non-void expression types. The result of != has Boolean type and will never yield an empty value. Given expressions A and B, the result of the expression A != B is semantically equivalent to not (A == B). In particular, if either A or B are empty, the result of the != operator will be true regardless of the value of the other operand.
A variable has a static type that is deduced from the first use of the variable which must be an assignment. Variable
names may consist of letters, numbers, underscores, and dollar signs ($) and must begin with a $. Variable names
are case sensitive and all characters in a variable’s name are significant. Variables declared in one query are not
accessible from another query.
All of the assignment operators have Void type, a side effect being that chained assignment is not supported and the
value of assignment may not be used. All assignment operators take a variable name as a LHS argument and an
expression of the same type on the RHS. In all forms of assignment, the RHS expression is first evaluated. For
simple assignment (=), the result is assigned to the variable, if the RHS evaluates to an empty value, the variable
now has an empty value.
Conditional assignment (=?) assigns the result to the LHS variable only if the RHS is not None. Compound assignment operates in the traditional manner, with A x= B having behavior similar to A = A x B where x is one of *, /, %, +, or - with the following exception:
If B is None, A = A x B will result in A having a value of None whereas A x= B will not (the value of A will not be changed).
The values of regular variables are reset at the beginning of every evaluation of a query. A persistent variable is one whose value persists across evaluations of a query, a persistent variable may be declared by preceding the initial assignment of the variable with the persistent keyword, e.g.:
persistent $counter = 0
The initial assignment to a persistent variable only occurs one time. Each analyzed module has its own set of persistent variables. Persistent variables are typically used as per-module counters, often with the echo operator.
The message operator is used to emit custom messages during the evaluation of an AST query and has the
syntax:
message( [location-expression] message-number expr ... )
The optional location-expression is an arbitrary expression with Location type, the value of which will determine the
file, line, and column number provided in the message as well as the context line and location of the position
indicator. If location-expression is omitted, the location used defaults to the location associated with the
current node. If the resulting location has an empty value, the message is issued without location
information.
message-number is a integer literal between 8001 and 8999, this is the message number that will be used to issue the
message.
Following the message number is one or more expressions of arbitrary type which are evaluated and used to form the
text of the emitted message. The result of each expression is converted to a string as described by the str operator
and the message text is the concatenation of these strings. Expressions with a false or None value are converted
to their textual representations and emitted with the message. The message operator always yields
true.
Each expression will also be represented as a message parameter allowing suppression with the +estring /-estring
, +esym /-esym , and +etype /-etype options. Expressions of NamedDecl and ASTType type will correspond to
symbol and type parameters, respectively, all other expressions will correspond to string parameters. The
+paraminfo option may be used to see the individual message parameters and types. Note that AST node
expressions must have NamedDecl type, attempting to use an expression with another AST node type will result in a
parse error (use the str operator to convert such nodes to a String value first). A maximum of nine expressions may
be used with the message operator.
An argument to the message operator that is a compound expression containing exactly two sub-expressions of Location type is treated as a location range, the corresponding range will be highlighted in the line containing the position indicator if the range occurs on the same line as the emitted context line. Location range arguments to not contribute to the limit of nine expressions in a message operator. Except for location range arguments, an expression argument may not have Location type.
The verbosify operator takes a single String operand and prints the value of the operand to the PC-lint Plus
verbosity stream (stdout by default). The syntax for the verbosify operator is:
verbosify( string-expr )
verbosify yields a value of true unless its operand is None in which case nothing is printed and the result of the
operator is None. Multiple strings may be combined into a single argument using the + or str operators and
non-String expressions may be converted to a string using str.
Note that query verbosity messages are not shown by default, the verbosity option -vq can be used to cause verbosity messages emanating from a query to be displayed.
The logical operators are &&, ||, and !. && and || are binary infix operators which accept any operands of non-Void
type. The && and || operators have Boolean type. The && operator yields true when both of its operands have
truthy values and false otherwise. The || operator yields true when either of its operands have
truthy value and false otherwise. && and || employ short-circuited operation, if the value of the
expression can be determine from the evaluation of the LHS operand then the RHS operand will not be
evaluated.
! is a prefix operator that accepts any non-Void operand and yields a Boolean value. If the operand has a truthy
value, the ! operator yields, false, otherwise it yields true.
None of the logical operators ever yield None.
Alternate Spellings The &&, ||, and ! operators may also be spelled and, or, and not, respectively.
An if expression has the form:
if condition { then-expr } [ else { else-expr } ]
The condition is first evaluated, followed by then-expr or else-expr (if provided) if the result of evaluating condition has a truthy or falsy value, respectively.
The Type and Value of an if Expression When an if expression contains an else clause and the type of then-expr and else-expr are of compatible types, the result of the if expression has the composite type of then-expr and else-expr and the value of whichever of the two expressions were evaluated. For example, the if expression:
if $x == 1 { 2 } else { 3.0 }
will have Floating type (the composite type of Integer and Floating) and will yield the value 2.0 if $x is 1 and 3.0
otherwise.
When an if expression contains an else-expr which is not compatible with the then-expr, the type of the if expression is Boolean and yields true if the evaluated clause yields a truthy value and false otherwise. For example, the if expression:
if $x == 1 { FunctionDecl } else { CXXRecordDecl }
will yield true if $x is 1 and the current node is a FunctionDecl or $x is not 1 and the current node is a
CXXRecordDecl, otherwise the if expression yields false.
When an if expression does not contain an else clause, the type of the if expression is Boolean and the result is false if the condition evaluates to a truthy value and then-expr evaluates to a falsy value, otherwise the result of the if expression is true. For example:
if 1 == 1 { 1 == 2 }
yields false but:
if 1 == 2 { ... }
will always yield true.
A while expression has the form:
while condition { do-expr }
The condition is first evaluated, if the result is a truthy value then do-expr is evaluated. This process repeats until condition evaluates to a falsy value at which point evaluation continues with the next expression. A while expression has Void type.
AST queries are typically executed one time for each node visited during an AST pre-order traversal. It is
sometimes desired to perform a second post-order visit to make use of information collected during the traversal of
child nodes. For example, to report when the nesting depth of if statements within a function exceeds three, a
nesting depth counter needs to be incremented during pre-order visitation of an if statement but also
needs to be decremented during post-order visitation of if statements. The echo operator provides
a mechanism by which select components of a query may be conditionally evaluated in post-order
fashion.
The syntax for the echo operator is:
echo { body }
When an echo expression is evaluated, its body is not evaluated but instead is stored as a reflection expression that will be evaluated after the current node’s children are traversed; the current node is then echoed and any reflection expressions associated with the echo are evaluated within the context of the echoed node. For example, the query:
persistent $previous_depth = 0 persistent $depth = 0 if FunctionDecl { $previous_depth = $depth $depth = 0 echo { $depth = $previous_depth } } if IfStmt { $depth += 1 echo { $depth -= 1 } if $depth > 3 { message(8001 "inappropriate nesting level for 'if'") } }
will report when the if nesting depth within a function exceeds three. The persistent variable $depth is initialized to 0 (persistent assignments only occur once and persistent variables retain their values across query executions). When an if statement is encountered, $depth is incremented and the echo expression (but not its body) is evaluated which causes the body to be registered as a reflection to be executed when the current node is echoed. If $depth is now greater than 3, a message is issued. After any children are visited, the current if node is echoed and $depth is decremented. When a function declaration is encountered, the current depth is saved and then restored at the end of traversing the declaration using another echo expression. This is done so that if statements in nested functions do not contribute to the nesting depth of their enclosing function, e.g. no message is issued for:
void foo() { if (1) { if (2) { if (3) { []() { if (1) { if (2) { } } }; }}} }
since the lambda starts with a new nesting depth of zero (if another nested if appeared immediately after the
lambda expression, this would be reported as expected).
The body of the echo expression forms a scope in which non-persistent variables defined outside the expression are represented by local copies starting with the captured values held at the time the echo expression was evaluated to register the echo, and non-persistent variables defined in the body cannot be accessed outside the body. Echoes are registered in the order in which they are encountered during evaluation and the reflections are evaluated in the same order. For example, to report all instances of a typedef defined within a non-inline namespace in:
namespace X { typedef int A; namespace Y { typedef int B; namespace Z { typedef int C; inline namespace W { typedef int D; namespace P { typedef int E; } } } } }
a persistent variable storing the current namespace can be maintained during the evaluation of NamespaceDecl nodes (using an echo to restore its previous value potentially referring to an enclosing namespace from a captured value) and this current namespace variable can be accessed during the evaluation of a TypedefNameDecl to check if the current namespace is inline:
persistent $current_namespace = NamespaceDecl if NamespaceDecl { NamespaceDecl : { $pending_namespace = $current_namespace echo { $current_namespace = $pending_namespace } $current_namespace = currentnode } } else if TypedefNameDecl { TypedefNameDecl : { if not $current_namespace.isInline { message(8001 "typedef '" currentnode "' defined in non-inline namespace '" $current_namespace "'" ) } } }
which will report typedefs A, B, C, and E but will not report typedef D because namespace W is inline.
Note that since the body of an echo expression is not evaluated until a node is echoed, and nodes are never echoed more than once, a nested echo operator would have no effect as the body of the inner echo would only be registered during the echo and never have the opportunity to be reflected. For this reason, a query that contains a nested echo will produce a parse error.
A compound expression consists of one or more expressions enclosed by braces ({}). The type of the compound expression is the type of the last enclosed expression. Expressions appearing within a compound expression are evaluated sequentially. If the evaluation of any of these expressions yields a value of false or None, the remaining expressions are not evaluated and the value of the compound expression is None. Otherwise, the value of the compound expression is the value of the last expression. For example:
{ 1 2.0 }
consists of two expressions (1 and 2.0) with types Integral and Floating, respectively. The type of the compound expression is Floating and the value will be 2.0 when evaluated. The compound expression:
{ false 1 }
has type Integral but will always yield a None value during evaluation as the expression 1 will never be reached since evaluation of the compound expression will stop after evaluating the expression false.
Parentheses may be used as a grouping operator to enclose any expression (note that e.g. the LHS of assignment
expects a variable name, not an expression, so $x = 1 is valid but ($x) = 1 is not). Parentheses must enclose
exactly one expression, e.g. () or (1 2) are syntax errors; braces can be used to enclose multiple expressions. The
primary purpose of parentheses is to override operator precedence. There is never any performance impact for using
parentheses.
Braces may also be used to override precedence and {X} is functionally equivalent to (X) for some expression X
(recall that the type and value associated with a compound expression is that of its last enclosed
expression). There is no performance impact for using braces to override operator precedence in this
way.
Parentheses are required to enclose the explicit argument list in a function invocation and are required to enclose the argument(s) of function-like operators including assert, message, and str although the parentheses are not technically operators in these cases.
The following table lists the precedence of query operators. Operators with a smaller precedence
value bind more tightly than those with a higher value. All operators have left-to-right
associativity except the with-node (:) operator and the relational operators which are right-to-left
associative. Parentheses or braces may be used to modify expression precedence, e.g. 1 + 2 * 3
7 but (1 +
2) * 3
9.
| 1 | () | Parentheses |
| 2 | . | Member Call |
| 3 | - | Unary Negation |
| 4 | ~ | Bitwise Complement |
| 5 | & | Bitwise And |
| 6 | | | Bitwise Or |
| 7 | * / % | Multiplicative Operators |
| 8 | + - | Additive Operators |
| 9 | != == <= >= < > | Relational Operators |
| 10 | in | In Operator |
| 11 | !/not | Logical Not |
| 12 | &&/and | Logical And |
| 13 | ||/or | Logical Or |
| 14 | = =? *= /= %= += -= | Assignment |
The relational operators are right-to-left associative, all other operators are left-to-right associative.
Much of the functionality provided by queries is realized through the use of hundreds of builtin functions. A builtin function accepts zero or more arguments of predefined types and returns a value of the type associated with the function. The expected number and type of arguments is checked at parse time. Function arguments are evaluated from left to right. If any of the provided arguments have an empty value at run-time, the remaining arguments are not evaluated, the function is not called, and the result of the function is an empty value.
A builtin function is invoked by writing the name of the function followed by an optional parenthesized argument list, e.g.:
isStruct(currentnode)
If there are no trailing arguments, an empty parenthesized list is allowed but optional.
The first argument of any function may be specified by placing it on the left-hand side of the . member call operator, e.g.:
currentnode.isStruct()
As mentioned above, the parentheses here are optional. The member call syntax provides a convenient, and perhaps more intuitive, syntax when using nested function invocations. For example, the query:
isStruct(getParent(FieldDecl(currentnode)))
used to determine if the current node is a FieldDecl whose parent is a struct can be written as:
currentnode.FieldDecl.getParent.isStruct
There is no functional difference between the syntaxes.
Most functions accept an ASTNode type as their first (and typically only) argument. In such cases, the argument
will default to the type and value of currentnode if the function is called with one argument less than the number
of parameters expected by the function. For example, all of the ASTNode conversion functions take a single Node
argument and thus:
IsStmt
IsStmt(currentnode)
Similarly:
isDerivedFrom($class)
isDerivedFrom(currentnode, $class)
$class.isDerivedFrom
Note that the type of the currentnode operator is context-dependent. When appearing in the -astquery option, it starts with a type of Node but its type may change within a with-node (:) operator. If the type of the currentnode operator is not compatible with the type expected as the first argument, an error will be produced when the query is parsed. In the above example, since isDerivedFrom expects two CXXRecordDecl arguments, the implicit use of currentnode will result in an error outside of a context where the current node has CXXRecordDecl type or type derived therefrom.
Builtin functions typically start with a lowercase letter and employ camelCase having names that match the corresponding underlying clang functions that they typically wrap. All of the ASTNode conversion functions (e.g. IfStmt, RecordDecl, etc.) start with an uppercase letter and match the name of the correponding clang class. This facilitates easy transition between the clang-produced program AST and query syntax and helps conversion functions stand out from other functions.
This section contains over a dozen examples of how the -astquery option may be used to craft custom messages,
many of which correspond to real-world uses cases provided by customers. Each example begins with a short
problem description followed by a query that implements a corresponding solution and elaborative notes about the
provided query.
Non-local variable names should be at least 3 characters long
-astquery(VarDecl() : { !isLocalVarDeclOrParm() && getNameAsString().length() < 3 message(8001 "variable name '" currentnode "' is too short") })
Variable declarations are represented by VarDecl nodes in the AST, the VarDecl() conversion function will only
match such nodes. The isLocalVarDeclOrParm function is used to exclude function parameters or
variables declared with function scope. The getNameAsString function returns a string containing the
name of the variable and the length function returns the length of this string. The message will be
issued with the name of the variable as a symbol parameter which may be suppressed using the -esym
option.
Variables of unsigned integer type should have a name starting with "uint"
-astquery(VarDecl() : { getType().isUnsignedIntegerType() hasName() && !getNameAsString().startsWith("uint") message(8001 "unsigned variable '" currentnode "' missing 'uint' prefix") })
The getType function returns the type of a declaration (as an ASTType), in this case the type of the current
variable declaration. The isUnsignedIntegerType function is called with an argument of ASTType
and returns true if the type is an unsigned integer type. The getNameAsString function is used to
obtain the variable name and the startsWith function returns true if the first argument (the result
of calling getNameAsString) starts with the value provided in the second argument ("uint"). The
hasName function is used to ensure the variable has a name so as to not emit a message for e.g. a
function declaration with unnamed parameters. The message reports the offending variable as a symbol
parameter.
Constructors and destructors should not be inline
-astquery(FunctionDecl() : { CXXConstructorDecl() || CXXDestructorDecl() !isDefaulted() && !isDeleted() isInlined() message(8001 "ctors and dtors should not be inline") })
Constructors and destructors are represented by CXXConstructorDecl and CXXDestructorDecl nodes, respectively.
Both of these are derived from FunctionDecl which is used with the with-node operator so that the remaining
function calls, which take a FunctionDecl argument, may be called with the implicit currentnode
object. The isDefaulted and isDeleted functions return true for defaulted (= default) and deleted
(= delete) functions, respectively. This check is included to prevent the message from being issued
for deleted or defaulted functions as these would be considered to be inline functions which is likely
not desired for the purpose of this message. The isInlined function returns true if the function is
inline.
Bit-field should not be defined
-astquery(FieldDecl() : { isBitField() message(8001 "bit-field defined") })
Non-static data-members of aggregates are represented as FieldDecl nodes in the AST. The isBitField function
takes a FieldDecl argument (the currentnode object is implicitly supplied as an argument in this case which
has FieldDecl type by virtue of the with-node operator) and returns true if the specified field is a
bit-field.
Variable Length Arrays should not be used
-astquery(VarDecl() : { getType().isVariablyModifiedType() message(8001 "variable '" currentnode "' has VLA type") })
The isVariablyModifiedType function is used to detect and report variable-length array declarations. Instances of
the message are parameterized with a symbol representing the offending variable.
Variables of function pointer type should be declared using typedefs
-astquery(VarDecl() : { getType().isFunctionPointerType() !getType().isTypedefNameType() message(8001 "use typedef to declare function pointer variables") })
When a variable is declared using a typedef, the getType function will return the typedef type for which
the function isTypedefNameType will return true. The function isFunctionPointerType takes an
ASTType and returns true of the type is a function pointer type (regardless of whether it is a typedef
type).
Non-public, non-struct class members should end with a trailing _
-astquery(FieldDecl() : { getAccess() != "public" getParent().isClass() hasName() && !getNameAsString().endsWith("_") message(8001 "non-public class member '" currentnode "' should end with _") })
The getAccess function returns a string that indicates the access of a declaration (public, private, protected, or
none). The getParent function returns the RecordDecl that contains the provided FieldDecl and the isClass
function determines if the that RecordDecl was declared with the class keyword. If the field does not have public
access, the parent has class type, and the name of the field does not end with _ then a message is issued with the
field provided as a symbol parameter.
Constructors that are callable with a single argument should be made explicit except for copy/move constructors and constructors taking only a std::initializer_list argument.
-astquery(CXXConstructorDecl() : { getMinRequiredArguments() == 1 !isCopyOrMoveConstructor() !isExplicit() !getParamDecl(1).getType().isStdInitList() message(8001 "single arg non-copy/move ctors must be marked explicit") })
The getMinRequiredArguments function returns the number of arguments that must be provided when calling a
function, isCopyOrMoveConstructor returns true if the provided function is a copy or move constructor, and
isExplicit returns true if the function was declared with the explicit keyword. The getParamDecl function
returns the specified parameter, getType is used to obtain the type of the first parameter, and isStdInitList is
used to determine if the type of this parameter is an instantiation of std::initializer_list. If the
constructor requires exactly one argument, is not a copy or move constructor, is not declared with the
explicit keyword, and does not accept a std::initializer_list argument, a custom message will be
emitted.
Default function arguments should be avoided except in constructors and static functions defined outside a header
-astquery(ParmVarDecl() : { hasDefaultArg() getParentFunctionOrMethod() : { !CXXConstructorDecl() !(getStorageClass() == "Static" && getDefinition().getLocation().isMainFile()) } message(8001 "default arg not allowed for parameter '" currentnode "'") })
The above query will be executed for every parameter variable. The hasDefaultArg returns true if the parameter
has a default argument and getParentFunctionOrMethod is used to obtain the function that the parameter belongs
to. If the parent function is not a constructor (determined by calling CXXConstructorDecl and is not a static
function defined in the main source file, a message is emitted with a *symbol* parameter representing the parameter
variable. The getDefinition function is used to obtain the function declaration that contains the body of the
function and the location of this function is checked to determine if it resides in the main source file via
isMainFile.
The construct for (;;) ... should not be used to represent an infinite loop
-astquery(ForStmt() : { !getInit() && !getCond() && !getInc() message(8001 "infinite loop via 'for (;;)'") })
The getInit, getCond, and getInc functions return the first, second, and third clauses of a for statement,
respectively. Each of these functions will return a value of None if the corresponding clause is not provided. If all of
these functions return None then the for statement has the proscribed form.
Enumeration constants should consist entirely of uppercase letters, digits, and underscores
-astquery(EnumConstantDecl() : { !getNameAsString() ~~ "^[A-Z_0-9]+$" message(8001 "enumeration constant '" currentnode "' should contain only uppercase letters, digits, and underscores") })
Enumeration constants are represented by EnumConstantDecl nodes in the AST so the conversion function of the
same name is used to only match those nodes. The getNameAsString function is used to get the constant’s name
and the ~~ pattern matching operator is used to check whether the name consists entirely of the allowed
characters.
Structures (declared with the struct keyword) should have names ending with "_t"
-astquery(RecordDecl() : { isStruct() && hasName() && !getNameAsString().endsWith("_t") message(8001 "structure '" currentnode "' does not contain '_t' suffix") })
Structures, classes, and unions are all represented by the RecordDecl AST node, the isStruct function is used to
determine if this record was declared with the struct keyword. If it was, the getNameAsString function is used
to obtain the name and the endsWith function checks to see that the name contains the requisite
suffix.
Bit-fields should not be defined using a type smaller than int
-astquery(FieldDecl : { isBitField() && getType().isPromotableIntegerType() message(8001 "type '" getType() "' not allowed for bit-fields") })
Similar to a previous example, the FieldDecl and isBitField functions are used to isolate bit-fields. The
getType function, applied to a bit-field, will yield the type used in the declaration of the bit-field. The
isPromotableIntegerType function returns true if the provided type is an integer type that is eligible for
promotion which is only the case for integer types smaller than int. The type used in the declaration of the
offending bit-field is included as a type parameter in the message which may be used to suppress the message with
the -etype option.
The strncpy function should not be called with the same variable for the first two arguments
-astquery(CallExpr() : { getDirectCallee().getNameAsString() == "strncpy" getArg(1).ignoreParenCasts().DeclRefExpr().getDecl().VarDecl().getNameAsString() == getArg(2).ignoreParenCasts().DeclRefExpr().getDecl().VarDecl().getNameAsString() message(8001 "source and destination argument for strncpy are the same") })
The getDirectCallee function returns the FunctionDecl corresponding to the CallExpr or None if the function
cannot be determined (e.g. if the function was called through a function pointer). The name of the called function is
then checked and the query will only continue for calls to strncpy. The getArg function is used to access the first
and second arguments of the call, ignoreParenCasts will skip over any parentheses and casts and DeclRefExpr will
return AST node of the same name if such a node is present. A DeclRefExpr node is used to represent a reference to
a declared entity. For example, in the expression a + b, the references to the variables a and b will each be
represented by a DeclRefExpr in the AST. The getDecl retrieves the declaration corresponding to
the DeclRefExpr and the VarDecl function will yield the declaration as a VarDecl if it is a variable
declaration. The getNameAsString function is then used to see if both arguments name the same
variable.
Tautological assignment should be avoided
-astquery(BinaryOperator() : { if isAssignmentOp() && !isCompoundAssignmentOp() { $lhs_assignment = getLHS().ignoreParenImpCasts() $rhs_assignment = getRHS().ignoreParenImpCasts() $lhs_decl = $lhs_assignment.DeclRefExpr().getDecl() $rhs_decl = $rhs_assignment.DeclRefExpr().getDecl() if !$lhs_decl { $lhs_decl = $lhs_assignment.MemberExpr().getMemberDecl() } if !$rhs_decl { $rhs_decl = $rhs_assignment.MemberExpr().getMemberDecl() } if $lhs_decl && $lhs_decl == $rhs_decl { message(8001 "tautological assignment involving symbol '" $lhs_decl "' ") } } } )
Binary operators, such as assignment operators, are represented by BinaryOperator nodes in the AST. The
isAssignmentOp function returns true if the binary operator is an assignment operator. Similarly, the
isCompoundAssignmentOp function returns true if the binary operator is a compound assignment
operator. A DeclRefExpr node represents a reference to a declared entity, such as a variable, and
the getDecl function retrieves the declaration corresponding to the DeclRefExpr. A MemberExpr
node represents a reference to the member of a structure, class, or union and the getMemberDecl
function is used to retrieve the corresponding member declaration. The corresponding variable or member
declarations associated with each of the LHS and RHS nodes, if any, are stored in $lhs_decl and
$rhs_decl, respectively. The message is then issued if the LHS of the assignment corresponds to a declared
entity and the RHS corresponds to the same declared entity.The message will include the symbol that
is stored in the $lhs_decl variable. This query does not overlap with the reporting of message 530
.
A C-style cast should not be used to convert between pointer types
-astquery(CStyleCastExpr() : { $source_type = getSubExpr().ignoreParenImpCasts().getType().getNonReferenceType() $dest_type = getType().getNonReferenceType() $source_type.isPointerType() && $dest_type.isPointerType() message(8001 "c-style cast used to convert from '" $source_type "' to '" $dest_type "'") })
The CStyleCastExpr represents a c-style cast (e.g. one of the form (type) value ). When applied to a
CStyleCastExpr, the getType function returns the type casted to. The getSubExpr function returns the expression
being casted and calling getType on this expression yileds the type being casted from. The getNonReferenceType
function returns the type that results from removing any reference types so that e.g. a variable having
reference-to-pointer type is still eligible to be reported by this message. If both types are pointer types (determined
using the isPointerType function), the message is issued. The emitted message contains two type parameters which
provide additional information about the cast and may be used to suppress the message for casts involving specific
types.
The below examples demonstrate various ways that the -equery option may be used to suppress messages in ways
that cannot be suppressed using standard suppression options. Most of the examples are taken from real-world use
cases. Each example begins with a description of the desired suppression and is followed by a query that implements
the suppression along with relevant explanation.
Suppress message 9033 (cannot cast essential-type to wider/different essential type) when casting to a typedef named EXEMPT
-equery(9033, CastExpr().getType().getAsString() == "EXEMPT")
Message 9033 is issued for a cast expression which is accessible via the current node. The current node is converted
to a CastExpr and the cast type is accessed via the getType function. If the type is a typedef with a name of
EXEMPT, the message will be suppressed.
Suppress message 9130 (bitwise operator applied to signed underlying type) for the ’|’ operator when the LHS is an integer constant expression
-equery(9130, BinaryOperator() : { getOpcodeStr() == "|" && getLHS().isIntegerConstantExpr() })
The BinaryOperator corresponding to the bitwise operator for which message 9130 is issued is available as
the current node. The getOpcodeStr function returns a string representation of the binary operator
and the getLHS function will return the left-hand operand. When the operator is | and the left-hand
expression is an integer constant expression (as per the isIntegerConstantExpr function), the message is
suppressed.
Suppress message 916 (implicit pointer assignment conversion) for conversions to void *
-equery(916, msgTypeParam(2).isVoidPointerType())
Message 916 is parameterized by two type parameters, the type being converted from is the first type parameter and
the type being converted to is the second. Message type parameters may be accessed using the msgTypeParam
function which takes an index as its argument and returns the corresponding type parameter as an ASTType value.
The query retrieves the to type and suppresses the message if it is a void pointer using the isVoidPointerType
function.
Suppress message 1731 (public virtual function) for pure functions in classes without in-class initializers
-equery(1731, msgSymbolParam(1).CXXMethodDecl() : { isPure() && !getParent().hasInClassInitializer() })
Message 1731 is parameterized by a single symbol parameter corresponding to the function that is the target of this
message. The isPure function returns true if the provided function is a pure virtual function (e.g. void foo() =
0). The getParent function returns the class containing the member function and the hasInClassInitializer
function returns true if this class has any in-class initializers.
Suppress message 1925 (symbol is a public data member) for members that have a non-POD class, structure, or union type
-equery(1925, msgSymbolParam(1).FieldDecl() : { getType().getNonReferenceType().isRecordType() !getType().getNonReferenceType().isPODType() })
Message 1925 is parameterized by the symbol corresponding to the public data member (a FieldDecl) referenced in
the message. The getType function returns the type of this member and the getNonReferenceType returns the type
resulting from removing any references from the type. The resulting non-reference type of the data member is then
checked to determine if it is a class, structure, or union type by the isRecordType function and the isPODType
determines of the type is a POD type.
Suppress message 9150 (non-private data member within a non-POD structure) for non-POD data members or data members that are arrays of non-POD types
-equery(9150, msgSymbolParam(1).FieldDecl() : { !getType().getNonReferenceType().isPODType() || (getType().isArrayType() && !getType().getArrayElementType().isPODType()) })
Message 9150 is parameterized by the symbol corresponding to the data member referenced in the message. The
getType function returns the type of this member and the getNonReferenceType returns the type resulting from
removing any references from the type. The isArrayType function returns true for array types and the
getArrayElementType function returns the element type of the array. The isPODType function returns true if the
resulting type is a POD type. If the data member is not a POD type or is an array of non-POD type the message is
suppressed.
Suppress message 1732 (new in constructor for which has no user-provided copy assignment operator) for classes directly derived from a class named NonCopyable
-equery(1732, msgSymbolParam(1).CXXRecordDecl() : { $num_bases = getNumBases() $base_idx = 1 $should_suppress = false while $base_idx <= $num_bases { if getBase($base_idx).getAsCXXRecordDecl().getNameAsString() == "NonCopyable" { $should_suppress = true } $base_idx += 1 } $should_suppress })
Message 1732 is parameterized by the symbol corresponding to the class referenced in the message. The getBase
function returns the nth base of a class as a type, the getAsCXXRecordDecl function is used to obtain the
corresponding class declaration, and the getNumBases returns the number of direct bases a class has. The while
loop is used with these functions to iterate over the bases of the class mentioned in the message. If the name of
any of these base classes (available using the getNameAsString function) is NonCopyable then the
$should_suppress variable is set to true which prevents issuance of the message at the end of the
query.
Suppress message 953 (local variable could be const) for pointers
-equery(953, msgSymbolParam(1).VarDecl().getType().isPointerType())
Message 953 is parameterized by the symbol corresponding to the variable referenced by the message and is accessed
by the msgSymbolParam function. The getType function returns this variables type and the isPointerType returns
true if this type is a pointer type.
Suppress message 818 (parameter of function could be pointer to const) for functions instantiated from a template
-equery(818, msgSymbolParam(2).FunctionDecl().isTemplateInstantiation())
Message 818 is parameterized by two symbols, the function parameter and the function itself. The
msgSymbolParam functio is used to access the FunctionDecl represented by the second symbol parameter and the
isTemplateInstantiation function is used to determine if the function was instantiated from a function
template.
Suppress message 523 (expression statement lacks side effects) when issued for a call to a virtual function
-equery(523, CallExpr().getDirectCallee().CXXMethodDecl().isVirtual())
The CallExpr conversion operator is used to access the call expression for which message 523 is issued. The
getDirectCall functions returns a FunctionDecl corresponding to the called function. The isVirtual function
takes the CXXMethodDecl (which is why the conversion function of the same name is used before isVirtual) and
returns true if the function is a virtual function and false otherwise.
Suppress message 835 (zero given as argument to operator) when the indicated side is an enumeration constant
-equery(835, msgStringParam(1).endsWith("right") && msgStringParam(2) == "|" BinaryOperator().getRHS().ignoreParenCasts().DeclRefExpr().getDecl().EnumConstantDecl()) -equery(835, msgStringParam(1).endsWith("left") && msgStringParam(2) == "|" BinaryOperator().getLHS().ignoreParenCasts().DeclRefExpr().getDecl().EnumConstantDecl())
Message 835 is parameterized by three string parameters: the first parameter indicates whether the argument
appears on the left or right side of the operator, the second parameter is a string that represents the operator, and
the third parameter is the context for which the message is issued. The msgStringParam function takes an index
argument and returns the corresponding string parameter of the message. The above query first isolates instances of
the message with the specified string parameters. Message 835 is issued for a BinaryOperator node. The remaining
functions are used to determine if the appropriate operand of this operator constitutes an enumeration
constant.
Suppress message 529 (local variable declared in function not subsequently referenced) for volatile-qualified variables
-equery(529, msgSymbolParam(1).VarDecl().getType().isVolatileQualified())
Message 529 is parameterized by two symbol parameters: the local variable and the function in which it is declared. The msgSymbolParam function is used to retrieve the first symbol which is converted to a VarDecl. The getType function provides the type of the variable and the isVolatileQualified function returns true if the type is volatile-qualified.
A regular expression is a string of characters that represents a search pattern used to match sections of text.
Regular expressions consist of regular characters (’a’, ’1’, ’_’, etc.) that have a literal meaning and
metacharacters (’*’, ’+’, ’|’, etc.) that have special meanings. Regular characters match themselves and special
characters and sequences are used to specify more complex behavior. PC-lint Plus supports Perl-style
regular expressions inside of queries via the ~~ pattern matching operator. This section provides an
overview of regular expression syntax and discusses some of the basic concepts involved. Most of the
patterns used with PC-lint Plus will be relatively simple and an understanding of the basic concepts will
suffice.
The purpose of this section is not to provide an exhaustive reference of regular expressions (for which numerous books have been written) but to introduce the basic concepts and provide a reference for some of the more advanced topics that may be useful in the context of Hooks. For additional information, please see:
All characters appearing in a regular expression are either regular characters or metacharacters. Regular characters represent themselves, e.g. the pattern "abc" will match the literal text "abc". Metacharacters instead impart a special meaning to the pattern, for example, "ab*c+" will match text that contains the letter ’a’, immediately followed by zero or more ’b’ characters, followed by one or more ’c’ characters (e.g. "acc" and "acccb" will match but "abb" won’t). The metacharacters used in regular expressions are *, ?, +, {, }, (, ), [, ], ^, $, |, \, and ..
By default, patterns are not anchored meaning that a match anywhere in the string is considered success. For example, the pattern "a+" will match the text "cab". The anchor characters ^ and $ can be used to anchor the pattern to the beginning or end of the subject string, respectively. For example, "^a+" will match any string that starts with one or more ’a’ characters and "a+$" will match any string that ends in one or more ’a’ characters. ’^’ and ’$’ can be used together to specify an exact match of the subject string, e.g. "^a+$" will match only a string consisting entirely or ’a’ characters.
The dot character ’.’ represents any single character, e.g. "c.b" will match "cab", "cub", "ccb", etc. The ’?’, ’*’, and
’+’ characters are used to modify the number of times a immediately preceding subpattern should be matched. ’?’
means that the subpattern can match zero or one time, ’*’ means zero or more times, and ’+’ means one or more
times. For example, "c.?b" will match "cab" and "cb", but not "club" whereas "c.+b" would match "cab" and "club"
but not "cb" and "c.*b" would match all three.
A set of curly braces can also be used to specify repetition limits. If one number appears inside of the braces, that is the number of times the preceding subpattern must match to be successful. Alternatively, a min and max may be specified, separated by a comma. In this case, the first number specifies the minimum number of times the subpattern can match and the second number specifies the maximum. For example, "ca{2,3}" will match "caab" and "caaab" but not "cab". If the second number is elided, this is taken to mean there is no maximum, e.g. "fi1,ght" will match "fight", "fiight", "fiiiight", etc.
The | character specifies pattern alternation, e.g. either the preceding or the following pattern may match. For example, the pattern "blue|red|green" will match a string that contains either "blue", "red", or "green".
Parts of a pattern surrounded by parenthesis are subpatterns. A subpattern can have its own modifiers attached to it. For example, "q(ue)+" will match "que" and "queue" (and "queueue" etc.) but will not match "qu". Subpatterns can be arbitrarily complex.
The ’\’ character can be used to introduce backslash escape sequences and to remove the meaning from
metacharacters. For example "*" is not a valid pattern because the * quantifier must be applied to a pattern. To
match a literal * the pattern "\*" can be used; the backslash removes the special meaning. Note that the
meaning is only removed for the character that immediately follows, e.g. "\**" will match zero or more *
characters. In addition to removing the meaning from metacharacters, the following escape sequences are
supported:
| \d | Any decimal digit (i.e. 0-9) |
| \D | Any non-decimal character |
| \h | Any horizontal whitespace character |
| \H | Any character except horizontal whitespace |
| \s | Any space character |
| \S | Any non-space character |
| \v | Any vertical whitespace character |
| \V | Any character except vertical whitespace |
| \w | Any "word" character (letter, digit, or underscore) |
| \W | Any character that is not a word character |
In addition to escape sequences that match classes of characters, escape sequences can also represent assertions,
conditions that must be true at the point in which they appear for the pattern to successfully match. The following
assertions are supported:
| \b | Matches at a word boundary |
| \B | Matches anywhere except a word boundary |
| \A | Matches at the start of the subject string |
| \Z | Matches at the end of the subject string |
| \G | Matches at the first matching position of the subject string |
A word boundary is the start or end of a sequence of one or more word characters.
The ’[’ character starts a character class which ends with the corresponding ’]’ character. The characters in between
the brackets are all part of the class and a match of any of them fulfills the corresponding portion of the pattern.
This is useful for matching one of a set of characters. For example, "c[au]b" will match "cab" and "cub" but not "cb"
or "cob" or "caub". The POSIX character classes listed below can also be used within a character class by
enclosing the name in [: ... :], e.g. the pattern "[_[:lower:][:digit:]]" will match a character
that is either a lowercase letter, a digit, or the underscore. A character class cannot be empty and as
such a ] can be included in a character class by specifying it as the first character of the class, e.g.
[]abc].
| alnum | letters and numbers |
| alpha | letters |
| ascii | ASCII characters |
| blank | space or tab |
| cntrl | control characters |
| digit | numbers (0-9) |
| graph | printing characters except space |
| lower | lower case letters |
| | printing characters, including space |
| punct | printing characters that are not letters, digits, or space |
| space | whitespace |
| upper | upper case letters |
| word | word characters (letters, digits, and underscore) |
| xdigit | hexadecimal digits |
Ranges may be used in a character class by using - between two characters, e.g. "[A-F0-9]" to match upper case
hexadecimal digits. To include the - as part of the set, include it at the beginning or escape it with a backslash.
Character class escape sequences can be used in bracketed character classes, e.g. "[a-f\d]" to match lower case
hexadecimal digits.
A negated character class is one that matches anything except the types of characters included in the class. To
negate a character class, use ^ as the first character in the class, e.g. "[^[:lower:]_]" will match any character that
is not a lower case letter or underscore character.
The metacharacters $, |, (, ), ?, *, +, and { do not maintain their special meaning inside of a character class and can be used without escaping them. The ^, -, and [ characters are only considered special when appearing at the beginning of the pattern, in a location where a range operation is permitted, and when introducing a POSIX character class, respectively. In other parts of a character class, these characters have no special meaning.
A capture occurs any time a parenthesized subpattern is matched. It is called a capture because the text that
matched the subpattern is saved and can be accessed later in the pattern. A reference to a capture within a pattern
is called a backreference and can be referred to within the pattern by the capture number or capture name (if
provided).
Capture groups are numbered starting with 1 for the first group, 2 for the second, etc. A backreference to a capture
group with a number between 1-9 can be made using the syntax \# . For example the pattern "ca(.)\1" will match
any string containing "ca" followed by two of the same letter, e.g. "call". Backreferences can also be referred to
using the syntax \g{#}, e.g. "ca(.)\g{1}". The latter syntax avoids possible ambiguities between the syntax for
specifying octal escape sequences as well as allowing the referencing of capture group numbers greater than
9.
Capture groups can be given names by starting the group with ?<name> and named backreferences using the syntax \k{name}, e.g. "ca(?<c1>.)\k{c1}". Named capture groups are useful in larger or more complex patterns making use of many capture groups and provide a form of documentation within the pattern.
By default, matches are performed in a case-sensitive fashion. Case insensitive matches can be performed for part or
all of a match by using the i mode modifier. A mode modifier is a syntax for temporarily changing the behavior of
how patterns are interpreted. Mode modifiers are introduced by placing them between the ? and :
characters that start a non-capturing group. For example, the pattern "(?i:foo)" will match "foo", "FOO",
"Foo", etc. The case-insensitve behavior is applied to the containing group. An entire pattern, possibly
containing captures, can be enclosed in a non-capturing group that uses mode modifiers. For example:
"^(?i:(?<prefix>...)bar)$" will case-insensitively match any string that contains 6 characters, the last three of
which are "bar"; the first three characters are stored in the named capture group prefix and are
also available as capture group 1 within the pattern (the group containing the ?i: is a non-capturing
group).
In addition to the case-insensitive mode modifier, the x mode modifier may be used to enable extended mode. In extended mode, spaces within a pattern are ignored (they usually match literal space characters) as is everything from a # character to the end of the line. This mode can be useful for making complex patterns more readable by spacing them out across several lines and providing comments for individual portions of the pattern.
The syntax for the assert operator is:
assert ( condition )
The assert operator takes a single parenthesized condition which is an arbitrary non-void expression. If the condition evaluates to false or None, error 340 is issued and the assert operator yields false after which processing continues normally, otherwise assert yields true.
The +dump_queries option will cause PC-lint Plus to emit canonicalized query information along with corresponding Query AST immediately after processing subsequent -astquery, -equery , or +equery options. For example, the output generated for the option:
-astquery(VarDecl() : { !isLocalVarDeclOrParm() && getNameAsString().length() < 3 message(8001 "variable name '" currentnode "' is too short") })
will look something like:
Parsed AST Query: VarDecl() : { !isLocalVarDeclOrParm() && getNameAsString().length() < 3 message(8001 "variable name '" currentnode "' is too short") } Canonicalized Query: VarDecl(currentnode) : { not isLocalVarDeclOrParm(currentnode) and length(getNameAsString(currentnode)) < 3 message(8001 currentnode "variable name '" currentnode "' is too short") } Query AST: QueryContainer {Boolean} <Invalid location> `-WithNode {Boolean} <<astquery option>:1:1-4:1> |-BuiltinFunctionCall VarDecl(ASTNode) {VarDecl} <<astquery option>:1:1-9> | `-Currentnode [Arg 1] {ASTNode} <Invalid location> (implicit) `-CompoundExpr {Boolean} <<astquery option>:1:13-4:1> |-AndOperator {Boolean} <<astquery option>:2:5-61> | |-NotOperator {Boolean} <<astquery option>:2:5-27> | | `-BuiltinFunctionCall isLocalVarDeclOrParm(VarDecl) {Boolean} <<astquery option>:2:6-27> | | `-Currentnode [Arg 1] {VarDecl} <Invalid location> (implicit) | `-LessThanOperator {Integral} <<astquery option>:2:50-61> | |-BuiltinFunctionCall length(String) {Integral} <<astquery option>:2:50-55> | | `-BuiltinFunctionCall getNameAsString(NamedDecl) [Arg 1] {String} <<astquery option>:2:32-48> | | `-Currentnode [Arg 1] {VarDecl} <Invalid location> (implicit) | `-Integer '3' {Integral} <<astquery option>:2:61> `-Message (8001) {Boolean} <<astquery option>:3:5-64> |-Currentnode [Location] {VarDecl} <Invalid location> (implicit) |-String "variable name '" [Message Parameter 1] {String} <<astquery option>:3:18-34> |-Currentnode [Message Parameter 2] {VarDecl} <<astquery option>:3:36-46> `-String "' is too short" [Message Parameter 3] {String} <<astquery option>:3:48-63>
The Query AST shows how the parsed query was interpreted. The static type of each query node is shown in braces
after query node kind and possible annotation in square brackets. The location corresponding to the range of parsed
text is shown in angle brackets. Some nodes have additional information shown in parentheses at the end of the
node output.
The following sub-obtions may be used with +dump_queries: unicode, nounicode, colors, nocolors, compact, and
nocompact. The first two sub-options specify whether Unicode line-drawing characters are used in the
dumped AST. The next two options dictate whether portions of the AST are rendered in different
colors. The last two sub-options determine whether the AST is horizontally compacted and is only
supported when using Unicode line-drawing characters. The default mode on Linux and macOS is
equivalent to +dump_queries(unicode,colors,nocompact), the default mode on Windows is equivalent to
+dump_queries(nounicode,nocolors,nocompact).
The -dump_queries option suppresses AST query dumping for subsequently parsed queries. A later +dump_queries option will restore AST query dumping using the previously provided sub-options (if any). Multiple +dump_queries and -dump_queries may be used to cause a subset of query options to be affected.
getBoolType () ASTType
Returns the builtin Boolean type.
getChar16Type () ASTType
Returns the builtin char16_t type in C++ mode and unsigned short in C mode.
getChar32Type () ASTType
Returns the builtin char32_t type in C++ mode and unsigned int in C mode.
getChar8Type () ASTType
Returns the builtin char8_t type.
getCharType () ASTType
Returns the builtin char type.
getCharWidthInBits () Integral
Returns the bit width of the char type.
getDoubleType () ASTType
Returns the builtin double type.
getFloat128Type () ASTType
Returns the builtin __float128 type.
getFloatType () ASTType
Returns the builtin float type.
getInt128Type () ASTType
Returns the builtin __int128 type.
getIntMaxType () ASTType
Returns the intmax_t type.
getIntPtrType () ASTType
Returns a type compatible with the intptr_t type.
getIntType () ASTType
Returns the builtin int type.
getLongDoubleType () ASTType
Returns the builtin long double type.
getLongLongType () ASTType
Returns the builtin long long type.
getLongType () ASTType
Returns the builtin long type.
getNullPtrType () ASTType
Returns the builtin nullptr_t type.
getPointerDiffType () ASTType
Returns the ptrdiff_t type.
getShortType () ASTType
Returns the builtin short type.
getSignedCharType () ASTType
Returns the builtin signed char type.
getSignedIntTypeForBitwidth (Integral) ASTType
Returns the builtin signed integer type with the specified bit size, if any.
getSignedSizeType () ASTType
Returns the signed counterpart for the size_t type.
getSizeType () ASTType
Returns the size_t type.
getUIntMaxType () ASTType
Returns the uintmax_t type.
getUIntPtrType () ASTType
Returns a type compatible with the uintptr_t type.
getUnsignedCharType () ASTType
Returns the builtin unsigned char type.
getUnsignedInt128Type () ASTType
Returns the builtin unsigned __int128 type.
getUnsignedIntType () ASTType
Returns the builtin unsigned int type.
getUnsignedIntTypeForBitwidth (Integral) ASTType
Returns the builtin unsigned integer type with the specified bit size, if any.
getUnsignedLongLongType () ASTType
Returns the builtin unsigned long long type.
getUnsignedLongType () ASTType
Returns the builtin unsigned long type.
getUnsignedPointerDiffType () ASTType
Returns the unsigned counterpart for the ptrdiff_t type.
getUnsignedShortType () ASTType
Returns the builtin unsigned short type.
getVoidPtrType () ASTType
Returns the builtin pointer-to-void type.
getVoidType () ASTType
Returns the builtin void type.
getWideCharType () ASTType
Returns the builtin wide character type.
msgLocation () Location
Returns the primary location of the current message. This function is only available in -equery/+equery options.
msgNumStringParams () Integral
Returns the number of string parameters in the current message. This function is only available in -equery/+equery options.
msgNumSymbolParams () Integral
Returns the number of symbol parameters in the current message. This function is only available in -equery/+equery options.
msgNumTypeParams () Integral
Returns the number of type parameters in the current message. This function is only available in -equery/+equery options.
msgNumber () Integral
Returns the message number of the current message. This function is only available in -equery/+equery options.
msgStringParam (Integral) String
Returns the specified string parameter of the current message. This function is only available in -equery/+equery options.
msgSymbolParam (Integral) NamedDecl
Returns the specified symbol parameter of the current message. This function is only available in -equery/+equery options.
msgTypeParam (Integral) ASTType
Returns the specified type parameter of the current message. This function is only available in -equery/+equery options.
threadID () Integral
Returns the numeric value of the running thread where 0 is the main thread (outside of a module) and a value of n represents the thread processing the nth source module.
toBitsFromCharUnits (Integral) Integral
Returns the number of bits needed to represent the provided number of char units.
toCharUnitsFromBits (Integral) Integral
Returns the number of char units needed to store the provided number of bits.
AbstractConditionalOperator (ASTNode) AbstractConditionalOperator
If the provided AST node is convertible to an AbstractConditionalOperator, returns the node as an AbstractConditionalOperator, otherwise returns None.
AccessSpecDecl (ASTNode) AccessSpecDecl
If the provided AST node is convertible to an AccessSpecDecl, returns the node as an AccessSpecDecl, otherwise returns None.
AddrLabelExpr (ASTNode) AddrLabelExpr
If the provided AST node is convertible to an AddrLabelExpr, returns the node as an AddrLabelExpr, otherwise returns None.
ArraySubscriptExpr (ASTNode) ArraySubscriptExpr
If the provided AST node is convertible to an ArraySubscriptExpr, returns the node as an ArraySubscriptExpr, otherwise returns None.
AtomicExpr (ASTNode) AtomicExpr
If the provided AST node is convertible to an AtomicExpr, returns the node as an AtomicExpr, otherwise returns None.
AttributedStmt (ASTNode) AttributedStmt
If the provided AST node is convertible to an AttributedStmt, returns the node as an AttributedStmt, otherwise returns None.
BinaryConditionalOperator (ASTNode) BinaryConditionalOperator
If the provided AST node is convertible to a BinaryConditionalOperator, returns the node as a BinaryConditionalOperator, otherwise returns None.
BinaryOperator (ASTNode) BinaryOperator
If the provided AST node is convertible to a BinaryOperator, returns the node as a BinaryOperator, otherwise returns None.
BindingDecl (ASTNode) BindingDecl
If the provided AST node is convertible to a BindingDecl, returns the node as a BindingDecl, otherwise returns None.
BreakStmt (ASTNode) BreakStmt
If the provided AST node is convertible to a BreakStmt, returns the node as a BreakStmt, otherwise returns None.
CStyleCastExpr (ASTNode) CStyleCastExpr
If the provided AST node is convertible to a CStyleCastExpr, returns the node as a CStyleCastExpr, otherwise returns None.
CXXBindTemporaryExpr (ASTNode) CXXBindTemporaryExpr
If the provided AST node is convertible to a CXXBindTemporaryExpr, returns the node as a CXXBindTemporaryExpr, otherwise returns None.
CXXBoolLiteralExpr (ASTNode) CXXBoolLiteralExpr
If the provided AST node is convertible to a CXXBoolLiteralExpr, returns the node as a CXXBoolLiteralExpr, otherwise returns None.
CXXCatchStmt (ASTNode) CXXCatchStmt
If the provided AST node is convertible to a CXXCatchStmt, returns the node as a CXXCatchStmt, otherwise returns None.
CXXConstCastExpr (ASTNode) CXXConstCastExpr
If the provided AST node is convertible to a CXXConstCastExpr, returns the node as a CXXConstCastExpr, otherwise returns None.
CXXConstructExpr (ASTNode) CXXConstructExpr
If the provided AST node is convertible to a CXXConstructExpr, returns the node as a CXXConstructExpr, otherwise returns None.
CXXConstructorDecl (ASTNode) CXXConstructorDecl
If the provided AST node is convertible to a CXXConstructorDecl, returns the node as a CXXConstructorDecl, otherwise returns None.
CXXConversionDecl (ASTNode) CXXConversionDecl
If the provided AST node is convertible to a CXXConversionDecl, returns the node as a CXXConversionDecl, otherwise returns None.
CXXDefaultArgExpr (ASTNode) CXXDefaultArgExpr
If the provided AST node is convertible to a CXXDefaultArgExpr, returns the node as a CXXDefaultArgExpr, otherwise returns None.
CXXDefaultInitExpr (ASTNode) CXXDefaultInitExpr
If the provided AST node is convertible to a CXXDefaultInitExpr, returns the node as a CXXDefaultInitExpr, otherwise returns None.
CXXDeleteExpr (ASTNode) CXXDeleteExpr
If the provided AST node is convertible to a CXXDeleteExpr, returns the node as a CXXDeleteExpr, otherwise returns None.
CXXDependentScopeMemberExpr (ASTNode) CXXDependentScopeMemberExpr
If the provided AST node is convertible to a CXXDependentScopeMemberExpr, returns the node as a CXXDependentScopeMemberExpr, otherwise returns None.
CXXDestructorDecl (ASTNode) CXXDestructorDecl
If the provided AST node is convertible to a CXXDestructorDecl, returns the node as a CXXDestructorDecl, otherwise returns None.
CXXDynamicCastExpr (ASTNode) CXXDynamicCastExpr
If the provided AST node is convertible to a CXXDynamicCastExpr, returns the node as a CXXDynamicCastExpr, otherwise returns None.
CXXFoldExpr (ASTNode) CXXFoldExpr
If the provided AST node is convertible to a CXXFoldExpr, returns the node as a CXXFoldExpr, otherwise returns None.
CXXForRangeStmt (ASTNode) CXXForRangeStmt
If the provided AST node is convertible to a CXXForRangeStmt, returns the node as a CXXForRangeStmt, otherwise returns None.
CXXFunctionalCastExpr (ASTNode) CXXFunctionalCastExpr
If the provided AST node is convertible to a CXXFunctionalCastExpr, returns the node as a CXXFunctionalCastExpr, otherwise returns None.
CXXInheritedCtorInitExpr (ASTNode) CXXInheritedCtorInitExpr
If the provided AST node is convertible to a CXXInheritedCtorInitExpr, returns the node as a CXXInheritedCtorInitExpr, otherwise returns None.
CXXMemberCallExpr (ASTNode) CXXMemberCallExpr
If the provided AST node is convertible to a CXXMemberCallExpr, returns the node as a CXXMemberCallExpr, otherwise returns None.
CXXMethodDecl (ASTNode) CXXMethodDecl
If the provided AST node is convertible to a CXXMethodDecl, returns the node as a CXXMethodDecl, otherwise returns None.
CXXNamedCastExpr (ASTNode) CXXNamedCastExpr
If the provided AST node is convertible to a CXXNamedCastExpr, returns the node as a CXXNamedCastExpr, otherwise returns None.
CXXNewExpr (ASTNode) CXXNewExpr
If the provided AST node is convertible to a CXXNewExpr, returns the node as a CXXNewExpr, otherwise returns None.
CXXNoexceptExpr (ASTNode) CXXNoexceptExpr
If the provided AST node is convertible to a CXXNoexceptExpr, returns the node as a CXXNoexceptExpr, otherwise returns None.
CXXNullPtrLiteralExpr (ASTNode) CXXNullPtrLiteralExpr
If the provided AST node is convertible to a CXXNullPtrLiteralExpr, returns the node as a CXXNullPtrLiteralExpr, otherwise returns None.
CXXOperatorCallExpr (ASTNode) CXXOperatorCallExpr
If the provided AST node is convertible to a CXXOperatorCallExpr, returns the node as a CXXOperatorCallExpr, otherwise returns None.
CXXParenListInitExpr (ASTNode) CXXParenListInitExpr
If the provided AST node is convertible to a CXXParenListInitExpr, returns the node as a CXXParenListInitExpr, otherwise returns None. This initializer was introduced in C++ 20.
CXXPseudoDestructorExpr (ASTNode) CXXPseudoDestructorExpr
If the provided AST node is convertible to a CXXPseudoDestructorExpr, returns the node as a CXXPseudoDestructorExpr, otherwise returns None.
CXXRecordDecl (ASTNode) CXXRecordDecl
If the provided AST node is convertible to a CXXRecordDecl, returns the node as a CXXRecordDecl, otherwise returns None.
CXXReinterpretCastExpr (ASTNode) CXXReinterpretCastExpr
If the provided AST node is convertible to a CXXReinterpretCastExpr, returns the node as a CXXReinterpretCastExpr, otherwise returns None.
CXXScalarValueInitExpr (ASTNode) CXXScalarValueInitExpr
If the provided AST node is convertible to a CXXScalarValueInitExpr, returns the node as a CXXScalarValueInitExpr, otherwise returns None.
CXXStaticCastExpr (ASTNode) CXXStaticCastExpr
If the provided AST node is convertible to a CXXStaticCastExpr, returns the node as a CXXStaticCastExpr, otherwise returns None.
CXXStdInitializerListExpr (ASTNode) CXXStdInitializerListExpr
If the provided AST node is convertible to a CXXStdInitializerListExpr, returns the node as a CXXStdInitializerListExpr, otherwise returns None.
CXXThisExpr (ASTNode) CXXThisExpr
If the provided AST node is convertible to a CXXThisExpr, returns the node as a CXXThisExpr, otherwise returns None.
CXXThrowExpr (ASTNode) CXXThrowExpr
If the provided AST node is convertible to a CXXThrowExpr, returns the node as a CXXThrowExpr, otherwise returns None.
CXXTryStmt (ASTNode) CXXTryStmt
If the provided AST node is convertible to a CXXTryStmt, returns the node as a CXXTryStmt, otherwise returns None.
CXXTypeidExpr (ASTNode) CXXTypeidExpr
If the provided AST node is convertible to a CXXTypeidExpr, returns the node as a CXXTypeidExpr, otherwise returns None.
CallExpr (ASTNode) CallExpr
If the provided AST node is convertible to a CallExpr, returns the node as a CallExpr, otherwise returns None.
CaseStmt (ASTNode) CaseStmt
If the provided AST node is convertible to a CaseStmt, returns the node as a CaseStmt, otherwise returns None.
CastExpr (ASTNode) CastExpr
If the provided AST node is convertible to a CastExpr, returns the node as a CastExpr, otherwise returns None.
CharacterLiteral (ASTNode) CharacterLiteral
If the provided AST node is convertible to a CharacterLiteral, returns the node as a CharacterLiteral, otherwise returns None.
ClassTemplateDecl (ASTNode) ClassTemplateDecl
If the provided AST node is convertible to a ClassTemplateDecl, returns the node as a ClassTemplateDecl, otherwise returns None.
ClassTemplatePartialSpecializationDecl (ASTNode) ClassTemplatePartialSpecializationDecl
If the provided AST node is convertible to a ClassTemplatePartialSpecializationDecl, returns the node as a ClassTemplatePartialSpecializationDecl, otherwise returns None.
ClassTemplateSpecializationDecl (ASTNode) ClassTemplateSpecializationDecl
If the provided AST node is convertible to a ClassTemplateSpecializationDecl, returns the node as a ClassTemplateSpecializationDecl, otherwise returns None.
CompoundAssignOperator (ASTNode) CompoundAssignOperator
If the provided AST node is convertible to a CompoundAssignOperator, returns the node as a CompoundAssignOperator, otherwise returns None.
CompoundLiteralExpr (ASTNode) CompoundLiteralExpr
If the provided AST node is convertible to a CompoundLiteralExpr, returns the node as a CompoundLiteralExpr, otherwise returns None.
CompoundStmt (ASTNode) CompoundStmt
If the provided AST node is convertible to a CompoundStmt, returns the node as a CompoundStmt, otherwise returns None.
ConditionalOperator (ASTNode) ConditionalOperator
If the provided AST node is convertible to a ConditionalOperator, returns the node as a ConditionalOperator, otherwise returns None.
ContinueStmt (ASTNode) ContinueStmt
If the provided AST node is convertible to a ContinueStmt, returns the node as a ContinueStmt, otherwise returns None.
CoreturnStmt (ASTNode) CoreturnStmt
If the provided AST node is convertible to a CoreturnStmt, returns the node as a CoreturnStmt, otherwise returns None.
CoroutineBodyStmt (ASTNode) CoroutineBodyStmt
If the provided AST node is convertible to a CoroutineBodyStmt, returns the node as a CoroutineBodyStmt, otherwise returns None.
Decl (ASTNode) Decl
If the provided AST node is convertible to a Decl, returns the node as a Decl, otherwise returns None.
DeclRefExpr (ASTNode) DeclRefExpr
If the provided AST node is convertible to a DeclRefExpr, returns the node as a DeclRefExpr, otherwise returns None.
DeclStmt (ASTNode) DeclStmt
If the provided AST node is convertible to a DeclStmt, returns the node as a DeclStmt, otherwise returns None.
DeclaratorDecl (ASTNode) DeclaratorDecl
If the provided AST node is convertible to a DeclaratorDecl, returns the node as a DeclaratorDecl, otherwise returns None.
DecompositionDecl (ASTNode) DecompositionDecl
If the provided AST node is convertible to a DecompositionDecl, returns the node as a DecompositionDecl, otherwise returns None.
DefaultStmt (ASTNode) DefaultStmt
If the provided AST node is convertible to a DefaultStmt, returns the node as a DefaultStmt, otherwise returns None.
DesignatedInitExpr (ASTNode) DesignatedInitExpr
If the provided AST node is convertible to a DesignatedInitExpr, returns the node as a DesignatedInitExpr, otherwise returns None.
DoStmt (ASTNode) DoStmt
If the provided AST node is convertible to a DoStmt, returns the node as a DoStmt, otherwise returns None.
EmptyDecl (ASTNode) EmptyDecl
If the provided AST node is convertible to an EmptyDecl, returns the node as an EmptyDecl, otherwise returns None.
EnumConstantDecl (ASTNode) EnumConstantDecl
If the provided AST node is convertible to an EnumConstantDecl, returns the node as an EnumConstantDecl, otherwise returns None.
EnumDecl (ASTNode) EnumDecl
If the provided AST node is convertible to an EnumDecl, returns the node as an EnumDecl, otherwise returns None.
ExplicitCastExpr (ASTNode) ExplicitCastExpr
If the provided AST node is convertible to an ExplicitCastExpr, returns the node as an ExplicitCastExpr, otherwise returns None.
Expr (ASTNode) Expr
If the provided AST node is convertible to an Expr, returns the node as an Expr, otherwise returns None.
ExternCContextDecl (ASTNode) ExternCContextDecl
If the provided AST node is convertible to an ExternCContextDecl, returns the node as an ExternCContextDecl, otherwise returns None.
FieldDecl (ASTNode) FieldDecl
If the provided AST node is convertible to a FieldDecl, returns the node as a FieldDecl, otherwise returns None.
FloatingLiteral (ASTNode) FloatingLiteral
If the provided AST node is convertible to a FloatingLiteral, returns the node as a FloatingLiteral, otherwise returns None.
ForStmt (ASTNode) ForStmt
If the provided AST node is convertible to a ForStmt, returns the node as a ForStmt, otherwise returns None.
FriendDecl (ASTNode) FriendDecl
If the provided AST node is convertible to a FriendDecl, returns the node as a FriendDecl, otherwise returns None.
FriendTemplateDecl (ASTNode) FriendTemplateDecl
If the provided AST node is convertible to a FriendTemplateDecl, returns the node as a FriendTemplateDecl, otherwise returns None.
FunctionDecl (ASTNode) FunctionDecl
If the provided AST node is convertible to a FunctionDecl, returns the node as a FunctionDecl, otherwise returns None.
FunctionTemplateDecl (ASTNode) FunctionTemplateDecl
If the provided AST node is convertible to a FunctionTemplateDecl, returns the node as a FunctionTemplateDecl, otherwise returns None.
GNUNullExpr (ASTNode) GNUNullExpr
If the provided AST node is convertible to a GNUNullExpr, returns the node as a GNUNullExpr, otherwise returns None.
GenericSelectionExpr (ASTNode) GenericSelectionExpr
If the provided AST node is convertible to a GenericSelectionExpr, returns the node as a GenericSelectionExpr, otherwise returns None.
GotoStmt (ASTNode) GotoStmt
If the provided AST node is convertible to a GotoStmt, returns the node as a GotoStmt, otherwise returns None.
IfStmt (ASTNode) IfStmt
If the provided AST node is convertible to an IfStmt, returns the node as an IfStmt, otherwise returns None.
ImaginaryLiteral (ASTNode) ImaginaryLiteral
If the provided AST node is convertible to an ImaginaryLiteral, returns the node as an ImaginaryLiteral, otherwise returns None.
ImplicitCastExpr (ASTNode) ImplicitCastExpr
If the provided AST node is convertible to an ImplicitCastExpr, returns the node as an ImplicitCastExpr, otherwise returns None.
ImplicitParamDecl (ASTNode) ImplicitParamDecl
If the provided AST node is convertible to an ImplicitParamDecl, returns the node as an ImplicitParamDecl, otherwise returns None.
IndirectFieldDecl (ASTNode) IndirectFieldDecl
If the provided AST node is convertible to an IndirectFieldDecl, returns the node as an IndirectFieldDecl, otherwise returns None.
InitListExpr (ASTNode) InitListExpr
If the provided AST node is convertible to an InitListExpr, returns the node as an InitListExpr, otherwise returns None.
IntegerLiteral (ASTNode) IntegerLiteral
If the provided AST node is convertible to an IntegerLiteral, returns the node as an IntegerLiteral, otherwise returns None.
LabelDecl (ASTNode) LabelDecl
If the provided AST node is convertible to a LabelDecl, returns the node as a LabelDecl, otherwise returns None.
LabelStmt (ASTNode) LabelStmt
If the provided AST node is convertible to a LabelStmt, returns the node as a LabelStmt, otherwise returns None.
LambdaExpr (ASTNode) LambdaExpr
If the provided AST node is convertible to a LambdaExpr, returns the node as a LambdaExpr, otherwise returns None.
LinkageSpecDecl (ASTNode) LinkageSpecDecl
If the provided AST node is convertible to a LinkageSpecDecl, returns the node as a LinkageSpecDecl, otherwise returns None.
MemberExpr (ASTNode) MemberExpr
If the provided AST node is convertible to a MemberExpr, returns the node as a MemberExpr, otherwise returns None.
NamedDecl (ASTNode) NamedDecl
If the provided AST node is convertible to a NamedDecl, returns the node as a NamedDecl, otherwise returns None.
NamespaceAliasDecl (ASTNode) NamespaceAliasDecl
If the provided AST node is convertible to a NamespaceAliasDecl, returns the node as a NamespaceAliasDecl, otherwise returns None.
NamespaceDecl (ASTNode) NamespaceDecl
If the provided AST node is convertible to a NamespaceDecl, returns the node as a NamespaceDecl, otherwise returns None.
NullStmt (ASTNode) NullStmt
If the provided AST node is convertible to a NullStmt, returns the node as a NullStmt, otherwise returns None.
OffsetOfExpr (ASTNode) OffsetOfExpr
If the provided AST node is convertible to an OffsetOfExpr, returns the node as an OffsetOfExpr, otherwise returns None.
ParenExpr (ASTNode) ParenExpr
If the provided AST node is convertible to a ParenExpr, returns the node as a ParenExpr, otherwise returns None.
ParmVarDecl (ASTNode) ParmVarDecl
If the provided AST node is convertible to a ParmVarDecl, returns the node as a ParmVarDecl, otherwise returns None.
RecordDecl (ASTNode) RecordDecl
If the provided AST node is convertible to a RecordDecl, returns the node as a RecordDecl, otherwise returns None.
RedeclarableTemplateDecl (ASTNode) RedeclarableTemplateDecl
If the provided AST node is convertible to a RedeclarableTemplateDecl, returns the node as a RedeclarableTemplateDecl, otherwise returns None.
ReturnStmt (ASTNode) ReturnStmt
If the provided AST node is convertible to a ReturnStmt, returns the node as a ReturnStmt, otherwise returns None.
StaticAssertDecl (ASTNode) StaticAssertDecl
If the provided AST node is convertible to a StaticAssertDecl, returns the node as a StaticAssertDecl, otherwise returns None.
Stmt (ASTNode) Stmt
If the provided AST node is convertible to a Stmt, returns the node as a Stmt, otherwise returns None.
StmtExpr (ASTNode) StmtExpr
If the provided AST node is convertible to a StmtExpr, returns the node as a StmtExpr, otherwise returns None.
StringLiteral (ASTNode) StringLiteral
If the provided AST node is convertible to a StringLiteral, returns the node as a StringLiteral, otherwise returns None.
SwitchCase (ASTNode) SwitchCase
If the provided AST node is convertible to a SwitchCase, returns the node as a SwitchCase, otherwise returns None.
SwitchStmt (ASTNode) SwitchStmt
If the provided AST node is convertible to a SwitchStmt, returns the node as a SwitchStmt, otherwise returns None.
TagDecl (ASTNode) TagDecl
If the provided AST node is convertible to a TagDecl, returns the node as a TagDecl, otherwise returns None.
TemplateDecl (ASTNode) TemplateDecl
If the provided AST node is convertible to a TemplateDecl, returns the node as a TemplateDecl, otherwise returns None.
TemplateTypeParmDecl (ASTNode) TemplateTypeParmDecl
If the provided AST node is convertible to a TemplateTypeParmDecl, returns the node as a TemplateTypeParmDecl, otherwise returns None.
TranslationUnitDecl (ASTNode) TranslationUnitDecl
If the provided AST node is convertible to a TranslationUnitDecl, returns the node as a TranslationUnitDecl, otherwise returns None.
TypeAliasDecl (ASTNode) TypeAliasDecl
If the provided AST node is convertible to a TypeAliasDecl, returns the node as a TypeAliasDecl, otherwise returns None.
TypeAliasTemplateDecl (ASTNode) TypeAliasTemplateDecl
If the provided AST node is convertible to a TypeAliasTemplateDecl, returns the node as a TypeAliasTemplateDecl, otherwise returns None.
TypeDecl (ASTNode) TypeDecl
If the provided AST node is convertible to a TypeDecl, returns the node as a TypeDecl, otherwise returns None.
TypedefDecl (ASTNode) TypedefDecl
If the provided AST node is convertible to a TypedefDecl, returns the node as a TypedefDecl, otherwise returns None.
TypedefNameDecl (ASTNode) TypedefNameDecl
If the provided AST node is convertible to a TypedefNameDecl, returns the node as a TypedefNameDecl, otherwise returns None.
UnaryExprOrTypeTraitExpr (ASTNode) UnaryExprOrTypeTraitExpr
If the provided AST node is convertible to a UnaryExprOrTypeTraitExpr, returns the node as a UnaryExprOrTypeTraitExpr, otherwise returns None.
UnaryOperator (ASTNode) UnaryOperator
If the provided AST node is convertible to a UnaryOperator, returns the node as a UnaryOperator, otherwise returns None.
UserDefinedLiteral (ASTNode) UserDefinedLiteral
If the provided AST node is convertible to a UserDefinedLiteral, returns the node as a UserDefinedLiteral, otherwise returns None.
UsingDecl (ASTNode) UsingDecl
If the provided AST node is convertible to a UsingDecl, returns the node as a UsingDecl, otherwise returns None.
UsingDirectiveDecl (ASTNode) UsingDirectiveDecl
If the provided AST node is convertible to a UsingDirectiveDecl, returns the node as a UsingDirectiveDecl, otherwise returns None.
UsingShadowDecl (ASTNode) UsingShadowDecl
If the provided AST node is convertible to a UsingShadowDecl, returns the node as a UsingShadowDecl, otherwise returns None.
ValueDecl (ASTNode) ValueDecl
If the provided AST node is convertible to a ValueDecl, returns the node as a ValueDecl, otherwise returns None.
ValueStmt (ASTNode) ValueStmt
If the provided AST node is convertible to a ValueStmt, returns the node as a ValueStmt, otherwise returns None.
VarDecl (ASTNode) VarDecl
If the provided AST node is convertible to a VarDecl, returns the node as a VarDecl, otherwise returns None.
VarTemplateDecl (ASTNode) VarTemplateDecl
If the provided AST node is convertible to a VarTemplateDecl, returns the node as a VarTemplateDecl, otherwise returns None.
VarTemplatePartialSpecializationDecl (ASTNode) VarTemplatePartialSpecializationDecl
If the provided AST node is convertible to a VarTemplatePartialSpecializationDecl, returns the node as a VarTemplatePartialSpecializationDecl, otherwise returns None.
VarTemplateSpecializationDecl (ASTNode) VarTemplateSpecializationDecl
If the provided AST node is convertible to a VarTemplateSpecializationDecl, returns the node as a VarTemplateSpecializationDecl, otherwise returns None.
WhileStmt (ASTNode) WhileStmt
If the provided AST node is convertible to a WhileStmt, returns the node as a WhileStmt, otherwise returns None.
getLocation (ASTNode) Location
Returns the location of the provided AST node.
canDecayToPointerType (ASTType) Boolean
Returns true when isFunctionType or isArrayType would return true for the provided type.
getArrayElementType (ASTType) ASTType
If the provided type is an array type, returns the type of the array’s elements, otherwise returns None.
getArraySizeExpr (ASTType) Expr
If the provided type is a constant, dependent, or variable sized array, returns the expression that represents the array’s size, otherwise returns None.
getArraySizeModifier (ASTType) String
If the provided type is an array type, returns a string (one of "Normal", "Static", or "Star") that represents the array’s size modifier, otherwise returns None.
getAsCXXRecordDecl (ASTType) CXXRecordDecl
If the provided type is a CXXRecordDecl, returns the corresponding declaration, otherwise returns None.
getAsRecordDecl (ASTType) RecordDecl
If the provided type is a RecordDecl, returns the corresponding declaration, otherwise returns None.
getAsString (ASTType) String
Returns a string representation of the provided type.
getAsTagDecl (ASTType) TagDecl
If the provided type is a TagDecl, returns the corresponding declaration, otherwise returns None.
getAtomicUnqualifiedType (ASTType) ASTType
Returns the provided type with const, volatile, restrict, and _Atomic qualifier removed.
getCanonicalType (ASTType) ASTType
Returns the canonical type of the provided type.
getConstantArraySize (ASTType) Integral
If the provided type is a constant sized array, return the size value of the array, otherwise returns None.
getFunctionCallResultType (ASTType) ASTType
if the provided type is a function type, returns the function’s call result type, otherwise returns None.
getFunctionReturnType (ASTType) ASTType
If the provided type is a function type, returns the function’s return type, otherwise returns None.
getNonReferenceType (ASTType) ASTType
If the provided type is a reference type, returns the type to which the reference refers, otherwise returns the provided type.
getPointeeCXXRecordDecl (ASTType) CXXRecordDecl
If the provided type is a pointer or reference to a CXXRecordDecl, returns the corresponding CXXRecordDecl, otherwise returns None.
getPointeeType (ASTType) ASTType
If the provided type is a pointer, pointer to member, or reference type, returns the corresponding pointee type, otherwise returns None.
getTypeSizeInBits (ASTType) Integral
Returns size of the provided type, if known, in bits.
getTypeSizeInChars (ASTType) Integral
Returns size of the provided type, if known, in char units.
hasLocalQualifiers (ASTType) Boolean
Returns true if the provided type is locally qualified.
hasQualifiers (ASTType) Boolean
Returns true if the provided type is const, restrict, or volatile qualified.
isAggregateType (ASTType) Boolean
Returns true the provided type is a C++ aggregate type or a C aggregate or union type.
isAnyCharacterType (ASTType) Boolean
Returns true if isCharType, isWideCharType, isChar8Type, isChar16Type, or isChar32Type would return true for the provided type.
isAnyComplexType (ASTType) Boolean
Returns true if the provided type is an integral or floating point complex type.
isArithmeticType (ASTType) Boolean
Returns true when either isRealType or isAnyComplexType would return true.
isArrayIndexTypeConstQualified (ASTType) Boolean
Returns true if the provided type is an array type with a const qualified index type such as the type returns by getOriginalType for the ParmVarDecl for the parameter in a function declared as void foo(int a[const n]);.
isArrayIndexTypeRestrictQualified (ASTType) Boolean
Returns true if the provided type is an array type with a restrict qualified index type such as the type returns by getOriginalType for the ParmVarDecl for the parameter in a function declared as void foo(int a[restrict n]);.
isArrayIndexTypeVolatileQualified (ASTType) Boolean
Returns true if the provided type is an array type with a volatile qualified index type such as the type returns by getOriginalType for the ParmVarDecl for the parameter in a function declared as void foo(int a[volatile n]);.
isArrayType (ASTType) Boolean
Returns true if the provided type is an array type.
isAtLeastAsQualifiedAs (ASTType ASTType) Boolean
Returns true if the first provided type is at least as qualified as the second provided type.
isAtomicType (ASTType) Boolean
Returns true if the provided type is a C11 atomic type declared with _Atomic.
isBooleanType (ASTType) Boolean
Returns true if the provided type is a Boolean type.
isBuiltinType (ASTType) Boolean
Returns true if the provided type corresponds to a builtin type.
isCForbiddenLValueType (ASTType) Boolean
Returns true if the provided type is the unqualified void type or a function type.
isCXX11PODType (ASTType) Boolean
Returns true if the provided type is a POD type according to the rules of the C++ 11 standard.
isCXX98PODType (ASTType) Boolean
Returns true if the provided type is a POD type according to the rules of the C++ 98 standard.
isChar16Type (ASTType) Boolean
Returns true if the canonical type of the provided type is char16_t.
isChar32Type (ASTType) Boolean
Returns true if the canonical type of the provided type is char32_t.
isChar8Type (ASTType) Boolean
Returns true if the canonical type of the provided type is char8_t.
isCharType (ASTType) Boolean
Returns true if the canonical type of the provided type is one of char, signed char, or unsigned char.
isClassType (ASTType) Boolean
Returns true if the provided type is a class type, declared with the class keyword.
isComplexType (ASTType) Boolean
Returns true if the provided type is a complex floating point type.
isCompoundType (ASTType) Boolean
Returns true if the provided type is a compound type, i.e. if any of isArrayType, isFunctionType, isPointerType, isReferenceType, isRecordType, isUnionType, isEnumeralType, or isMemberPointerType would return true for the provided type.
isConstQualified (ASTType) Boolean
Returns true if the provided type is const qualified.
isConstantArrayType (ASTType) Boolean
Returns true if the provided type is a constant sized array type (e.g. int array[10];).
isConstantSizeType (ASTType) Boolean
Returns true if the provided type is not an incomplete, dependent, or variable-sized type.
isDependentSizedArrayType (ASTType) Boolean
Returns true if the provided type is a dependent sized array type (e.g. int array[T];).
isDependentType (ASTType) Boolean
Returns true if the definition of the provided type depends on a template parameter.
isElaboratedTypeSpecifier (ASTType) Boolean
Returns true if the provided type is a C++ elaborated-type-specifier.
isEnumeralType (ASTType) Boolean
Returns true if the provided type is an enumeral type.
isFloatingType (ASTType) Boolean
Returns true if the provided type is a real or complex floating point type.
isFunctionNoProtoType (ASTType) Boolean
Returns true if the provided type is a function type without parameter type information.
isFunctionPointerType (ASTType) Boolean
Returns true if the provided type is a function pointer type.
isFunctionProtoType (ASTType) Boolean
Returns true if the provided type is a function type with parameter type information.
isFunctionType (ASTType) Boolean
Returns true if the provided type is a function type.
isFundamentalType (ASTType) Boolean
Returns true if the provided type is a fundamental type, i.e. if isVoidType, isNullPtrType, or isArithmeticType would return true for the provided type and isEnumeralType type would return false.
isIncompleteArrayType (ASTType) Boolean
Returns true if the provided type is an incomplete array type (e.g. int array[];).
isIncompleteOrObjectType (ASTType) Boolean
Returns true if the provided type is an incomplete or object type, i.e. not a function type.
isIncompleteType (ASTType) Boolean
Returns true if the provided type is an incomplete type, i.e. not an object or function type.
isInstantiationDependentType (ASTType) Boolean
Returns true if the provided type involves a template parameter, regardless of whether its definition depends on template parameter.
isIntegerType (ASTType) Boolean
Returns true if the provided type is a (non-complex) integer type.
isIntegralOrEnumerationType (ASTType) Boolean
Returns true if the provided type has integral or enumeration type.
isIntegralOrUnscopedEnumerationType (ASTType) Boolean
Returns true if the provided type has integral or unscoped enumeration type.
isIntegralType (ASTType) Boolean
Returns true if the provided type has integral type.
isInterfaceType (ASTType) Boolean
Returns true if the provided type is an interface type.
isLValueReferenceType (ASTType) Boolean
Returns true if the provided type is a lvalue-reference type.
isLiteralType (ASTType) Boolean
Returns true if the provided type is a C++ 11 literal type.
isLocalConstQualified (ASTType) Boolean
Returns true if the provided type is locally const qualified.
isLocalRestrictQualified (ASTType) Boolean
Returns true if the provided type is locally restrict qualified.
isLocalVolatileQualified (ASTType) Boolean
Returns true if the provided type is locally volatile qualified.
isMemberDataPointerType (ASTType) Boolean
Returns true if the provided type is a pointer to data member type.
isMemberFunctionPointerType (ASTType) Boolean
Returns true if the provided type is a pointer to function member type.
isMemberPointerType (ASTType) Boolean
Returns true when either isMemberFunctionPointerType or isMemberDataPointerType would return true.
isMoreQualifiedThan (ASTType ASTType) Boolean
Returns true if the first provided type is at more as qualified as the second provided type.
isNothrowT (ASTType) Boolean
Returns true if the provided type is the std::nothrow_t type.
isNullPtrType (ASTType) Boolean
Returns true if the provided type is the std::nullptr_t type.
isObjectType (ASTType) Boolean
Returns true if the provided type is an object type, i.e. not an incomplete or function type.
isOverloadableType (ASTType) Boolean
Returns true when isDependentType, isRecordType, or isEnumeralType would return true for the provided type.
isPODType (ASTType) Boolean
Returns true if the provided type is a POD type according to the current C++ language mode.
isPointerType (ASTType) Boolean
Returns true if the provided type is a pointer type.
isPromotableIntegerType (ASTType) Boolean
Returns true if the provided type is promotable.
isRValueReferenceType (ASTType) Boolean
Returns true if the provided type is a rvalue-reference type.
isRealFloatingType (ASTType) Boolean
Returns true if the provided type is a real (i.e. not complex) floating point type (e.g. float, double, etc.).
isRealType (ASTType) Boolean
Returns true if the provided type is a real (not complex) floating point or integral type or a non-scoped, complete, enumeration type.
isRecordType (ASTType) Boolean
Returns true when the isStructureOrClassType or isUnionType functions would return true.
isReferenceType (ASTType) Boolean
Returns true if the provided type is a reference type.
isRestrictQualified (ASTType) Boolean
Returns true if the provided type is restrict qualified.
isScalarType (ASTType) Boolean
Returns true if the provided type is a scalar type.
isScopedEnumeralType (ASTType) Boolean
Returns true if the provided type is a scoped enumeration type.
isSignedIntegerOrEnumerationType (ASTType) Boolean
Returns true if the provided type is a signed integer type or has enumeration type with an underlying signed integer type.
isSignedIntegerType (ASTType) Boolean
Returns true if the provided type is a signed integer type or has unscoped enumeration type with an underlying signed integer type.
isStandardLayoutType (ASTType) Boolean
Returns true if the provided type is a standard-layout type.
isStdByteType (ASTType) Boolean
Returns true if the provided type is the std::byte type.
isStdInitList (ASTType) Boolean
Returns true if the provided type is an instantiation of std::initializer_list.
isStructuralType (ASTType) Boolean
Returns true if the provided type is a C++ 20 structural type.
isStructureOrClassType (ASTType) Boolean
Returns true when the isClassType, isStructureType, or isInterfaceType functions would return true.
isStructureType (ASTType) Boolean
Returns true if the provided type is a structure or class type, declared with the struct keyword.
isTemplateTypeParmType (ASTType) Boolean
Returns true if the provided type is a template type parameter type.
isTrivialType (ASTType) Boolean
Returns true if the provided type is a trivial type.
isTriviallyCopyableType (ASTType) Boolean
Returns true if the provided type is trivially copyable.
isTypedefNameType (ASTType) Boolean
Returns true if the provided type was written as a typedef name.
isUnionType (ASTType) Boolean
Returns true if the provided type is a union type.
isUnscopedEnumerationType (ASTType) Boolean
Returns true if the provided type is a non-scoped enumeration type.
isUnsignedIntegerOrEnumerationType (ASTType) Boolean
Returns true if the provided type is an unsigned integer type or has enumeration type with an underlying unsigned integer type.
isUnsignedIntegerType (ASTType) Boolean
Returns true if the provided type is an unsigned integer type or has unscoped enumeration type with an underlying unsigned integer type.
isVariableArrayType (ASTType) Boolean
Returns true if the provided type is a variably sized array type (e.g. int array[n];).
isVariablyModifiedType (ASTType) Boolean
Returns true if this is a C99 variably modified type (the type of a variable length array).
isVoidPointerType (ASTType) Boolean
Returns true if the provided type is a void pointer type.
isVoidType (ASTType) Boolean
Returns true if the provided type is a void type.
isVolatileQualified (ASTType) Boolean
Returns true if the provided type is volatile qualified.
isWideCharType (ASTType) Boolean
Returns true if the canonical type of the provided type is wchar_t.
getBase (ArraySubscriptExpr) Expr
Returns the expression that forms the base of the provided array subscript expression, regardless of operand order.
getIdx (ArraySubscriptExpr) Expr
Returns the expression that forms the index of the provided array subscript epression, regardless of operand order.
getLHS (ArraySubscriptExpr) Expr
Returns the expression appearing on the LHS of the provided array subscript expression.
getRHS (ArraySubscriptExpr) Expr
Returns the expression appearing on the RHS of the provided array subscript expression, i.e. the expression enclosed by square brackets.
getSubStmt (AttributedStmt) Stmt
Returns the substatement of the provided attributed statement.
getLHS (BinaryOperator) Expr
Returns the LHS operand of the provided binary operator.
getOpcodeStr (BinaryOperator) String
Returns the string representation of the binary operator.
getRHS (BinaryOperator) Expr
Returns the RHS operand of the provided binary operator.
isAdditiveOp (BinaryOperator) Boolean
Returns true if the provided binary operator is an additive operator.
isAssignmentOp (BinaryOperator) Boolean
Returns true if the provided binary operator is an assignment operator.
isBitwiseOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a bitwise operator.
isCommaOp (BinaryOperator) Boolean
Returns true if the provided binary operator is the comma operator.
isComparisonOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a comparison operator.
isCompoundAssignmentOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a compound assignment operator.
isEqualityOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a equality operator.
isLogicalOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a logical operator.
isMultiplicativeOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a multiplicative operator.
isPtrMemOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a pointer-to-member operator.
isRelationalOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a relational operator.
isShiftAssignOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a shift assignment operator.
isShiftOp (BinaryOperator) Boolean
Returns true if the provided binary operator is a shift operator.
getValue (CXXBoolLiteralExpr) Boolean
Returns the value of the provided Boolean literal expression.
getCaughtType (CXXCatchStmt) ASTType
Returns the type caught by the provided catch statement of None if the provided catch statement does not specify a type, i.e. catch (...).
getExceptionDecl (CXXCatchStmt) VarDecl
Returns the variable associated with the provided catch statement or None if the provided catch statement does not specify a type, i.e. catch (...).
getHandlerBlock (CXXCatchStmt) Stmt
Returns the statement that comprises the handler block of the provided catch statement.
getArg (CXXConstructExpr Integral) Expr
Returns the specified argument in the provided construct expression.
getConstructor (CXXConstructExpr) CXXConstructorDecl
Returns the constructor that will be invoked by the provided construct expression.
getNumArgs (CXXConstructExpr) Integral
Returns the number of argument in the provided construct expression, including default arguments.
hadMultipleCandidates (CXXConstructExpr) Boolean
Returns true if the constructor associated with the provided construct expression was resolved from an overload set with multiple candidates.
isImmediateEscalating (CXXConstructExpr) Boolean
Returns true if the provided construct expression is immediate-escalating, a category introduced in C++ 23.
isListInitialization (CXXConstructExpr) Boolean
Returns true if the provided construct expression was written with list-initialization.
isStdInitListInitialization (CXXConstructExpr) Boolean
Returns true if the provided construct expression was written with list-initialization but was interpreted as forming a std::initializer_list<T> from the list and passing that as a single constructor argument.
getInheritedConstructor (CXXConstructorDecl) CXXConstructorDecl
If the provided constructor is an inheriting constructor, returns the constructor that this constructor is based on, otherwise returns None.
getNumCtorInitializers (CXXConstructorDecl) Integral
Returns the number of initializers in the provided constructor.
getTargetConstructor (CXXConstructorDecl) CXXConstructorDecl
If the provided constructor is a delegating constructor, returns the constructor to which it delegates, otherwise returns None.
isConvertingConstructor (CXXConstructorDecl Boolean) Boolean
Returns true if the provided constructor can be used for user-defined conversions.
isCopyConstructor (CXXConstructorDecl) Boolean
Returns true if the provided constructor is a copy constructor.
isCopyOrMoveConstructor (CXXConstructorDecl) Boolean
Returns true if the provided constructor is a copy constructor or a move constructor.
isDefaultConstructor (CXXConstructorDecl) Boolean
Returns true if the provided constructor can be called without any arguments.
isDelegatingConstructor (CXXConstructorDecl) Boolean
Returns true if the provided constructor is a delegating constructor.
isExplicit (CXXConstructorDecl) Boolean
Returns true if the provided constructor is marked as explicit.
isInheritingConstructor (CXXConstructorDecl) Boolean
Returns true if the provided constructor is an implicit constructor synthesized to model a call to a constructor inherited from a base class.
isMoveConstructor (CXXConstructorDecl) Boolean
Returns true if the provided constructor is a move constructor.
isSpecializationCopyingObject (CXXConstructorDecl) Boolean
Returns true if the provided constructor is a member template specialization that would copy the object to itself.
getConversionType (CXXConversionDecl) ASTType
Returns the type that the provided conversion function converts to.
isExplicit (CXXConversionDecl) Boolean
Returns true if the provided conversion function is marked as explicit.
getOperatorDelete (CXXDestructorDecl) FunctionDecl
Returns the operator delete function associated with the provided destructor.
getOperatorDeleteThisArg (CXXDestructorDecl) Expr
Returns the operator delete ’this’ argument associated with the provided destructor.
getBody (CXXForRangeStmt) Stmt
Returns the statement that forms the body of the provided for-range statement.
getInit (CXXForRangeStmt) Stmt
If the provided for-range statement contains an initialization clause, returns the statement that serves as that clause, otherwise returns None.
getLoopVarStmt (CXXForRangeStmt) DeclStmt
Returns the declaration statement of the loop variable of the provided for-range statement.
getLoopVariable (CXXForRangeStmt) VarDecl
Returns the loop variable of the provided for-range statement.
getRangeInit (CXXForRangeStmt) Expr
Returns the range expression of the provided for-range statement.
getNumExplicitParams (CXXMethodDecl) Integral
Returns the number of parameters the function is declared as receiving. This does not count an explicit object parameter, introduced in C++ 23.
getOverriddenMethod (CXXMethodDecl Integral) CXXMethodDecl
Returns the specified overridden function of the provided member function.
getParent (CXXMethodDecl) CXXRecordDecl
Returns the class in which the provided member function was defined.
getThisObjectType (CXXMethodDecl) ASTType
Returns the type pointed to by the ’this’ object associated with the provided member function or None if the member function is static.
getThisType (CXXMethodDecl) ASTType
Returns the type of the ’this’ object associated with the provided member function or None if the member function is static.
hasInlineBody (CXXMethodDecl) Boolean
Returns true if the provided member function has an inlined body.
isConst (CXXMethodDecl) Boolean
Returns true if the provided member function is const.
isCopyAssignmentOperator (CXXMethodDecl) Boolean
Returns true if the provided member function is a copy assignment operator.
isExplicitObjectMemberFunction (CXXMethodDecl) Boolean
Returns true if the provided member function is an explicit object member function, introduced in C++ 23.
isImplicitObjectMemberFunction (CXXMethodDecl) Boolean
Returns true if the provided member function does not contain an explicit object parameter, introduced in C++ 23.
isInstance (CXXMethodDecl) Boolean
Returns true if the provided member function is not static.
isLValueRefQualified (CXXMethodDecl) Boolean
Returns true if the provided member function is lvalue-ref-qualified.
isLambdaStaticInvoker (CXXMethodDecl) Boolean
Returns true if the provided member function is a lambda closure type’s static member function that is used for the result of the lambda’s conversion to function pointer.
isMoveAssignmentOperator (CXXMethodDecl) Boolean
Returns true if the provided member function is a move assignment operator.
isRValueRefQualified (CXXMethodDecl) Boolean
Returns true if the provided member function is rvalue-ref-qualified.
isRefQualified (CXXMethodDecl) Boolean
Returns true if the provided member function is ref-qualified.
isStatic (CXXMethodDecl) Boolean
Returns true if provided member function is static.
isVirtual (CXXMethodDecl) Boolean
Returns true if the provided member function is virtual.
isVolatile (CXXMethodDecl) Boolean
Returns true if the provided member function is volatile.
numOverriddenMethods (CXXMethodDecl) Integral
Returns the number of member functions overridden by the provided member function.
defaultedCopyConstructorIsDeleted (CXXRecordDecl) Boolean
Returns true if a defaulted copy constructor for the provided class would be deleted.
defaultedDestructorIsDeleted (CXXRecordDecl) Boolean
Returns true if a defaulted destructor for the provided class would be deleted.
defaultedMoveConstructorIsDeleted (CXXRecordDecl) Boolean
Returns true if a defaulted move constructor for the provided class would be deleted.
getBase (CXXRecordDecl Integral) ASTType
Returns the specified base of the provided class.
getConstructor (CXXRecordDecl Integral) CXXConstructorDecl
Returns the specified constructor of the provided class.
getDependentLambdaCallOperator (CXXRecordDecl) FunctionTemplateDecl
If the provided class corresponds to a templated closure type, returns the dependent lambda call operator of the closure type, otherwise returns None.
getDescribedClassTemplate (CXXRecordDecl) ClassTemplateDecl
Returns the class template that is described the the provided class if any, otherwise returns None.
getDestructor (CXXRecordDecl) CXXDestructorDecl
Returns the destructor of the provided class.
getFriend (CXXRecordDecl Integral) FriendDecl
Returns the specified friend of the provided class.
getInstantiatedFromMemberClass (CXXRecordDecl) CXXRecordDecl
If the provided class is a member class instantiation, returns the member class from which it was instantiated, otherwise returns None.
getLambdaCallOperator (CXXRecordDecl) CXXMethodDecl
If the provided class is a closure type, returns the lambda call operator, otherwise returns None.
getLambdaStaticInvoker (CXXRecordDecl) CXXMethodDecl
If the provided class corresponds to a lambda, returns the lambda static invoker, otherwise returns None.
getMethod (CXXRecordDecl Integral) CXXMethodDecl
Returns the specified member function of the provided class.
getNumBases (CXXRecordDecl) Integral
Returns the number of bases the provided class was defined with or None if the class is not defined.
getNumVBases (CXXRecordDecl) Integral
Returns the number of virtual bases the provided class was defined with or None if the class is not defined.
getTemplateInstantiationPattern (CXXRecordDecl) CXXRecordDecl
If the provided class is a template instantiation, returns the class from which it could have been instantiated, otherwise returns None.
getVirtualBase (CXXRecordDecl Integral) ASTType
Returns the specified virtual base of the provided class.
hasConstexprDefaultConstructor (CXXRecordDecl) Boolean
Returns true if the provided class as a constexpr default constructor.
hasConstexprDestructor (CXXRecordDecl) Boolean
Returns true if the provided class has a constexpr destructor.
hasConstexprNonCopyMoveConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a constexpr constructor that is neither a copy constructor nor a move constructor.
hasCopyAssignmentWithConstParam (CXXRecordDecl) Boolean
Returns true if the provided class has a copy assignment operator with reference to const-qualified type as a parameter.
hasCopyConstructorWithConstParam (CXXRecordDecl) Boolean
Returns true if the provided class has a copy constructor with reference to const-qualified type as a parameter.
hasDefaultConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has one or more default constructors.
hasDefinition (CXXRecordDecl) Boolean
Returns true if the class associated with the provided declaration is defined in the current module.
hasDirectFields (CXXRecordDecl) Boolean
Returns true if the provided class declared any non-static data members.
hasFriends (CXXRecordDecl) Boolean
Returns true if the provided class was defined with one or more friends.
hasInClassInitializer (CXXRecordDecl) Boolean
Returns true if the provided class has an in-class initializer for any non-static data members.
hasInheritedAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a using-declaration that names a base class assignment operator.
hasInheritedConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a using-declaration that names a user-declared base class constructor.
hasIrrelevantDestructor (CXXRecordDecl) Boolean
Returns true if the provided class has a destructor with no semantic effect.
hasMoveAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a move assignment operator.
hasMoveConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a move constructor.
hasMutableFields (CXXRecordDecl) Boolean
Returns true if the provided class contains any mutable fields or inherits from a class that does.
hasNonLiteralTypeFieldsOrBases (CXXRecordDecl) Boolean
Returns true if the provided class has non-literal type, non-literal fields, or non-literal bases.
hasNonTrivialCopyAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a non-trivial copy assignment operator.
hasNonTrivialCopyConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a non-trivial copy constructor.
hasNonTrivialDefaultConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a non-trivial default constructor.
hasNonTrivialDestructor (CXXRecordDecl) Boolean
Returns true if the provided class has a non-trivial destructor.
hasNonTrivialMoveAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a non-trivial move assignment operator.
hasNonTrivialMoveConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a non-trivial move constructor.
hasPrivateFields (CXXRecordDecl) Boolean
Returns true if the provided class declares any private non-static data members.
hasProtectedFields (CXXRecordDecl) Boolean
Returns true if the provided class declares any protected non-static data members.
hasSimpleCopyAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a single, accessible, unambiguous copy assignment operator that is not deleted.
hasSimpleCopyConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a single, accessible, unambiguous copy constructor that is not deleted.
hasSimpleDestructor (CXXRecordDecl) Boolean
Returns true if the provided class has an accessible destructor that is not deleted.
hasSimpleMoveAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a single, accessible, unambiguous move assignment operator that is not deleted.
hasSimpleMoveConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a single, accessible, unambiguous move constructor that is not deleted.
hasTrivialCopyAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a trivial copy assignment operator.
hasTrivialCopyConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a trivial copy constructor.
hasTrivialDefaultConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a trivial default constructor.
hasTrivialDestructor (CXXRecordDecl) Boolean
Returns true if the provided class has a trivial destructor.
hasTrivialMoveAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a trivial move assignment operator.
hasTrivialMoveConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a trivial move constructor.
hasUninitializedReferenceMember (CXXRecordDecl) Boolean
Returns true if the provided class contains one or more reference members and the class does not have a user-declared constructor.
hasUserDeclaredConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a user-declared constructor.
hasUserDeclaredCopyAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a user-declared copy assignment operator.
hasUserDeclaredCopyConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a user-declared copy constructor.
hasUserDeclaredDestructor (CXXRecordDecl) Boolean
Returns true if the provided class has a user-declared destructor.
hasUserDeclaredMoveAssignment (CXXRecordDecl) Boolean
Returns true if the provided class has a user-declared move assignment operator.
hasUserDeclaredMoveConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a user-declared move constructor.
hasUserDeclaredMoveOperation (CXXRecordDecl) Boolean
Returns true if the provided class has user-declared move constructor or a user-declared move assignment operator.
hasUserProvidedDefaultConstructor (CXXRecordDecl) Boolean
Returns true if the provided class has a user-provided default constructor.
hasVariantMembers (CXXRecordDecl) Boolean
Returns true if the provided class has any variant members.
isAbstract (CXXRecordDecl) Boolean
Returns true if the provided class declares a pure virtual function or inherits a pure virtual function that it does not override.
isAggregate (CXXRecordDecl) Boolean
Returns true if the provided class is an aggregate. An aggregate is a class having no user-declared constructors and no base classes, virtual functions, or non-public non-static data members.
isAnyDestructorNoReturn (CXXRecordDecl) Boolean
Returns true if the provided class’ destructor, or any implicitly invoked destructor, are declared as not returning.
isCLike (CXXRecordDecl) Boolean
Returns true if the provided class does not utilize C++ -specific features such as non-public fields, base classes, member functions, use of the ’class’ keyword, etc.
isCXX11StandardLayout (CXXRecordDecl) Boolean
Returns true of the provided class has standard layout as defined by C++ 11.
isCapturelessLambda (CXXRecordDecl) Boolean
Returns true if the class is a lambda and does not have any captures.
isDerivedFrom (CXXRecordDecl CXXRecordDecl) Boolean
Returns true if the first provided class is derived from the second provided class.
isEmpty (CXXRecordDecl) Boolean
Returns true if the provided class would be considered empty by the std::is_empty type trait. A class is considered empty if it is a non-union class which does not have any virtual functions or virtual base classes, whose only non-static data members are zero width bit-fields, and any base classes are also empty.
isGenericLambda (CXXRecordDecl) Boolean
Returns true if the provided class describes a generic lambda function object.
isInterfaceLike (CXXRecordDecl) Boolean
Returns true if the provided class is declared using the non-standard ’interface’ keyword or has a single interface-like base class and no user-declared constructors, destructors, conversion functions, friends, fields, virtual bases, member function definitions.
isLambda (CXXRecordDecl) Boolean
Returns true if the provided class describes a lambda function object.
isLiteral (CXXRecordDecl) Boolean
Returns true if the provided class is a literal type in the current C++ language mode.
isLocalClass (CXXRecordDecl) FunctionDecl
If the provided class is a local class, returns the enclosing function declaration, otherwise returns None.
isPOD (CXXRecordDecl) Boolean
Returns true if the provided class is a POD type as defined in C++ TR1.
isPolymorphic (CXXRecordDecl) Boolean
Returns true if the provided class contains or inherits any virtual functions.
isProvablyNotDerivedFrom (CXXRecordDecl CXXRecordDecl) Boolean
Returns true if the first provided class is provably not derived from the second provided class.
isStandardLayout (CXXRecordDecl) Boolean
Returns true of the provided class has standard layout as defined by C++ .
isStructural (CXXRecordDecl) Boolean
Returns true if the provided class is a structural type.
isTrivial (CXXRecordDecl) Boolean
Returns true if the provided class is trivial, that is it has a trivial default constructor and is trivially copyable.
isTriviallyCopyConstructible (CXXRecordDecl) Boolean
Returns true if the provided class is trivially copy constructible.
isTriviallyCopyable (CXXRecordDecl) Boolean
Returns true if the provided class is trivially copyable.
isVirtuallyDerivedFrom (CXXRecordDecl CXXRecordDecl) Boolean
Returns true if the first provided class is virtually derived from the second provided class.
lambdaIsDefaultConstructibleAndAssignable (CXXRecordDecl) Boolean
Returns true if the provided class is a closure type with implicit default constructor and copy and move assignment operators. Returns None if the provided class is not a lambda function object.
numBases (CXXRecordDecl) Integral
Returns the number of bases of the provided class.
numConstructors (CXXRecordDecl) Integral
Returns the number of constructors of the provided class.
numFriends (CXXRecordDecl) Integral
Returns the number of friends of the provided class.
numMethods (CXXRecordDecl) Integral
Returns the number of member functions of the provided class.
numVirtualBases (CXXRecordDecl) Integral
Returns the number of virtual bases of the provided class.
getHandler (CXXTryStmt Integral) CXXCatchStmt
Returns the ’catch’ statement corresponding to the specified exception handler for the provided ’try’ statement.
getNumHandlers (CXXTryStmt) Integral
Returns the number of exception handlers for the provided ’try’ statement.
getTryBlock (CXXTryStmt) CompoundStmt
Returns the compound statement forming the try-block of the provided ’try’ statement.
getArg (CallExpr Integral) Expr
Returns the specified argument in the provided call expression.
getCallReturnType (CallExpr) ASTType
Returns the return type of the provided call expression which may be different than the type of the expression for functions returning a reference type.
getCallee (CallExpr) Expr
Returns the expression that comprises the function being called in the provided call expression.
getCalleeDecl (CallExpr) Decl
Returns the declaration associated with the callee in the provided call expression.
getDirectCallee (CallExpr) FunctionDecl
Returns the declaration of the function called by the provided call expression if this is a direct function call (e.g. not a call through a function pointer variable).
getNumArgs (CallExpr) Integral
Returns the number of arguments in the call to the provided call expression, including any default arguments.
hasUnusedResultAttr (CallExpr) Boolean
Returns true if the provided call expression involves a return type or a called function declared with the nodiscard attribute.
isCallToStdMove (CallExpr) Boolean
Returns true if the provided call expression represents a call to std::move.
usesADL (CallExpr) Boolean
Returns true if the provided call expression employs argument-dependent lookup.
getCastKindName (CastExpr) String
Returns a string representing the kind of conversion employed by the provided conversion expression.
getConversionFunction (CastExpr) NamedDecl
Returns the conversion function used to perform the provided conversion if any, otherwise returns None.
getSubExpr (CastExpr) Expr
Returns the converted expression of the provided conversion expression.
getValue (CharacterLiteral) Integral
Returns the numeric value of the provided character literal.
isAscii (CharacterLiteral) Boolean
Returns true if the provided character literal is an ascii character.
isUTF16 (CharacterLiteral) Boolean
Returns true if the provided character literal is a UTF16 character.
isUTF32 (CharacterLiteral) Boolean
Returns true if the provided character literal is a UTF32 character.
isUTF8 (CharacterLiteral) Boolean
Returns true if the provided character literal is a UTF8 character.
isWide (CharacterLiteral) Boolean
Returns true if the provided character literal is a wide character.
getNumStmts (CompoundStmt) Integral
Returns the number of (top-level) statements in the provided compound statement.
getStmt (CompoundStmt Integral) Stmt
Returns the specified statement in the provided compound statement.
getStmtExprResult (CompoundStmt) Stmt
Returns the statement that would be used as the result of a GCC compound expression.
getOperand (CoreturnStmt) Expr
Returns the return value expression of the provided coreturn statement if any, otherwise returns None.
getPromiseCall (CoreturnStmt) Expr
Returns the promise call that results from the provided coreturn statement if any, otherwise returns None.
isImplicit (CoreturnStmt) Boolean
Returns true if the provided coreturn statement is implicit.
getAllocate (CoroutineBodyStmt) Expr
Returns the allocation expression for the provided coroutine.
getBody (CoroutineBodyStmt) Stmt
Returns the body of the provided coroutine.
getDeallocate (CoroutineBodyStmt) Expr
Returns the deallocation expression for the provided coroutine.
dump (Decl) String
Returns a string containing the AST tree of the provided declaration.
getAccess (Decl) String
Returns a string ("public", "protected", "private", or "none") indicating the access of the provided declaration.
getBeginLoc (Decl) Location
Returns the Location associated with the beginning of the provided declaration.
getCanonicalDecl (Decl) Decl
Returns the canonical declaration of the provided declaration.
getDeclContext (Decl) Decl
Returns the semantic declaration context of the provided declaration.
getDeclKindName (Decl) String
Returns a string representing the kind of the provided declaration.
getEndLoc (Decl) Location
Returns the Location associated with the end of the provided declaration.
getLexicalDeclContext (Decl) Decl
Returns the lexical declaration context of the provided declaration.
getMaxAlignment (Decl) String
Returns the maximum alignment as specified by attributes applied to the provided declaration or 0.
getParentFunctionOrMethod (Decl) FunctionDecl
If the provided declaration was declared within a function, returns that function, otherwise returns None.
getTemplateDepth (Decl) Integral
Returns the number of levels of template parameter surrounding the provided declaration.
hasBody (Decl) Boolean
Returns true if the provided declaration has a body.
isCanonicalDecl (Decl) Boolean
Returns the canonical declaration associated with the provided declaration.
isFirstDecl (Decl) Boolean
Returns true if the provided declaration is the first declaration of the declared entity.
isFunctionOrFunctionTemplate (Decl) Boolean
Returns true if the provided declaration is a function or function template.
isImplicit (Decl) Boolean
Returns true if the provided declaration was implicitly generated.
isInAnonymousNamespace (Decl) Boolean
Returns true if the provided declaration was declared in an anonymous namespace.
isInStdNmespace (Decl) Boolean
Returns true if the provided declaration was declared in the std namespace.
isInvalidDecl (Decl) Boolean
Returns true if the provided declaration is invalid, e.g. if semantic error occurred during processing of the declaration.
isLocalExternDecl (Decl) Boolean
Returns true if the provided declaration is a block-scope declaration with linkage.
isOutOfLine (Decl) Boolean
Returns true if the provided declaration was declared outside of its semantic context.
isParameterPack (Decl) Boolean
Returns true if the provided declaration is a parameter pack.
isReferenced (Decl) Boolean
Returns true if the provided declaration, or any of its redeclarations, was referenced.
isTemplateDecl (Decl) Boolean
Returns true if the provided declaration is a template.
isTemplateParameter (Decl) Boolean
Returns true if the provided declaration is a template parameter.
isTemplateParameterPack (Decl) Boolean
Returns true if the provided declaration is a template parameter pack.
isTemplated (Decl) Boolean
Returns true if the provided declaration is a template, template pattern, or is within a dependent context.
isUsed (Decl) Boolean
Returns true if the provided declaration, or any of its redeclarations, was used in a manner that requires a definition.
getDecl (DeclRefExpr) ValueDecl
Returns the declaration to which the provided declaration reference expression refers.
getFoundDecl (DeclRefExpr) NamedDecl
Returns the named declaration through which the provided declaration reference expression occurs which may be different than the value returned by getDecl such as in the presence of using declarations.
hasExplicitTemplateArgs (DeclRefExpr) Boolean
Returns true if the provided declaration reference expression was followed by an explicit template argument list.
hasTemplateKeyword (DeclRefExpr) Boolean
Returns true if the provided declaration reference expression was preceded by the template keyword.
isCapturedByCopyInLambdaWithExplicitObjectParameter (DeclRefExpr) Boolean
Returns true if the provided declaration reference expression was captured by copy in a lambda that has a dependent template type explicit object parameter, introduced in C++ 23.
isImmediateEscalating (DeclRefExpr) Boolean
Returns true if the provided declaration reference expression is immediate-escalating, a category introduced in C++ 23.
getBody (DoStmt) Stmt
Returns the body of the provided ’do’ statement.
getCond (DoStmt) Expr
Returns the condition expression of the provided ’do’ statement.
getInitExpr (EnumConstantDecl) Expr
Returns the expression used to specify the value of the provided enumeration constant or None.
getInitVal (EnumConstantDecl) Integral
Returns the value of the provided enumeration constant.
getEnumerator (EnumDecl Integral) EnumConstantDecl
Returns the specified enumerator of the provided enumeration.
getIntegerType (EnumDecl) ASTType
Returns the underlying integer type of the provided enumeration.
getNumEnumerators (EnumDecl) Integral
Returns the number of enumerators defined for the provided enumeration.
getNumNegativeBits (EnumDecl) Integral
Returns the number of bits needed to represent the smallest negative enumerator for the provided enumeration.
getNumPositiveBits (EnumDecl) Integral
Returns the number of bits needed to represent the largest non-negative enumerator for the provided enumeration.
getPromotionType (EnumDecl) ASTType
Returns the type that enumerators of the provided enumeration will be promoted to.
isComplete (EnumDecl) Boolean
Returns true if the provided enumeration is considered to be a complete type.
isFixed (EnumDecl) Boolean
Returns true if the provided enumeration was declared with a fixed underlying type using the C++ 11 or a compiler-specific mechanism.
isScoped (EnumDecl) Boolean
Returns true if the provided enumeration is a C++ 11 scoped enumeration.
isScopedUsingClassTag (EnumDecl) Boolean
Returns true if the provided enumeration is a scoped enumeration defined using the ’class’ keyword.
containsUnexpandedParameterPack (Expr) Boolean
Returns true if the provided expression contains an unexpanded parameter pack.
evaluateAsBooleanCondition (Expr) Boolean
If the provided expression is a constant expression which can be manipulated to a Boolean condition, returns the value of that manipulation, otherwise returns None.
evaluateAsFloat (Expr) Floating
If the provided expression is a constant expression that can be manipulated to a floating point value, returns the value of that manipulation, otherwise returns None.
evaluateAsInt (Expr) Integral
If the provided expression is a constant expression that can be manipulated to an integer, returns the value of that manipulation, otherwise returns None.
getExprLoc (Expr) Location
Returns the preferred diagnostic location of the provided expression, typically the location of the operator itself as opposed to an operand.
getIntegerConstantExpr (Expr) Integral
If the provided expression is an integer constant expression, returns the value of the expression, otherwise returns None.
getSourceBitField (Expr) FieldDecl
If the provided expression refers to a bit-field, returns the declaration of that bit-field, otherwise returns None.
getType (Expr) ASTType
Returns the type of the provided expression.
hasNonTrivialCall (Expr) Boolean
Returns true if the provided expression involves a call to a non-trivial function.
ignoreCasts (Expr) Expr
Returns the expression resulting from skipping over any explicit casts starting at the provided expression.
ignoreImpCasts (Expr) Expr
Returns the expression resulting from skipping over any implicit casts starting at the provided expression.
ignoreImplicit (Expr) Expr
Returns the expression resulting from skipping over the same nodes that ignoreImpCasts does as well as any MaterializeTemporaryExpr and CXXBindTemporaryExpr nodes at the provided expression.
ignoreImplicitAsWritten (Expr) Expr
Returns the expression resulting from skipping over the same nodes that ignoreImplicit does as well as any implicit calls to constructors and conversion functions at the provided expression.
ignoreParenBaseCasts (Expr) Expr
Returns the expression resulting from skipping over any parentheses and derived-to-base casts starting at the provided expression.
ignoreParenCasts (Expr) Expr
Returns the expression resulting from skipping over any parentheses and/or implicit/explicit casts starting at the provided expression.
ignoreParenImpCasts (Expr) Expr
Returns the expression resulting from skipping over any parentheses and/or implicit casts starting at the provided expression.
ignoreParens (Expr) Expr
Returns the expression resulting from skipping over any parentheses starting at the provided expression.
isBoundMemberFunction (Expr) Boolean
Returns true if the provided expression is a bound member function.
isCXX11ConstantExpr (Expr) Boolean
Returns true if the provided expression is a constant expression in C++ 11.
isCXX98IntegralConstantExpr (Expr) Boolean
Returns true if the provided expression is an integer constant expression in C++ 98.
isConstantExpr (Expr) Boolean
Returns true if the provided expression is a constant expression.
isDefaultArgument (Expr) Boolean
Returns true if the provided expression is a default function argument.
isGLValue (Expr) Boolean
Returns true if the provided expression is a gl-value according to the current language mode.
isImplicitCXXThis (Expr) Boolean
Returns true if the provided expression is an implicit reference to the C++ this pointer.
isIntegerConstantExpr (Expr) Boolean
Returns true the provided expression is an integer constant expression.
isKnownToHaveBooleanValue (Expr) Boolean
Returns true if the provided expression is an integer constant expression known to have a value of 0 or 1.
isLValue (Expr) Boolean
Returns true if the provided expression is a l-value according to the current language mode.
isNullPointerConstant (Expr) Boolean
Returns true if the provided expression reduces to a null pointer constant.
isRValue (Expr) Boolean
Returns true if the provided expression is a r-value in C mode or pr-value in C++ mode.
isTypeDependent (Expr) Boolean
Returns true if the type of the provided expression depends on a template parameter.
isValueDependent (Expr) Boolean
Returns true if the value of the provided expression depends on a template parameter.
isXValue (Expr) Boolean
Returns true if the provided expression is a xl-value according to the current language mode.
refersToBitField (Expr) Boolean
Returns true if the provided expression is a gl-value that potentially refers to a bit-field.
getBitWidthValue (FieldDecl) Integral
If the provided field is a bit-field, returns the bit width of the bit-field, otherwise returns None.
getInClassInitStyle (FieldDecl) String
Returns a string (one of "None", "Copy", or "List") representing the initialization style used to initialize the provided field.
getInClassInitializer (FieldDecl) Expr
If the provided field has an in-class initializer, returns the expression used in that initializer, otherwise returns None.
getParent (FieldDecl) RecordDecl
Returns the parent class of the provided field.
hasInClassInitializer (FieldDecl) Boolean
Returns true if the provided field has an in-class initializer.
isAnonymousStructOrUnion (FieldDecl) Boolean
Returns true if the provided field is an anonymous struct or union.
isBitField (FieldDecl) Boolean
Returns true if the provided field is a bit-field.
isMutable (FieldDecl) Boolean
Returns true if the provided field was defined with the ’mutable’ keyword.
isUnnamedBitfield (FieldDecl) Boolean
Returns true if the provided field is an unnamed bit-field.
isZeroLengthBitField (FieldDecl) Boolean
Returns true if the provided field is a zero-width bit-field.
isZeroSize (FieldDecl) Boolean
Returns true if the provided field is a zero-width bit-field or is of empty class type.
getValue (FloatingLiteral) Floating
Returns the value of the provided floating point literal.
isExact (FloatingLiteral) Boolean
Returns true if the provided floating point literal can be exactly represented in its corresponding type.
getBody (ForStmt) Stmt
Returns the statement that forms the body of the provided for statement.
getCond (ForStmt) Expr
Returns the statement that comprises the second/condition clause of the provided for statement if any, otherwise returns None.
getConditionVariable (ForStmt) VarDecl
Returns the condition variable declared in the second clause of the provided for statement if any, otherwise returns None.
getConditionVariableDeclStmt (ForStmt) DeclStmt
Returns the declaration statement of the condition variable declared in the second clause of the provided for statement if any, otherwise returns None.
getInc (ForStmt) Expr
Returns the statement that comprises the third/increment clause of the provided for statement if any, otherwise returns None.
getInit (ForStmt) Stmt
Returns the statement that comprises the first/initialization clause of the provided for statement if any, otherwise returns None.
getFriendDecl (FriendDecl) NamedDecl
If the provided friend declaration does not name a type, returns the inner declaration, otherwise None is returned.
getFriendType (FriendDecl) ASTType
If the provided friend declaration names a type, that type is returned, otherwise None is returned.
getFriendDecl (FriendTemplateDecl) NamedDecl
If the provided friend declaration names a templated function, that function is returned, otherwise None is returned.
getFriendType (FriendTemplateDecl) ASTType
If the provided friend declaration names a templated type, that type is returned, otherwise None is returned.
doesThisDeclarationHaveABody (FunctionDecl) Boolean
Returns true if the provided function declaration has a body.
getBody (FunctionDecl) Stmt
Returns the body associated with the provided function or None if there is no body.
getCallResultType (FunctionDecl) ASTType
Returns the type of an expression that calls the provided function.
getDeclaredReturnType (FunctionDecl) ASTType
Returns the type that the provided function is declared as returining.
getDefinition (FunctionDecl) FunctionDecl
Returns the declaration of the provided function that contains a body if any, otherwise returns None.
getDescribedFunctionTemplate (FunctionDecl) FunctionTemplateDecl
Returns the function template that is described by the provided function or None.
getInstantiatedFromMemberFunction (FunctionDecl) FunctionDecl
If the provided function is an instantiation of a member function of a class template specialization, returns the function from which it was instantiated, otherwise returns None.
getMinRequiredArguments (FunctionDecl) Integral
Returns the minimum number of arguments needed to invoke the provided function.
getNumParams (FunctionDecl) Integral
Returns the number of parameters that the provided function was declared as receiving.
getParamDecl (FunctionDecl Integral) ParmVarDecl
Returns the specified parameter declaration of the provided function.
getPointOfInstantiation (FunctionDecl) Location
Returns the location in which the provided function was instantiated or None if it is not an instantiation.
getPrimaryTemplate (FunctionDecl) FunctionTemplateDecl
Returns the function template that the provided function specializes or was instantiated from if any, otherwise returns None.
getReturnType (FunctionDecl) ASTType
Returns the type that the provided function returns.
getStorageClass (FunctionDecl) String
Returns a string (one of "None", "Extern", "Static", "PrivateExtern", "Auto", or "Register") representing the storage class of the provided function.
getTemplateInstantiationPattern (FunctionDecl) FunctionDecl
If the provided function is an instantiation, returns the function from which it could have been instantiated, otherwise returns None.
hasCXXExplicitFunctionObjectParameter (FunctionDecl) Boolean
Returns true if the provided function has an explicit object parameter, introduced in C++ 23.
hasImplicitReturnZero (FunctionDecl) Boolean
Returns true falling off the end of the provided function implicitly returns zero.
hasInheritedPrototype (FunctionDecl) Boolean
Returns true if the provided function has a prototype inherited from a previous declaration.
hasOneParamOrDefaultArgs (FunctionDecl) Boolean
Returns true if the provided function may be invoked with a single argument.
hasPrototype (FunctionDecl) Boolean
Returns true if the provided function has either a written prototype or a prototype obtained from merging the function declaration with one that does.
hasSkippedBody (FunctionDecl) Boolean
Returns true if the body of the provided function was skipped such as with the -skip_function option.
hasTrivialBody (FunctionDecl) Boolean
Returns true if the body associated with the provided function is trivial.
hasWrittenPrototype (FunctionDecl) Boolean
Returns true if the provided function has a written prototype.
isConsteval (FunctionDecl) Boolean
Returns true if the provided function is a consteval function.
isConstexpr (FunctionDecl) Boolean
Returns true if the provided function is constexpr.
isConstexprSpecified (FunctionDecl) Boolean
Returns true if the provided function was specified as constexpr.
isDefaulted (FunctionDecl) Boolean
Returns true if the provided function is defaulted.
isDefined (FunctionDecl) Boolean
Returns true if there is a definition associated with the provided function.
isDeleted (FunctionDecl) Boolean
Returns true if the provided function is deleted.
isDeletedAsWritten (FunctionDecl) Boolean
Returns true if the provided function was marked as deleted in the source code.
isDestroyingOperatorDelete (FunctionDecl) Boolean
Returns true if the provided function is a destroying operator delete.
isExplicitlyDefaulted (FunctionDecl) Boolean
Returns true if the provided function is explicitly defaulted.
isExternC (FunctionDecl) Boolean
Returns true if the provided function has external C linkage.
isFunctionTemplateSpecialization (FunctionDecl) Boolean
Returns true if the provided function is a function template specialization.
isGlobal (FunctionDecl) Boolean
Returns true if the provided function is a global function.
isImmediateEscalating (FunctionDecl) Boolean
Returns true if the provided function is an immediate-escalating function, introduced in C++ 23.
isImmediateFunction (FunctionDecl) Boolean
Returns true if the provided function is an immediate function, introduced in C++ 20.
isImplicitlyInstantiable (FunctionDecl) Boolean
Returns true if the provided function is a function template specialization or a member of a class template specialization that can be implicitly instantiated.
isInExternCContext (FunctionDecl) Boolean
Returns true if the provided function is subject to a C++ extern "C" linkage specifier.
isInExternCXXContext (FunctionDecl) Boolean
Returns true if the provided function is subject to a C++ extern "C++ " linkage specifier.
isInlineSpecified (FunctionDecl) Boolean
Returns true if the provided function was declared using the inline keyword.
isInlined (FunctionDecl) Boolean
Returns true if the provided function is an inline function, e.g. it was declared using inline, constexpr, or is a member function defined in the body of its class.
isLateTemplateParsed (FunctionDecl) Boolean
Returns true if the provided function is a templated function that will be late parsed.
isMain (FunctionDecl) Boolean
Returns true if the provided function is the main function.
isNoReturn (FunctionDecl) Boolean
Returns true if the provided function was declared as not returning.
isOverloadedOperator (FunctionDecl) Boolean
Returns true if the provided function is an overloaded operator.
isPure (FunctionDecl) Boolean
Returns true if the provided function is a pure virtual function.
isReplaceableGlobalAllocationFunction (FunctionDecl) Boolean
Returns true if the provided function is one of the replaceable global allocation functions.
isReservedGlobalPlacementOperator (FunctionDecl) Boolean
Returns true if the provided function is one of the reserved global placement operators.
isStatic (FunctionDecl) Boolean
Returns true if the provided function is a static function.
isTemplateInstantiation (FunctionDecl) Boolean
Returns true if the provided function was instantiated from a function template.
isThisDeclarationADefinition (FunctionDecl) Boolean
Returns true if the provided function declaration is a definition.
isThisDeclarationInstantiatedFromAFriendDefinition (FunctionDecl) Boolean
Returns true if the provided function declaration is instantiated from a friend definition.
isTrivial (FunctionDecl) Boolean
Returns true if the provided function is a trivial special member function.
isUserProvided (FunctionDecl) Boolean
Returns true if the provided function is used-declared and not deleted or defaulted in its first declaration.
isVariadic (FunctionDecl) Boolean
Returns true if the provided function is variadic.
isVirtualAsWritten (FunctionDecl) Boolean
Returns true if the provided function was explicitly declared virtual.
getLabel (GotoStmt) LabelDecl
Returns the label statement corresponding to the provided ’goto’ statement.
getCond (IfStmt) Expr
Returns the condition expression of the provided if statement.
getConditionVariable (IfStmt) VarDecl
Returns the condition variable declared in the provided if statement if any, otherwise returns None.
getConditionVariableDeclStmt (IfStmt) DeclStmt
If the provided ifstatement declares a condition variable, returns the declaration statement associated with the condition variable, otherwise returns None.
getElse (IfStmt) Stmt
Returns the statement forming the else clause of the provided if statement or None if there is no else clause.
getInit (IfStmt) Stmt
If the provided if statement contains an initialization clause, returns the statement that serves as that clause, otherwise returns None.
getNondiscardedCase (IfStmt) Stmt
If the provided if statement is an if constexpr statement, returns the substatement that will be evaluated, otherwise returns None.
getThen (IfStmt) Stmt
Returns the statement forming the then clause of the provided if statement.
isConsteval (IfStmt) Boolean
Returns true if the provided if statement is either a negated or non-negated consteval if statement, introduced in C++ 23.
isConstexpr (IfStmt) Boolean
Returns true if the provided if statement is an if constexpr statement.
isNegatedConsteval (IfStmt) Boolean
Returns true if the provided if statement is an if !consteval statement, introduced in C++ 23.
isNonNegatedConsteval (IfStmt) Boolean
Returns true if the provided if statement is an if consteval statement, introduced in C++ 23.
getValue (IntegerLiteral) Integral
Returns the value of the provided integer literal.
getStmt (LabelDecl) LabelStmt
Returns the substatement of the provided label.
isGnuLocal (LabelDecl) Boolean
Returns true if the provided label is a GNU local label.
getDecl (LabelStmt) LabelDecl
Returns the declaration of the label referenced by the provided label statement.
getName (LabelStmt) String
Returns the name of the label referenced by the provided label statement.
getSubStmt (LabelStmt) Stmt
Returns the substatement of the provided label statement.
isSideEntry (LabelStmt) Boolean
Returns true if the label is jumped to in a way that skips the initialization of an automatic variable that would normally make the program ill-formed. This side entry label is allowed when microsoft semantics (+fms) is enabled.
getCallOperator (LambdaExpr) CXXMethodDecl
Returns the function call operator associated with the provided lambda.
getDependentCallOperator (LambdaExpr) FunctionTemplateDecl
Returns the function template call operator associated with the provided lambda if any, otherwise returns None.
getLambdaClass (LambdaExpr) CXXRecordDecl
Returns the class that corresponds to the provided lambda.
hasDefaultCapture (LambdaExpr) Boolean
Returns true if the provided lambda has a capture-default.
hasDefaultCaptureByCopy (LambdaExpr) Boolean
Returns true if the provided lambda has a capture-default of capture-by-copy.
hasDefaultCaptureByReference (LambdaExpr) Boolean
Returns true if the provided lambda has a capture-default of capture-by-reference.
hasExplicitParameters (LambdaExpr) Boolean
Returns true if the provided lambda is declared with an explicit parameter list.
hasExplicitResultType (LambdaExpr) Boolean
Returns true if the result type was explicitly specified for the provided lambda.
isGenericLambda (LambdaExpr) Boolean
Returns true if the provided lambda is a generic lambda.
isMutable (LambdaExpr) Boolean
Returns true if the provided lambda captures any values that may be modified in the lambda.
hasBraces (LinkageSpecDecl) Boolean
Returns true if the provided linkage declaration was defined with braces.
isCLanguageLinkage (LinkageSpecDecl) Boolean
Returns true if the provided linkage declaration is a C-language linkage declaration.
isCXXLanguageLinkage (LinkageSpecDecl) Boolean
Returns true if the provided linkage declaration is a C++ -language linkage declaration.
getBufferName (Location) String
Returns the buffer name of the provided Location.
getExpansionColumnNumber (Location) Integral
Returns the expansion column number of the provided Location.
getExpansionLineNumber (Location) Integral
Returns the expansion line number of the provided Location.
getPresumedColumnNumber (Location) Integral
Returns the presumed column number of the provided Location.
getPresumedLineNumber (Location) Integral
Returns the presumed line number of the provided Location.
getSpellingColumnNumber (Location) Integral
Returns the spelling column number of the provided Location.
getSpellingLineNumber (Location) Integral
Returns the spelling line number of the provided Location.
isLibraryRegion (Location) Boolean
Returns true if the provided location is in a library region.
isMacroLocation (Location) Boolean
Returns true if the provided location is the result of macro expansion.
isMainFile (Location) Boolean
Returns true if the provided location resides in the main source file of the current translation unit.
getBase (MemberExpr) Expr
Returns the expression forming the base (LHS operand) of the provided member expression.
getMemberDecl (MemberExpr) ValueDecl
Returns the member declaration corresponding to the provided member expression.
hadMultipleCandidates (MemberExpr) Boolean
Returns true if the provided member expression refers to a function that was resolved from an overloaded set having multiple candidates.
hasQualifier (MemberExpr) Boolean
Returns true if the provided member expression used a C++ nested-name specifier to refer to the member, e.g. x->Base::foo.
hasTemplateKeyword (MemberExpr) Boolean
Returns true if the member name in the provided member expression was preceded by the template keyword.
isArrow (MemberExpr) Boolean
Returns true if the provided member expression used the arrow syntax, e.g. x->foo as opposed to x.foo.
performsVirtualDispatch (MemberExpr) Boolean
Returns true if virtual dispatch is performed for the provided member expression.
getNameAsString (NamedDecl) String
Returns a string containing the name of the provided named declaration or "(unnamed)" if the provided declaration does not have a name.
getQualifiedNameAsString (NamedDecl) String
Returns a string containing the fully qualified name of the provided named declaration.
getUnderlyingDecl (NamedDecl) NamedDecl
Returns the underlying declaration of the provided named declaration looking through any using declarations.
hasExternalFormalLinkage (NamedDecl) Boolean
Returns true if the provided named declaration has external linkage.
hasLinkage (NamedDecl) Boolean
Returns true if the provided named declaration has linkage.
hasName (NamedDecl) Boolean
Returns true if the provided named declaration has a name.
isCXXClassMember (NamedDecl) Boolean
Returns true if the provided named declaration is a C++ class member.
isCXXInstanceMember (NamedDecl) Boolean
Returns true if the provided named declaration is a C++ class instance member.
isExternallyDeclarable (NamedDecl) Boolean
Returns true if the provided named declaration can be redeclared in a different translation unit.
isExternallyVisible (NamedDecl) Boolean
Returns true if the provided named declaration is externally visible.
getCanonicalDecl (NamespaceAliasDecl) NamespaceAliasDecl
Returns the canonical declaration of the provided namespace alias declaration.
getNamespace (NamespaceAliasDecl) NamespaceDecl
Returns the namespace declaration corresponding to the provided namespace alias declaration.
getAnonymousNamespace (NamespaceDecl) NamespaceDecl
Returns the anonymous namespace nested within the provided namespace if any, otherwise returns None.
getOriginalNamespace (NamespaceDecl) NamespaceDecl
Returns the first declaration of the provided namespace.
isAnonymousNamespace (NamespaceDecl) Boolean
Returns true if the provided namespace is an anonymous namespace.
isInline (NamespaceDecl) Boolean
Returns true if the provided namespace is an inline namespace.
isNested (NamespaceDecl) Boolean
Returns true if the provided namespace is a nested namespace, introduced in C++ 17.
isOriginalNamespace (NamespaceDecl) Boolean
Returns true if the provided namespace is the first declaration of the namespace.
hasLeadingEmptyMacro (NullStmt) Boolean
Returns true if the provided null statement follows a macro that expanded to nothing.
getSubExpr (ParenExpr) Expr
Returns the enclosed expression of the provided parenthesized expression.
getDefaultArg (ParmVarDecl) Expr
If the provided parameter was declared with a default argument, returns the expression comprising that argument, otherwise returns None.
getFunctionScopeIndex (ParmVarDecl) Integral
Returns the index of the provided parameter within it prototype.
getOriginalType (ParmVarDecl) ASTType
Returns the original type of the provided parameter before e.g. array to pointer decay.
hasDefaultArg (ParmVarDecl) Boolean
Returns true if the provided parameter was declared with a default argument.
hasInheritedDefaultArg (ParmVarDecl) Boolean
Returns true if the provided parameter inherits a default argument from an overridden function.
isExplicitObjectParameter (ParmVarDecl) Boolean
Returns true if the provided parameter is an explicit object parameter, introduced in C++ 23.
isKNRPromoted (ParmVarDecl) Boolean
Returns true if the provided parameter must undergo K&R-style default argument promotion.
findFirstNamedDataMember (RecordDecl) FieldDecl
Returns the first named data member of the provided record if any, otherwise returns None.
getField (RecordDecl Integral) FieldDecl
Returns the specified field of the provided record.
hasFlexibleArrayMember (RecordDecl) Boolean
Returns true if the provided record contains a flexible array member.
hasVolatileMember (RecordDecl) Boolean
Returns true if the provided record has a volatile member.
isAnonymousStructOrUnion (RecordDecl) Boolean
Returns true if the provided record is an anonymous struct or union.
isInjectedClassName (RecordDecl) Boolean
Returns true if the provided record represents an injected class name.
isLambda (RecordDecl) Boolean
Returns true if the provided record is a class describing a lambda function object.
isOrContainsUnion (RecordDecl) Boolean
Returns true if the provided record is a union or (recursively) contains a union.
numFields (RecordDecl) Integral
Returns the number of fields in the provided record.
getNRVOCandidate (ReturnStmt) VarDecl
Returns the variable that might be used for named return value optimization.
getRetValue (ReturnStmt) Expr
Returns the return value expression of the provided ’return’ statement.
getAssertExpr (StaticAssertDecl) Expr
Returns the expression used in the provided static assertion.
getMessage (StaticAssertDecl) StringLiteral
If the provided static assertion contained a message argument, that argument is returned, otherwise None is returned.
isFailed (StaticAssertDecl) Boolean
Returns true if the provided static assertion failed.
dump (Stmt) String
Returns a string containing the AST tree of the provided statement.
getBeginLoc (Stmt) Location
Returns the Location corresponding with the beginning of the provided statement.
getEndLoc (Stmt) Location
Returns the Location corresponding with the end of the provided statement.
getStmtClassName (Stmt) String
Returns a string representing the kind of the provided statement.
endsWith (String String) Boolean
Returns true if the first argument ends with the second argument.
length (String) Integral
Returns the length of the string provided as the first argument.
lowerCase (String) String
Returns a copy of the provided string with all characters converted to lowercase.
makeAbsolutePath (String) String
Returns the absolute path of the provided path.
startsWith (String String) Boolean
Returns true if the first argument starts with the second argument.
strftime (String) String
Returns a string representing the current date and time according to the provided format string as per the Standard C++ 11 strftime function.
upperCase (String) String
Returns a copy of the provided string with all characters converted to uppercase.
containsNonAscii (StringLiteral) Boolean
Returns true if the provided string literal contains non-ascii characters.
getValue (StringLiteral) String
Returns the string value of the provided string literal.
isOrdinary (StringLiteral) Boolean
Returns true if the provided string literal is an ordinary string.
isUTF16 (StringLiteral) Boolean
Returns true if the provided string literal a UTF16 string.
isUTF32 (StringLiteral) Boolean
Returns true if the provided string literal a UTF32 strings.
isUTF8 (StringLiteral) Boolean
Returns true if the provided string literal is a UTF8 string.
isUnevaluated (StringLiteral) Boolean
Returns true if the provided string literal is unevaluated.
isWide (StringLiteral) Boolean
Returns true if the provided string literal is a wide string.
getNextSwitchCase (SwitchCase) SwitchCase
Returns the next switch case which is typically the one written prior to the provided one in the source code.
getSubStmt (SwitchCase) Stmt
Returns the substatement of the provided switch case.
getBody (SwitchStmt) Stmt
Returns the statement comprising the body of the provided switch statement.
getCond (SwitchStmt) Expr
Returns the condition expression of the provided switch statement.
getConditionVariable (SwitchStmt) VarDecl
Returns the condition variable declared in the switch statement if any, otherwise returns None.
getConditionVariableDeclStmt (SwitchStmt) DeclStmt
If the provided while statement declares a condition variable, returns the declaration statement associated with the condition variable, otherwise returns None.
getFirstSwitchCase (SwitchStmt) SwitchCase
Returns the switch case at the beginning of the list of switch cases for the provided switch statement which is typicall the last switch case written in the source code for the switch.
getInit (SwitchStmt) Stmt
If the provided switch statement contains an initialization clause, returns the statement that serves as that clause, otherwise returns None.
isAllEnumCasesCovered (SwitchStmt) Boolean
Returns true if the switch condition has enumeration type and every value associated with the corresponding declared enumerators are covered by cases in the switch.
getCanonicalDecl (TagDecl) TagDecl
Returns the canonical declaration of the provided tag declaration.
getDefinition (TagDecl) TagDecl
Returns the tag declaration that defines the provided tag if any, otherwise returns None.
getInnerLocStart (TagDecl) Location
Returns the location of the provided tag declaration ignoring enclosing template declarations.
getOuterLocStart (TagDecl) Location
Returns the location of the provided tag declaration considering enclosing template declarations.
getTypedefNameForAnonDecl (TagDecl) TypedefNameDecl
Returns the typedef declared with the provided anonymous tag declaration if any, otherwise returns None.
isClass (TagDecl) Boolean
Returns true if the provided tag declares a class.
isCompleteDefinition (TagDecl) Boolean
Returns true if the provided tag has a complete definition.
isCompleteDefinitionRequired (TagDecl) Boolean
Returns true if a complete definition of the provided tag is needed in the current translation unit.
isDependentType (TagDecl) Boolean
Returns true if the provided tag declares a type that depends on template parameters.
isEmbeddedInDeclarator (TagDecl) Boolean
Returns true if the provided tag is embedded in a declarator.
isEnum (TagDecl) Boolean
Returns true if the provided tag declares an enumeration.
isFreeStanding (TagDecl) Boolean
Returns true if the provided tag is freestanding.
isInterface (TagDecl) Boolean
Returns true if the provided tag declares an interface.
isStruct (TagDecl) Boolean
Returns true if the provided tag is declares a struct.
isThisDeclarationADefinition (TagDecl) Boolean
Returns true if the provided tag declaration is a definition.
isThisDeclarationADemotedDefinition (TagDecl) Boolean
Returns true if the provided tag declaration was defined in a C++ 20 module, but was demoted to a declaration.
isUnion (TagDecl) Boolean
Returns true if the provided tag declares a union.
getTypeForDecl (TypeDecl) ASTType
Returns the type of the provided type declaration.
getAnonDeclWithTypedefName (TypedefNameDecl) TagDecl
Returns the anonymous tag declaration associated with the provided typedef name declaration if any, otherwise returns None.
getUnderlyingType (TypedefNameDecl) ASTType
Returns the underlying type of the provided typedef name declaration.
getOpcodeStr (UnaryOperator) String
Returns the string representation of the provided unary operator.
isArithmeticOp (UnaryOperator) Boolean
Returns true if the provided unary operator is an arithmetic operator.
isDecrementOp (UnaryOperator) Boolean
Returns true if the provided unary operator is the prefix or postfix decrement operator.
isIncrementOp (UnaryOperator) Boolean
Returns true if the provided unary operator is the prefix or postfix increment operator.
isPostfix (UnaryOperator) Boolean
Returns true if the provided unary operator is the postfix increment operator or the postfix decrement operator.
isPrefix (UnaryOperator) Boolean
Returns true if the provided unary operator is the prefix increment operator or the prefix decrement operator.
hasTypename (UsingDecl) Boolean
Returns true if the provided using declaration uses the typename keyword.
isAccessDeclaration (UsingDecl) Boolean
Returns true if the provided using declaration is a C++ 03 access declaration.
getNominatedNamespace (UsingDirectiveDecl) NamespaceDecl
Returns the namespace nominated by the provided using directive declaration.
getType (ValueDecl) ASTType
Returns the type of the provided value declaration.
getExprStmt (ValueStmt) Expr
Returns the expression statement of the provided value statement.
getAnyInitializer (VarDecl) Expr
Returns the initialized attached to any declaration of the provided variable.
getDescribedVarTemplate (VarDecl) VarTemplateDecl
Returns the variable template that is described by the provided variable or None.
getInit (VarDecl) Expr
Returns the initializer attached to the provided variable declaration if any, otherwise returns None.
getInstantiatedFromStaticDataMember (VarDecl) VarDecl
If the provided variable is a static data member of a class template specialization, returns the templated static data member from which it was instantiated, otherwise returns None.
getTemplateInstantiationPattern (VarDecl) VarDecl
If the provided variable is an instantiation, returns the variable from which it could have been instantiated, otherwise returns None.
hasDependentAlignment (VarDecl) Boolean
Returns true if the provided variable’s alignment is dependent on a template argument.
hasExternalStorage (VarDecl) Boolean
Returns true if the provided variable has extern storage.
hasGlobalStorage (VarDecl) Boolean
Returns true if the provided variables does not have local storage.
hasICEInitializer (VarDecl) Boolean
Returns true if the provided variable is initialized with an integer constant expression.
hasInit (VarDecl) Boolean
Returns true the provided variable declaration has an initializer.
hasLocalStorage (VarDecl) Boolean
Returns true if the provided variable is a non-static local variable with function scope.
isCXXForRangeDecl (VarDecl) Boolean
Returns true if the provided variable is a for-range declaration in a for-range statement.
isConstexpr (VarDecl) Boolean
Returns true if the provided variable is constexpr.
isDirectInit (VarDecl) Boolean
Returns true if the provided variable is initialized with a direct-initializer (list or call style initialization).
isExceptionVariable (VarDecl) Boolean
Returns true if the provided variable is the exception variable of a catch statement.
isExternC (VarDecl) Boolean
Returns true if the provided variable has external C linkage.
isFileVarDecl (VarDecl) Boolean
Returns true if the provided variable has file scope.
isFunctionOrMethodVarDecl (VarDecl) Boolean
Returns true if the provided variable is a local, non-parameter variable not declared inside of block.
isInExternCContext (VarDecl) Boolean
Returns true if the provided variable is subject to a C++ extern "C" linkage specifier.
isInExternCXXContext (VarDecl) Boolean
Returns true if the provided variable is subject to a C++ extern "C++ " linkage specifier.
isInitCapture (VarDecl) Boolean
Returns true if the provided variable is the implicit variable for a lambda init-capture.
isInline (VarDecl) Boolean
Returns true if the provided variable is a C++ 20 inline variable.
isInlineSpecified (VarDecl) Boolean
Returns true if the inline keyword was specified for the provided variable.
isLocalVarDecl (VarDecl) Boolean
Returns true if the provided variable is a local, non-parameter variable.
isLocalVarDeclOrParm (VarDecl) Boolean
Returns true if the provided variable is a local or function-parameter variable.
isNRVOVariable (VarDecl) Boolean
Returns true if the provided variable is a local variable that may be used for named return value optimization.
isParameterPack (VarDecl) Boolean
Returns true if the provided variable is a function parameter pack or init-capture pack.
isStaticDataMember (VarDecl) Boolean
Returns true if the provided variable is a static data member of a class.
isStaticLocal (VarDecl) Boolean
Returns true if the provided variable is a static local variable with function scope.
isUsableInConstantExpressions (VarDecl) Boolean
Returns true if the provided variable may be use in constant expressions.
getBody (WhileStmt) Stmt
Returns the statement comprising the body of the provided while statement.
getCond (WhileStmt) Expr
Returns the condition expression of the provided while statement.
getConditionVariable (WhileStmt) VarDecl
Returns the condition variable declared in the while statement if any, otherwise returns None.
getConditionVariableDeclStmt (WhileStmt) DeclStmt
If the provided while statement declares a condition variable, returns the declaration statement associated with the condition variable, otherwise returns None.