Author: Michael Liao
Date: 2025-11-12T14:55:15-05:00
New Revision: cc54ee854f8a081861eb75ad788934705fc54878

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

LOG: [clang][HLSL] Fix crash issue due to Twine usage

- Dangling pointer (from std::string) is created and trigger crash on
  some Linux distributions under different build types.

Added: 
    

Modified: 
    clang/lib/Sema/SemaHLSL.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index b17c885909747..21eea5569a3eb 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -940,8 +940,7 @@ void SemaHLSL::checkSemanticAnnotation(
       DiagnoseAttrStageMismatch(SemanticAttr, ST, {llvm::Triple::Compute});
 
     if (SemanticAttr->getSemanticIndex() != 0) {
-      Twine PrettyName =
-          std::string("'") + SemanticAttr->getSemanticName() + "'";
+      Twine PrettyName = "'" + SemanticAttr->getSemanticName() + "'";
       Diag(SemanticAttr->getLoc(),
            diag::err_hlsl_semantic_indexing_not_supported)
           << PrettyName.str();


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to