Skip to content

Commit

Permalink
[TableGen] Print Error and not crash on dumping non-string values (ll…
Browse files Browse the repository at this point in the history
…vm#104568)

Co-authored-by: Akshat Oke <Akshat.Oke@amd.com>
  • Loading branch information
optimisan and optimisan authored Aug 19, 2024
1 parent a80a90e commit 82fdfd4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions llvm/lib/TableGen/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 82fdfd4

Please sign in to comment.