MacroArgumentExtractor

io.joern.c2cpg.astcreation.MacroArgumentExtractor
class MacroArgumentExtractor(tu: IASTTranslationUnit, loc: IASTFileLocation)

Utility class that obtains the arguments of the macro at loc of the translation unit tu (we used CDT's naming convention here.) The way this works is by performing macro expansion using CDT's MacroExpander, which accepts a MacroExpansionTracker, which is informed of arguments as they are determined. The problem is that the default MacroExpansionTracker does not make these arguments available separately but only in a form where all arguments have been merged back into a string.

By supplying a custom tracker that inherits from MacroExpansionTracker and overrides the method setExpandedMacroArgument, we can intercept arguments and store them in a list for later retrieval. We wrap this rather complicated way of accessing the macro arguments in the single public method getArguments of the MacroArgumentExtractor.

This class must be in this package in order to have access to PreprocessorMacro.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def getArguments: List[String]