CodeQL library for C/C++
Search

Member predicate MacroInvocation::getUnexpandedArgument

Gets the ith unexpanded argument of this macro invocation, where the first argument has i = 0. The result has been expanded for macro parameters but not for macro invocations. This means that for macro invocations not inside a #define, which can have no macro parameters in their arguments, the result is equivalent to what is in the source text, modulo whitespace.

In the following code example, the argument of the outermost invocation is ID(1) in unexpanded form and 1 in expanded form.

#define ID(x) x
ID(ID(1))

In the following example code, the last line contains an invocation of macro A and a child invocation of macro ID. The argument to ID is 1 in both unexpanded and expanded form because macro parameters (here, x) are expanded in both cases.

#define ID(x) x
#define A(x) ID(x)
A(1)

The ... parameter in variadic macros counts as one parameter that always receives one argument, which may contain commas.

Use getExpandedArgument to get the expanded form.

string getUnexpandedArgument(int i)