[PATCH] D73965: [clang] Add matcher to identify macro expansions.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 4 08:58:41 PST 2020
aaron.ballman added inline comments.
================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:313-317
+ auto& Context = Finder->getASTContext();
+ auto B =
+ internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
+ if (!B) return false;
+ auto E =
----------------
Please do not use auto when the type is not spelled out in the initialization.
================
Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:614
+ const ASTContext &Context) {
+ auto& SM = Context.getSourceManager();
+ const auto& LangOpts = Context.getLangOpts();
----------------
Same comments here about use of `auto`.
================
Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:128
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
+ std::string input = R"cc(
----------------
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?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73965/new/
https://reviews.llvm.org/D73965
More information about the cfe-commits
mailing list