[clang] 6ab9f1e - [Driver] Fix -fsanitize-address-stack-use-after-scope after D142606

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 6 12:54:39 PST 2023


Author: Fangrui Song
Date: 2023-02-06T12:54:34-08:00
New Revision: 6ab9f1e59371fe96ca3fda1a26a28ae0b7caf637

URL: https://github.com/llvm/llvm-project/commit/6ab9f1e59371fe96ca3fda1a26a28ae0b7caf637
DIFF: https://github.com/llvm/llvm-project/commit/6ab9f1e59371fe96ca3fda1a26a28ae0b7caf637.diff

LOG: [Driver] Fix -fsanitize-address-stack-use-after-scope after D142606

Driver::getToolChain called by Driver::BuildCompilation gets the
`Triple` argument from a temporary. With delayed detection due to
LazyDetector, we would reference a dangling `Triple`.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/LazyDetector.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/LazyDetector.h b/clang/lib/Driver/ToolChains/LazyDetector.h
index dfa8b5a4a82e4..813d00a87bb88 100644
--- a/clang/lib/Driver/ToolChains/LazyDetector.h
+++ b/clang/lib/Driver/ToolChains/LazyDetector.h
@@ -20,7 +20,7 @@ namespace clang {
 
 template <class T> class LazyDetector {
   const driver::Driver &D;
-  const llvm::Triple &Triple;
+  llvm::Triple Triple;
   const llvm::opt::ArgList &Args;
 
   std::optional<T> Detector;


        


More information about the cfe-commits mailing list