[clang] 06a9832 - [ASTMatchers][NFC] Fix name of matcher in docs and add a missing test
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 11 05:16:04 PDT 2022
Author: Whisperity
Date: 2022-05-11T14:15:53+02:00
New Revision: 06a98328fc7b70756782fafff5ebfbec815cf1f5
URL: https://github.com/llvm/llvm-project/commit/06a98328fc7b70756782fafff5ebfbec815cf1f5
DIFF: https://github.com/llvm/llvm-project/commit/06a98328fc7b70756782fafff5ebfbec815cf1f5.diff
LOG: [ASTMatchers][NFC] Fix name of matcher in docs and add a missing test
Added:
Modified:
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
Removed:
################################################################################
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index d552f4ccd7668..55c4da639a815 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1012,7 +1012,7 @@ <h2 id="decl-matchers">Node Matchers</h2>
<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
Example:
- staticAssertExpr()
+ staticAssertDecl()
matches
static_assert(sizeof(S) == sizeof(int))
in
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index c16bc5f0eafde..221cab03b0ecb 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2523,7 +2523,7 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, OpaqueValueExpr>
/// Matches a C++ static_assert declaration.
///
/// Example:
-/// staticAssertExpr()
+/// staticAssertDecl()
/// matches
/// static_assert(sizeof(S) == sizeof(int))
/// in
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index ed222a1fdf877..6723e1657c1ab 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -735,6 +735,17 @@ TEST_P(ASTMatchersTest, ParmVarDecl) {
EXPECT_TRUE(notMatches("void f();", parmVarDecl()));
}
+TEST_P(ASTMatchersTest, StaticAssertDecl) {
+ if (!GetParam().isCXX11OrLater())
+ return;
+
+ EXPECT_TRUE(matches("static_assert(true, \"\");", staticAssertDecl()));
+ EXPECT_TRUE(
+ notMatches("constexpr bool staticassert(bool B, const char *M) "
+ "{ return true; };\n void f() { staticassert(true, \"\"); }",
+ staticAssertDecl()));
+}
+
TEST_P(ASTMatchersTest, Matcher_ConstructorCall) {
if (!GetParam().isCXX()) {
return;
More information about the cfe-commits
mailing list