[llvm] 82fdfd4 - [TableGen] Print Error and not crash on dumping non-string values (#104568)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 18 21:29:51 PDT 2024


Author: Akshat Oke
Date: 2024-08-19T09:59:47+05:30
New Revision: 82fdfd4aa7f60b1f8e715211b925a7f2bfe57ea9

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

LOG: [TableGen] Print Error and not crash on dumping non-string values (#104568)

Co-authored-by: Akshat Oke <Akshat.Oke at amd.com>

Added: 
    

Modified: 
    llvm/lib/TableGen/Error.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp
index dabb265ef80ca1..4b99ff89da3b93 100644
--- a/llvm/lib/TableGen/Error.cpp
+++ b/llvm/lib/TableGen/Error.cpp
@@ -173,8 +173,11 @@ void CheckAssert(SMLoc Loc, Init *Condition, Init *Message) {
 // Dump a message to stderr.
 void dumpMessage(SMLoc Loc, Init *Message) {
   auto *MessageInit = dyn_cast<StringInit>(Message);
-  assert(MessageInit && "no debug message to print");
-  PrintNote(Loc, MessageInit->getValue());
+  if (!MessageInit) {
+    PrintError(Loc, "dump value is not of type string");
+  } else {
+    PrintNote(Loc, MessageInit->getValue());
+  }
 }
 
 } // end namespace llvm


        


More information about the llvm-commits mailing list