Class TypeHierarchyResolver

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

public class TypeHierarchyResolver
extends Pass
Transitively RecordDeclaration nodes with their supertypes' records.

Supertypes are all interfaces a class implements and the superclass it inherits from, including all of their respective supertypes). The JavaParser provides us with initial info about direct ancestors' names. This pass then recursively maps those and their own supertypes to the correct RecordDeclaration (if available).

After determining the ancestors of a class, all inherited methods are scanned to find out which of them are overridden/implemented in the current class. See FunctionDeclaration.getOverriddenBy()

Attention: Needs to be run before other analysis passes, as it triggers a type refresh. This is needed e.g. for TypeManager.getCommonType(Collection) to be re-evaluated at places where it is crucial to have parsed all RecordDeclarations. Otherwise, type information in the graph might not be fully correct

  • Field Summary

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

    lang, log
  • Constructor Summary

    Constructors
    Constructor Description
    TypeHierarchyResolver()  
  • Method Summary

    Modifier and Type Method Description
    void accept​(TranslationResult translationResult)  
    void cleanup()  
    LanguageFrontend getLang()  
    void setLang​(LanguageFrontend lang)
    Passes may need information about what source language they are parsing.

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

    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

    • TypeHierarchyResolver

      public TypeHierarchyResolver()
  • Method Details

    • getLang

      public LanguageFrontend getLang()
      Overrides:
      getLang in class Pass
      Returns:
      May be null
    • setLang

      public void setLang​(LanguageFrontend lang)
      Description copied from class: Pass
      Passes may need information about what source language they are parsing.
      Overrides:
      setLang in class Pass
      Parameters:
      lang - May be null
    • accept

      public void accept​(TranslationResult translationResult)
    • cleanup

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