[llvm] [TableGen] Print Error and not crash on dumping non-string values (PR #104568)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 16 02:26:40 PDT 2024
https://github.com/Akshat-Oke created https://github.com/llvm/llvm-project/pull/104568
None
>From 14e82d2f9f440caaa0575b53c512f6605cfa5107 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Fri, 16 Aug 2024 09:07:23 +0000
Subject: [PATCH] [TableGen] Print Error and not crash on dumping non-string
values
---
llvm/lib/TableGen/Error.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
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