https://github.com/StoeckOverflow created 
https://github.com/llvm/llvm-project/pull/216272

APINotes are often used for system headers, so warnings emitted through the 
generic API-notes diagnostic should not be hidden solely because the referenced 
declaration is in a system header.

This PR sets `ShowInSystemHeader` on `warn_apinotes_message` and adds test 
coverage for an unmatched `Where.Parameters` warning emitted from a 
system-header declaration.

This follows up on feedback from 
https://github.com/llvm/llvm-project/pull/209408#pullrequestreview-4797088847

Reviewers: @Xazax-hun @j-hui @egorzhdan

>From 6ce2e729b3d0538354193a1a53aea79cdd567688 Mon Sep 17 00:00:00 2001
From: stoeckoverflow <[email protected]>
Date: Tue, 11 Aug 2026 14:58:14 +0200
Subject: [PATCH] [APINotes] Show API notes warnings in system headers

---
 .../clang/Basic/DiagnosticCommonKinds.td      |  3 +-
 .../apinotes-warnings-system-headers.cpp      | 28 +++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/APINotes/apinotes-warnings-system-headers.cpp

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 192fdf9299eb4..04fdeefc10adf 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -425,7 +425,8 @@ def err_module_format_unhandled : Error<
 
 // API notes
 def err_apinotes_message : Error<"%0">;
-def warn_apinotes_message : Warning<"%0">, InGroup<DiagGroup<"apinotes">>;
+def warn_apinotes_message : Warning<"%0">,
+  InGroup<DiagGroup<"apinotes">>, ShowInSystemHeader;
 def note_apinotes_message : Note<"%0">;
 
 class NonportablePrivateAPINotesPath  : Warning<
diff --git a/clang/test/APINotes/apinotes-warnings-system-headers.cpp 
b/clang/test/APINotes/apinotes-warnings-system-headers.cpp
new file mode 100644
index 0000000000000..86b36097322d2
--- /dev/null
+++ b/clang/test/APINotes/apinotes-warnings-system-headers.cpp
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t && split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -fapinotes -Wapinotes -isystem 
%t/SystemHeaderAPINotes %t/test.cpp -x c++ 2>&1 | FileCheck %s
+
+// CHECK: warning: API notes entry for 'systemHeaderUnmatched' has unmatched 
Where.Parameters [double]
+
+//--- test.cpp
+#include "SystemHeaderAPINotes.h"
+
+//--- SystemHeaderAPINotes/SystemHeaderAPINotes.h
+#ifndef SYSTEM_HEADER_API_NOTES_H
+#define SYSTEM_HEADER_API_NOTES_H
+
+#pragma clang system_header
+
+void systemHeaderUnmatched(int);
+
+#endif // SYSTEM_HEADER_API_NOTES_H
+
+//--- SystemHeaderAPINotes/APINotes.apinotes
+---
+Name: SystemHeaderAPINotes
+Functions:
+- Name: systemHeaderUnmatched
+  Where:
+    Parameters:
+    - double
+  SwiftName: systemHeaderUnmatched(_:)
+...

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to