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

Member predicate WhileStmt::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()