diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index d552f4ccd7668c..55c4da639a8157 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -1012,7 +1012,7 @@
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 c16bc5f0eafde6..221cab03b0ecba 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -2523,7 +2523,7 @@ extern const internal::VariadicDynCastAllOfMatcher/// 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 ed222a1fdf8778..6723e1657c1ab6 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;