CodeQL library for C/C++
codeql/cpp-all 2.1.2-dev (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.

C11GenericNode

A node representing a C11GenericExpr.

CastNode

A node representing a Cast.

ChildStmtNode

A node representing a child of a Stmt that is itself a Stmt.

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.

FunctionParametersNode

A node representing the parameters of a Function.

GlobalOrNamespaceVariableNode

A node representing a GlobalOrNamespaceVariable.

HandlerNode

A node representing a Handler.

InitializerNode

A node representing an Initializer.

ParameterNode

A node representing a Parameter.

PrintAstConfiguration

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

PrintAstNode

A node in the output tree.

RequiresExprNode

A node representing a RequiresExpr

RequiresExprParametersNode

A node representing the parameters of a RequiresExpr.

StmtExprNode

A node representing a StmtExpr.

StmtNode

A node representing a Stmt.

StringLiteralNode

A node representing a StringLiteral.

VariableDeclarationEntryNode

A node representing a VariableDeclarationEntry.