[clang] [clang][CodeGen] Fix stack-use-after-return in deferred annotations (PR #226942)

Philipp Dominik Schubert via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 23:58:49 PDT 2026


================
@@ -506,7 +506,10 @@ class CodeGenModule : public CodeGenTypeCache {
 
   // Store deferred function annotations so they can be emitted at the end with
   // most up to date ValueDecl that will have all the inherited annotations.
-  llvm::MapVector<StringRef, const ValueDecl *> DeferredAnnotations;
+  // The key owns its storage: not every mangled name handed to
+  // GetOrCreateLLVMFunction outlives the call.
+  llvm::MapVector<std::string, const ValueDecl *, llvm::StringMap<unsigned>>
----------------
pdschbrt wrote:

I agree. If it was a hot path, I would have opted for a larger git diff and spent more energy on improving the situation.

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


More information about the cfe-commits mailing list