Skip to content

Commit

Permalink
[TableGen] Print Error and not crash on dumping non-string values
Browse files Browse the repository at this point in the history
  • Loading branch information
optimisan committed Aug 16, 2024
1 parent 0c02f61 commit b145038
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 b145038

Please sign in to comment.