[PATCH] D75202: [ASTMatchers] HasNameMatcher handles `extern "C"`
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 13:42:17 PST 2020
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM!
================
Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:518
+ // Linkage Spec can just be ignored
+ // FIXME: Any other DeclContext kinds that can be safely disregarded
+ if (isa<LinkageSpecDecl>(Ctx))
----------------
I would imagine we'd want to skip an `ExternCContextDecl` for similar reasons, though I am struggling to find a test case that actually generates that context.
================
Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:1648
+ // https://bugs.llvm.org/show_bug.cgi?id=42193
+ std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+ EXPECT_TRUE(matches(code, functionDecl(hasName("test"))));
----------------
As another test:
```
namespace foo {
extern "C" {
void test();
}
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75202/new/
https://reviews.llvm.org/D75202
More information about the cfe-commits
mailing list