AstCreator

io.joern.c2cpg.astcreation.AstCreator
class AstCreator(val filename: String, val config: Config, val cdtAst: IASTTranslationUnit, val file2OffsetTable: ConcurrentHashMap[String, Array[Int]]) extends AstCreatorBase with AstForTypesCreator with AstForFunctionsCreator with AstForPrimitivesCreator with AstForStatementsCreator with AstForExpressionsCreator with AstNodeBuilder with AstCreatorHelper with MacroHandler

Translates the Eclipse CDT AST into a CPG AST.

Attributes

Graph
Supertypes
class AstCreatorBase
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

override def absolutePath(filename: String): String

Absolute path for the given file name

Absolute path for the given file name

Attributes

Definition Classes
AstCreatorBase
def createAst(): DiffGraphBuilder

Inherited methods

def asChildOfMacroCall(node: IASTNode, ast: Ast): Ast

For the given node, determine if it is expanded from a macro, and if so, create a Call node to represent the macro invocation and attach ast as its child.

For the given node, determine if it is expanded from a macro, and if so, create a Call node to represent the macro invocation and attach ast as its child.

Attributes

Inherited from:
MacroHandler
protected def astForASMDeclaration(asm: IASTASMDeclaration): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForAliasDeclaration(aliasDeclaration: ICPPASTAliasDeclaration): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForArrayModifier(arrMod: IASTArrayModifier): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForBlockStatement(blockStmt: IASTCompoundStatement, order: Int): Ast

Attributes

Inherited from:
AstForStatementsCreator
protected def astForComment(comment: IASTComment): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForDeclarator(declaration: IASTSimpleDeclaration, declarator: IASTDeclarator, index: Int): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForExpression(expression: IASTExpression): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astForFieldReference(fieldRef: IASTFieldReference): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForFunctionDeclarator(funcDecl: IASTFunctionDeclarator): Ast

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForFunctionDefinition(funcDef: IASTFunctionDefinition): Ast

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForIdentifier(ident: IASTNode): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForInitializer(declarator: IASTDeclarator, init: IASTInitializer): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForInitializerList(l: IASTInitializerList): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForLiteral(lit: IASTLiteralExpression): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForMethodRefForLambda(lambdaExpression: ICPPASTLambdaExpression): Ast

Attributes

Inherited from:
AstForFunctionsCreator
protected def astForNamespaceAlias(namespaceAlias: ICPPASTNamespaceAlias): Ast

Attributes

Inherited from:
AstForTypesCreator
protected def astForQualifiedName(qualId: CPPASTQualifiedName): Ast

Attributes

Inherited from:
AstForPrimitivesCreator
protected def astForStaticAssert(a: ICPPASTStaticAssertDeclaration): Ast

Attributes

Inherited from:
AstForExpressionsCreator
protected def astsForDeclaration(decl: IASTDeclaration): Seq[Ast]

Attributes

Inherited from:
AstForTypesCreator
protected def astsForStatement(statement: IASTStatement, argIndex: Int): Seq[Ast]

Attributes

Inherited from:
AstForStatementsCreator
def blockAst(blockNode: NewBlock, statements: List[Ast]): Ast

For a given block node and statement ASTs, create an AST that represents the block. The main purpose of this method is to increase the readability of the code which creates block asts.

For a given block node and statement ASTs, create an AST that represents the block. The main purpose of this method is to increase the readability of the code which creates block asts.

Attributes

Inherited from:
AstCreatorBase
def callAst(callNode: NewCall, arguments: Seq[Ast], base: Option[Ast], receiver: Option[Ast]): Ast

Create an abstract syntax tree for a call, including CPG-specific edges required for arguments and the receiver.

Create an abstract syntax tree for a call, including CPG-specific edges required for arguments and the receiver.

Our call representation is inspired by ECMAScript, that is, in addition to arguments, a call has a base and a receiver. For languages other than Javascript, leave receiver empty for now.

Attributes

arguments

arguments (without the base argument (instance))

base

the value to use as this in the method call.

callNode

the node that represents the entire call

receiver

the object in which the property lookup is performed

Inherited from:
AstCreatorBase
def controlStructureAst(controlStructureNode: NewControlStructure, condition: Option[Ast], children: Seq[Ast], placeConditionLast: Boolean): Ast

