Class CXXLanguageFrontend


  • public class CXXLanguageFrontend
    extends LanguageFrontend
    The language frontend for translating CXX languages into the graph. It uses Eclipse CDT to parse the actual source code into an AST.

    Frontend for ONE CXX File

    • Method Detail

      • getCodeFromRawNode

        public <T> @Nullable java.lang.String getCodeFromRawNode​(T astNode)
        Description copied from class: LanguageFrontend
        Returns the raw code of the ast node, generic for java or c++ ast nodes.
        Specified by:
        getCodeFromRawNode in class LanguageFrontend
        Type Parameters:
        T - the raw ast type
        Parameters:
        astNode - the ast node
        Returns:
        the source code
      • getLocationFromRawNode

        public <T> @Nullable PhysicalLocation getLocationFromRawNode​(T astNode)
        Description copied from class: LanguageFrontend
        Returns the Region of the code with line and column, index starting at 1, generic for java or c++ ast nodes.
        Specified by:
        getLocationFromRawNode in class LanguageFrontend
        Type Parameters:
        T - the raw ast type
        Parameters:
        astNode - the ast node
        Returns:
        the location
      • processAttributes

        public void processAttributes​(@NonNull Node node,
                                      @NonNull org.eclipse.cdt.core.dom.ast.IASTAttributeOwner owner)
        Processes C++ attributes into Annotation nodes.
        Parameters:
        node - the node to process
        owner - the AST node which holds the attribute
      • replaceDeclarationInExpression

        public void replaceDeclarationInExpression​(Declaration newDeclaration,
                                                   Declaration oldDeclaration)
        Updates Expressions Refers-To Edge and cachedDeclaration from an old Declaration to new Declaration by using cachedExpressions. E.g. VariableDeclaration is replaced by FieldDeclaration and the refersTo Edge from the Expression must point to the new FieldExpression
        Parameters:
        newDeclaration - replaces the old target of the refersTo Edge (e.g. FieldDeclaration)
        oldDeclaration - current target of the refersTo Edge and will be replaced (e.g. VariableDeclaration)
      • expressionRefersToDeclaration

        public void expressionRefersToDeclaration​(Expression expression,
                                                  org.eclipse.cdt.core.dom.ast.IASTExpression iastExpression)
      • cacheDeclaration

        public @Nullable Declaration cacheDeclaration​(org.eclipse.cdt.core.dom.ast.IBinding binding,
                                                      Declaration declaration)
      • getCachedDeclaration

        public Declaration getCachedDeclaration​(org.eclipse.cdt.core.dom.ast.IBinding binding)
      • getCachedExpression

        public java.util.List<Expression> getCachedExpression​(org.eclipse.cdt.core.dom.ast.IBinding binding)
      • getCachedDeclarations

        public java.util.Map<org.eclipse.cdt.core.dom.ast.IBinding,​Declaration> getCachedDeclarations()
      • getDeclaratorHandler

        public de.fraunhofer.aisec.cpg.frontends.cpp.DeclaratorHandler getDeclaratorHandler()
      • getExpressionHandler

        public de.fraunhofer.aisec.cpg.frontends.cpp.ExpressionHandler getExpressionHandler()
      • getStatementHandler

        public de.fraunhofer.aisec.cpg.frontends.cpp.StatementHandler getStatementHandler()