This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add matcher to identify macro expansions.
ClosedPublic

Authored by ymandel on Feb 4 2020, 7:06 AM.

Details

Summary

This revision adds a matcher isExpandedFromMacro that determines whether a
statement is (transitively) expanded from a given macro.

Diff Detail

Event Timeline

ymandel created this revision.Feb 4 2020, 7:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2020, 7:06 AM
ymandel updated this revision to Diff 242335.Feb 4 2020, 7:30 AM

Fix to get it to link correctly.

gribozavr2 accepted this revision.Feb 4 2020, 7:57 AM
This revision is now accepted and ready to land.Feb 4 2020, 7:57 AM
This revision was automatically updated to reflect the committed changes.
aaron.ballman added inline comments.
clang/include/clang/ASTMatchers/ASTMatchers.h
313–317

Please do not use auto when the type is not spelled out in the initialization.

clang/lib/ASTMatchers/ASTMatchersInternal.cpp
614

Same comments here about use of auto.

clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
128

One test that's missing which is important are macros defined on the command line rather than defined in source, as those have expansion locations that are in the scratch buffer rather than a source file. Are you able to add such a test?

Aaron -- I missed your comments before submitting. I'll send a follow up with fixes. Thanks!