For a given node, condition AST and children ASTs, create an AST that represents the control structure. The main purpose of this method is to automatically assign the correct condition edges.

For a given node, condition AST and children ASTs, create an AST that represents the control structure. The main purpose of this method is to automatically assign the correct condition edges.

Attributes

Inherited from:
AstCreatorBase
def doWhileAst(condition: Option[Ast], body: Seq[Ast], code: Option[String], lineNumber: Option[Integer], columnNumber: Option[Integer]): Ast

Attributes

Inherited from:
AstCreatorBase
def forAst(forNode: NewControlStructure, locals: Seq[Ast], initAsts: Seq[Ast], conditionAsts: Seq[Ast], updateAsts: Seq[Ast], bodyAst: Ast): Ast

Attributes

Inherited from:
AstCreatorBase
def globalNamespaceBlock(): NewNamespaceBlock

Create a global namespace block for the given filename

Create a global namespace block for the given filename

Attributes

Inherited from:
AstCreatorBase
protected def handleUsingDeclaration(usingDecl: ICPPASTUsingDeclaration): Seq[Ast]

Attributes

Inherited from:
AstForTypesCreator
def methodAst(method: NewMethod, parameters: Seq[NewMethodParameterIn], body: Ast, methodReturn: NewMethodReturn, modifiers: Seq[NewModifier]): Ast

Creates an AST that represents an entire method, including its content.

Creates an AST that represents an entire method, including its content.

Attributes

Inherited from:
AstCreatorBase
def methodAstWithAnnotations(method: NewMethod, parameters: Seq[Ast], body: Ast, methodReturn: NewMethodReturn, modifiers: Seq[NewModifier], annotations: Seq[Ast]): Ast

Creates an AST that represents an entire method, including its content and with support for both method and parameter annotations.

Creates an AST that represents an entire method, including its content and with support for both method and parameter annotations.

Attributes

Inherited from:
AstCreatorBase
def methodStubAst(method: NewMethod, parameters: Seq[NewMethodParameterIn], methodReturn: NewMethodReturn, modifiers: Seq[NewModifier]): Ast

Creates an AST that represents a method stub, containing information about the method, its parameters, and the return type.

Creates an AST that represents a method stub, containing information about the method, its parameters, and the return type.

Attributes

Inherited from:
AstCreatorBase
protected def newBlockNode(node: IASTNode, typeFullName: String): NewBlock

Attributes

Inherited from:
AstNodeBuilder
protected def newCallNode(node: IASTNode, name: String, fullname: String, dispatchType: String, argIndex: Int): NewCall

Attributes

Inherited from:
AstNodeBuilder
protected def newCommentNode(node: IASTNode, code: String, filename: String): NewComment

Attributes

Inherited from:
AstNodeBuilder
protected def newControlStructureNode(node: IASTNode, controlStructureType: String, code: String): NewControlStructure

Attributes

Inherited from:
AstNodeBuilder
protected def newFieldIdentifierNode(node: IASTNode, name: String, code: String): NewFieldIdentifier

Attributes

Inherited from:
AstNodeBuilder
protected def newIdentifierNode(node: IASTNode, name: String, code: String, typeFullName: String): NewIdentifier

Attributes

Inherited from:
AstNodeBuilder
protected def newJumpTargetNode(node: IASTNode): NewJumpTarget

Attributes

Inherited from:
AstNodeBuilder
protected def newLiteralNode(node: IASTNode, code: String, typeFullName: String): NewLiteral

Attributes

Inherited from:
AstNodeBuilder
protected def newLocalNode(node: IASTNode, name: String, code: String, typeFullName: String): NewLocal

Attributes

Inherited from:
AstNodeBuilder
protected def newMemberNode(node: IASTNode, name: String, code: String, typeFullName: String): NewMember

Attributes

Inherited from:
AstNodeBuilder
protected def newMethodNode(node: IASTNode, name: String, code: String, fullName: String, fileName: String, astParentType: Option[String], astParentFullName: Option[String]): NewMethod

Attributes

Inherited from:
AstNodeBuilder
protected def newMethodRefNode(code: String, methodFullName: String, typeFullName: String, node: IASTNode): NewMethodRef

