[llvm] e7a83fc - [NVPTX] Fix a warning

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 12:55:21 PST 2025


Author: Kazu Hirata
Date: 2025-01-07T12:55:16-08:00
New Revision: e7a83fc74db78445c36a27f113e9b045f90f699a

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

LOG: [NVPTX] Fix a warning

This patch fixes:

  llvm/lib/Target/NVPTX/NVVMReflect.cpp:225:18: error: object backing
  the pointer will be destroyed at the end of the full-expression
  [-Werror,-Wdangling-gsl]

Added: 
    

Modified: 
    llvm/lib/Target/NVPTX/NVVMReflect.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/NVPTX/NVVMReflect.cpp b/llvm/lib/Target/NVPTX/NVVMReflect.cpp
index a0e897584a9d32..0cd584c4074447 100644
--- a/llvm/lib/Target/NVPTX/NVVMReflect.cpp
+++ b/llvm/lib/Target/NVPTX/NVVMReflect.cpp
@@ -222,7 +222,8 @@ bool NVVMReflect::runOnFunction(Function &F) {
 
 NVVMReflectPass::NVVMReflectPass() {
   // Get the CPU string from the command line if not provided.
-  StringRef SM = codegen::getMCPU();
+  std::string MCPU = codegen::getMCPU();
+  StringRef SM = MCPU;
   if (!SM.consume_front("sm_") || SM.consumeInteger(10, SmVersion))
     SmVersion = 0;
 }


        


More information about the llvm-commits mailing list