Class CallResolver

java.lang.Object
de.fraunhofer.aisec.cpg.passes.Pass
de.fraunhofer.aisec.cpg.passes.CallResolver
All Implemented Interfaces:
java.util.function.Consumer<TranslationResult>

public class CallResolver
extends Pass
Resolves CallExpression and NewExpression targets.

A CallExpression specifies the method that wants to be called via Node.getName(). The call target is a method of the same class the caller belongs to, so the name is resolved to the appropriate MethodDeclaration. This pass also takes into consideration that a method might not be present in the current class, but rather has its implementation in a superclass, and sets the pointer accordingly.

Constructor calls with ConstructExpression are resolved in such a way that their ConstructExpression.getInstantiates() points to the correct RecordDeclaration. Additionally, the ConstructExpression.getConstructor() is set to the according ConstructorDeclaration

  • Field Summary

    Fields inherited from class de.fraunhofer.aisec.cpg.passes.Pass

    lang, log
  • Constructor Summary

    Constructors
    Constructor Description
    CallResolver()  
  • Method Summary

    Modifier and Type Method Description
    void accept​(@NonNull TranslationResult translationResult)  
    static void addImplicitTemplateParametersToCall​(java.util.List<de.fraunhofer.aisec.cpg.graph.Node> templateParams, de.fraunhofer.aisec.cpg.graph.statements.expressions.ConstructExpression constructExpression)
    Adds implicit duplicates of the TemplateParams to the implicit ConstructExpression
    void cleanup()  

    Methods inherited from class de.fraunhofer.aisec.cpg.passes.Pass

    getLang, setLang, supportsLanguageFrontend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Consumer

    andThen
  • Constructor Details

    • CallResolver

      public CallResolver()
  • Method Details

    • cleanup

      public void cleanup()
      Specified by:
      cleanup in class Pass
    • accept

      public void accept​(@NonNull TranslationResult translationResult)
    • addImplicitTemplateParametersToCall

      public static void addImplicitTemplateParametersToCall​(java.util.List<de.fraunhofer.aisec.cpg.graph.Node> templateParams, de.fraunhofer.aisec.cpg.graph.statements.expressions.ConstructExpression constructExpression)
      Adds implicit duplicates of the TemplateParams to the implicit ConstructExpression
      Parameters:
      templateParams - of the VariableDeclaration/NewExpression
      constructExpression - duplicate TemplateParameters (implicit) to preserve AST, as ConstructExpression uses AST as well as the VariableDeclaration/NewExpression