[clang] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 16 05:31:25 PST 2024


================
@@ -1826,6 +1826,14 @@ TEST_P(ASTMatchersTest, IsStaticStorageClass) {
   EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass())));
   EXPECT_TRUE(notMatches("extern int i;", varDecl(isStaticStorageClass())));
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass())));
+
+  if (!GetParam().isCXX())
+    return;
+
+  EXPECT_TRUE(matches("static void foo(); void foo() {}",
+                      functionDecl(isDefinition(), isStaticStorageClass())));
----------------
HerrCai0907 wrote:

static function also available in C.

https://github.com/llvm/llvm-project/pull/120027


More information about the cfe-commits mailing list