Attributes

Inherited from:
AstNodeBuilder
protected def newMethodReturnNode(node: IASTNode, typeFullName: String): NewMethodReturn

Attributes

Inherited from:
AstNodeBuilder
protected def newNamespaceBlockNode(node: IASTNode, name: String, fullname: String, code: String, filename: String): NewNamespaceBlock

Attributes

Inherited from:
AstNodeBuilder
protected def newParameterInNode(node: IASTNode, name: String, code: String, typeFullName: String, index: Int, evaluationStrategy: String, isVariadic: Boolean): NewMethodParameterIn

Attributes

Inherited from:
AstNodeBuilder
protected def newReturnNode(node: IASTNode, code: String): NewReturn

Attributes

Inherited from:
AstNodeBuilder
protected def newTypeDeclNode(node: IASTNode, name: String, fullName: String, filename: String, code: String, astParentType: String, astParentFullName: String, inherits: Seq[String], alias: Option[String]): NewTypeDecl

Attributes

Inherited from:
AstNodeBuilder
protected def newUnknownNode(node: IASTNode): NewUnknown

Attributes

Inherited from:
AstNodeBuilder
def nodeSignature(node: IASTNode): String

The CDT utility method is unfortunately in a class that is marked as deprecated, however, this is because the CDT team would like to discourage its use but at the same time does not plan to remove this code.

The CDT utility method is unfortunately in a class that is marked as deprecated, however, this is because the CDT team would like to discourage its use but at the same time does not plan to remove this code.

Attributes

Inherited from:
MacroHandler
def returnAst(returnNode: NewReturn, arguments: Seq[Ast]): Ast

For a given return node and arguments, create an AST that represents the return instruction. The main purpose of this method is to automatically assign the correct argument indices.

For a given return node and arguments, create an AST that represents the return instruction. The main purpose of this method is to automatically assign the correct argument indices.

Attributes

Inherited from:
AstCreatorBase
def setArgumentIndices(arguments: Seq[Ast]): Unit

Attributes

Inherited from:
AstCreatorBase
def staticInitMethodAst(initAsts: List[Ast], fullName: String, signature: Option[String], returnType: String): Ast

Attributes

Inherited from:
AstCreatorBase
protected def templateParameters(e: IASTNode): Option[String]

Attributes

Inherited from:
AstForTypesCreator
def tryCatchAst(tryNode: NewControlStructure, tryBodyAst: Ast, catchAsts: Seq[Ast], finallyAst: Option[Ast]): Ast

For the given try body, catch ASTs and finally AST, create a try-catch-finally AST with orders set correctly for the ossdataflow engine.

For the given try body, catch ASTs and finally AST, create a try-catch-finally AST with orders set correctly for the ossdataflow engine.

Attributes

Inherited from:
AstCreatorBase
def whileAst(condition: Option[Ast], body: Seq[Ast], code: Option[String], lineNumber: Option[Integer], columnNumber: Option[Integer]): Ast

Attributes

Inherited from:
AstCreatorBase
def withArgumentIndex[T <: ExpressionNew](node: T, argIdxOpt: Option[Int]): T

Attributes

Inherited from:
AstCreatorBase
def withArgumentName[T <: ExpressionNew](node: T, argNameOpt: Option[String]): T

Attributes

Inherited from:
AstCreatorBase
def withIndex[T, X](nodes: Array[T])(f: (T, Int) => X): Seq[X]

Attributes

Inherited from:
AstCreatorBase
def withIndex[T, X](nodes: Seq[T])(f: (T, Int) => X): Seq[X]

Attributes

Inherited from:
AstCreatorBase
def wrapMultipleInBlock(asts: Seq[Ast], lineNumber: Option[Integer]): Ast

Attributes

Inherited from:
AstCreatorBase

Concrete fields

val cdtAst: IASTTranslationUnit
val file2OffsetTable: ConcurrentHashMap[String, Array[Int]]
val filename: String
protected val logger: Logger
protected val methodAstParentStack: ListBuffer[NewNode]
protected val scope: Scope[String, (NewNode, String), NewNode]
protected val usingDeclarationMappings: Map[String, String]

Inherited fields

val diffGraph: DiffGraphBuilder

Attributes

Inherited from:
AstCreatorBase