CodeQL library for C/C++
Search

Module PrintAST

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

By default, this will print the AST for all functions in the database. To change this behavior, extend PrintASTConfiguration and override shouldPrintFunction to hold for only the functions 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.

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 functions 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.