Class CXXLanguageFrontend
- java.lang.Object
-
- de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
-
- de.fraunhofer.aisec.cpg.frontends.cpp.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
-
-
Field Summary
-
Fields inherited from class de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
config, currentTU, log, objectListeners, predicateListeners, processedMapping, scopeManager
-
-
Constructor Summary
Constructors Constructor Description CXXLanguageFrontend(@NonNull TranslationConfiguration config, ScopeManager scopeManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable DeclarationcacheDeclaration(org.eclipse.cdt.core.dom.ast.IBinding binding, Declaration declaration)voidcleanup()voidexpressionRefersToDeclaration(Expression expression, org.eclipse.cdt.core.dom.ast.IASTExpression iastExpression)DeclarationgetCachedDeclaration(org.eclipse.cdt.core.dom.ast.IBinding binding)java.util.Map<org.eclipse.cdt.core.dom.ast.IBinding,Declaration>getCachedDeclarations()java.util.List<Expression>getCachedExpression(org.eclipse.cdt.core.dom.ast.IBinding binding)<T> @Nullable java.lang.StringgetCodeFromRawNode(T astNode)Returns the raw code of the ast node, generic for java or c++ ast nodes.DeclarationHandlergetDeclarationHandler()de.fraunhofer.aisec.cpg.frontends.cpp.DeclaratorHandlergetDeclaratorHandler()de.fraunhofer.aisec.cpg.frontends.cpp.ExpressionHandlergetExpressionHandler()InitializerHandlergetInitializerHandler()<T> @Nullable PhysicalLocationgetLocationFromRawNode(T astNode)Returns theRegionof the code with line and column, index starting at 1, generic for java or c++ ast nodes.ParameterDeclarationHandlergetParameterDeclarationHandler()de.fraunhofer.aisec.cpg.frontends.cpp.StatementHandlergetStatementHandler()TranslationUnitDeclarationparse(java.io.File file)voidprocessAttributes(@NonNull Node node, @NonNull org.eclipse.cdt.core.dom.ast.IASTAttributeOwner owner)Processes C++ attributes intoAnnotationnodes.voidreplaceDeclarationInExpression(Declaration newDeclaration, Declaration oldDeclaration)Updates Expressions Refers-To Edge and cachedDeclaration from an old Declaration to new Declaration by using cachedExpressions.<S,T>
voidsetComment(S s, T ctx)-
Methods inherited from class de.fraunhofer.aisec.cpg.frontends.LanguageFrontend
clearProcessed, getCodeOfSubregion, getCurrentTU, getNamespaceDelimiter, getNewLineType, getScopeManager, mergeRegions, parseAll, process, registerObjectListener, registerPredicateListener, setCodeAndRegion, setCurrentTU, setScopeManager
-
-
-
-
Constructor Detail
-
CXXLanguageFrontend
public CXXLanguageFrontend(@NonNull TranslationConfiguration config, ScopeManager scopeManager)
-
-
Method Detail
-
parse
public TranslationUnitDeclaration parse(java.io.File file) throws TranslationException
- Specified by:
parsein classLanguageFrontend- Throws:
TranslationException
-
getCodeFromRawNode
public <T> @Nullable java.lang.String getCodeFromRawNode(T astNode)
Description copied from class:LanguageFrontendReturns the raw code of the ast node, generic for java or c++ ast nodes.- Specified by:
getCodeFromRawNodein classLanguageFrontend- 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:LanguageFrontendReturns theRegionof the code with line and column, index starting at 1, generic for java or c++ ast nodes.- Specified by:
getLocationFromRawNodein classLanguageFrontend- 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 intoAnnotationnodes.- Parameters:
node- the node to processowner- 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()
-
cleanup
public void cleanup()
- Overrides:
cleanupin classLanguageFrontend
-
setComment
public <S,T> void setComment(S s, T ctx)- Specified by:
setCommentin classLanguageFrontend
-
getDeclarationHandler
public DeclarationHandler getDeclarationHandler()
-
getDeclaratorHandler
public de.fraunhofer.aisec.cpg.frontends.cpp.DeclaratorHandler getDeclaratorHandler()
-
getExpressionHandler
public de.fraunhofer.aisec.cpg.frontends.cpp.ExpressionHandler getExpressionHandler()
-
getInitializerHandler
public InitializerHandler getInitializerHandler()
-
getParameterDeclarationHandler
public ParameterDeclarationHandler getParameterDeclarationHandler()
-
getStatementHandler
public de.fraunhofer.aisec.cpg.frontends.cpp.StatementHandler getStatementHandler()
-
-