CodeQL library for C/C++
codeql/cpp-all 0.12.11 (changelog, source)
Search

Module PrintAST

Provides queries to pretty-print a C++ AST as a graph.

By default, this will print the AST for all functions and global and namespace variables in the database. To change this behavior, extend PrintASTConfiguration and override shouldPrintDeclaration to hold for only the declarations you wish to view the AST for.

Import path

import semmle.code.cpp.PrintAST

Imports

cpp

Provides classes and predicates for working with C/C++ code.

Predicates

edges

Holds if target is a child of source in the AST, and property key of the edge has the given value.

graphProperties

Holds if property key of the graph has the given value.

nodes

Holds if node belongs to the output tree, and its property key has the given value.

Classes

AstNode

A node representing an AST node other than a DeclarationEntry.

BaseAstNode

A node representing an AST node.

CastNode

A node representing a Cast.

ConstructorInitializersNode

A node representing the initializer list of a Constructor.

ConversionNode

A node representing a Conversion.

DeclStmtNode

A node representing a DeclStmt.

DeclarationEntryNode

A node representing a DeclarationEntry.

DestructorDestructionsNode

A node representing the destruction list of a Destructor.

ExprNode

A node representing an Expr.

FunctionNode

A node representing a Function.

GlobalOrNamespaceVariableNode

A node representing a GlobalOrNamespaceVariable.

InitializerNode

A node representing an Initializer.

ParameterNode

A node representing a Parameter.

ParametersNode

A node representing the parameters of a Function.

PrintAstConfiguration

The query can extend this class to control which declarations are printed.

PrintAstNode

A node in the output tree.

StmtExprNode

A node representing a StmtExpr.

StmtNode

A node representing a Stmt.

StringLiteralNode

A node representing a StringLiteral.

VariableDeclarationEntryNode

A node representing a VariableDeclarationEntry.