[clang] [-Wunsafe-buffer-usage] Warning-only analysis no longer re-analyzes pre-compiled code (PR #198006)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Fri May 22 12:25:01 PDT 2026


================
@@ -360,6 +360,20 @@ Attribute Changes in Clang
       - Name: myUnsafeFunction
         UnsafeBufferUsage: true
 
+- When using ``-Wunsafe-buffer-usage`` without
+  ``-fsafe-buffer-usage-suggestions``, warnings are now emitted only
+  once per source file. Pre-compiled code (such as PCH or module
+  headers) is no longer repeatedly analyzed, as it is analyzed during
+  its initial compilation. (Traditionally included headers are still
+  analyzed within each translation unit that includes them).  This
+  behavior matches most of other ``-W`` diagnostics.
+
+  When ``-fsafe-buffer-usage-suggestions`` is enabled, the behavior
+  remains the same as before: pre-compiled code is deserialized and
+  analyzed alongside the translation unit that uses it, because fix-it
+  suggestion analysis requires full visibility of the translation
+  unit.
----------------
ziqingluo-90 wrote:

well, actually when unified build is off and incremental build is on, which involves a lot of PCHs, the analysis accounts for 75% of the build time.

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


More information about the cfe-commits mailing list