Skip to content

Commit 04acf88

Browse files
committed
add doc and test
1 parent 3e521e7 commit 04acf88

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

clang/docs/LibASTMatchersReference.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,17 @@ <h2 id="decl-matchers">Node Matchers</h2>
804804
</pre></td></tr>
805805

806806

807+
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('exportDecl0')"><a name="exportDecl0Anchor">exportDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExportDecl.html">ExportDecl</a>&gt;...</td></tr>
808+
<tr><td colspan="4" class="doc" id="exportDecl0"><pre>Matches any export declaration.
809+
810+
Example matches following declarations.
811+
export void foo();
812+
export { void foo(); }
813+
export namespace { void foo(); }
814+
export int v;
815+
</pre></td></tr>
816+
817+
807818
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('fieldDecl0')"><a name="fieldDecl0Anchor">fieldDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;...</td></tr>
808819
<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
809820

clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,21 @@ TEST(ASTMatchersTestCUDA, HasAttrCUDA) {
189189
hasAttr(clang::attr::CUDAGlobal)));
190190
}
191191

192+
TEST_P(ASTMatchersTest, ExportDecl) {
193+
if (!GetParam().isCXX20OrLater()) {
194+
return;
195+
}
196+
const std::string moduleHeader = "module;export module ast_matcher_test;";
197+
EXPECT_TRUE(matches(moduleHeader + "export void foo();",
198+
exportDecl(has(functionDecl()))));
199+
EXPECT_TRUE(matches(moduleHeader + "export { void foo(); int v; }",
200+
exportDecl(has(functionDecl()))));
201+
EXPECT_TRUE(matches(moduleHeader + "export { void foo(); int v; }",
202+
exportDecl(has(varDecl()))));
203+
EXPECT_TRUE(matches(moduleHeader + "export namespace aa { void foo(); }",
204+
exportDecl(has(namespaceDecl()))));
205+
}
206+
192207
TEST_P(ASTMatchersTest, ValueDecl) {
193208
if (!GetParam().isCXX()) {
194209
// FIXME: Fix this test in non-C++ language modes.

0 commit comments

Comments
 (0)