CodeQL library for C/C++
codeql/cpp-all 0.12.8-dev (changelog, source)
Search

Member predicate Stmt::getGeneratingMacro

Gets a macro invocation that generates this entire statement.

For example, given

#define SOMEFUN a()
#define FOO do { SOMEFUN; b(); } while (0)
void f(void) {
    FOO;
}

this predicate would have results of SOMEFUN and FOO for the function call a(), and just FOO for the function call b(), the block within the ‘do’ statement, and the entire ‘do’ statement.

Note that, unlike isInMacroExpansion() it is not necessary for the macro to generate the terminating semi-colon.

MacroInvocation getGeneratingMacro()