bloomberg / clangmetatool

A framework for reusing code in Clang tools
https://bloomberg.github.io/clangmetatool/
Apache License 2.0
119 stars 25 forks source link

Fix source range for macro arguments #59

Closed dbeer1 closed 3 years ago

dbeer1 commented 3 years ago

ENG2STAAR-2680

Describe your changes The SourceUtil::getRangeForStatement method was not working properly when called on function macro calls that were themselves arguments to another macro. The reason was that we were using a function that always got the first token of the macro expansion, which was the macro name, instead of the full range.

For example, when the function would return only the source range of INNER instead of INNER(1) in

return OUTER(INNER(1));

This change also significantly simplifies the SourceUtil::isPartialMacro function, which was suffering from the same issue.

Testing performed Added unit tests

dbeer1 commented 3 years ago

CC: @envp, @HaltCatchFire