[clang] [clang][Sema] Don't warn for implicit uses of builtins in system headers (PR #138205)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri May 16 14:59:01 PDT 2025


================
@@ -1825,6 +1825,11 @@ class Sema final : public SemaBase {
   /// Set of no-builtin functions listed by \#pragma function.
   llvm::SmallSetVector<StringRef, 4> MSFunctionNoBuiltins;
 
+  /// Map of BuiltinIDs to source locations that have #pragma intrinsic calls
+  /// that refer to them.
+  llvm::DenseMap<unsigned, llvm::SmallSetVector<SourceLocation, 4>>
----------------
rnk wrote:

DenseMap of SmallVector values is not an efficient data structure choice, because the DenseMap is always at least 25% empty, and each SmallVector is likely to contain exactly 1 element.

I think we need to serialize these pragmas through the AST. Is it possible to do this by creating an implicit declaration of the builtin at the point of the pragma? You would test for this by making your system header into a module or PCH file in another test case.

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


More information about the cfe-commits mailing list