Skip to content

Commit 9cfa021

Browse files
[clang-tidy] Update documentation for 'fileScopeAsmDecl'
1 parent e6ac98a commit 9cfa021

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

clang/docs/LibASTMatchersReference.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,14 @@ <h2 id="decl-matchers">Node Matchers</h2>
828828
<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('fileScopeAsmDecl0')"><a name="fileScopeAsmDecl0Anchor">fileScopeAsmDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FileScopeAsmDecl.html">FileScopeAsmDecl</a>&gt;...</td></tr>
829829
<tr><td colspan="4" class="doc" id="fileScopeAsmDecl0"><pre>Matches top level asm declarations.
830830

831-
__asm__("nop");
831+
Given
832+
__asm("nop");
833+
void f() {
834+
__asm("mov al, 2");
835+
}
832836
fileScopeAsmDecl()
833-
matches '__asm__("nop")'
837+
matches '__asm("nop")',
838+
but not '__asm("mov al, 2")'.
834839
</pre></td></tr>
835840

836841

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,11 +2480,16 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, AsmStmt> asmStmt;
24802480

24812481
/// Matches top level asm declarations.
24822482
///
2483+
/// Given
24832484
/// \code
2484-
/// __asm__("nop");
2485+
/// __asm("nop");
2486+
/// void f() {
2487+
/// __asm("mov al, 2");
2488+
/// }
24852489
/// \endcode
24862490
/// fileScopeAsmDecl()
2487-
/// matches '__asm__("nop")'
2491+
/// matches '__asm("nop")',
2492+
/// but not '__asm("mov al, 2")'.
24882493
extern const internal::VariadicDynCastAllOfMatcher<Decl, FileScopeAsmDecl>
24892494
fileScopeAsmDecl;
24902495

clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ TEST_P(ASTMatchersTest, PredefinedExpr) {
11821182
TEST_P(ASTMatchersTest, FileScopeAsmDecl) {
11831183
EXPECT_TRUE(matches("__asm(\"nop\");", fileScopeAsmDecl()));
11841184
EXPECT_TRUE(
1185-
notMatches("void foo() { __asm(\"mov al, 2\"); }", fileScopeAsmDecl()));
1185+
notMatches("void f() { __asm(\"mov al, 2\"); }", fileScopeAsmDecl()));
11861186
}
11871187

11881188
TEST_P(ASTMatchersTest, AsmStatement) {

0 commit comments

Comments
 (0)