[llvm] r359559 - [TableGen] Fix null pointer dereferencing in token parser.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 06:09:55 PDT 2019
Author: rksimon
Date: Tue Apr 30 06:09:55 2019
New Revision: 359559
URL: http://llvm.org/viewvc/llvm-project?rev=359559&view=rev
Log:
[TableGen] Fix null pointer dereferencing in token parser.
Reported in https://www.viva64.com/en/b/0629/
Modified:
llvm/trunk/lib/TableGen/TGParser.cpp
Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=359559&r1=359558&r2=359559&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Tue Apr 30 06:09:55 2019
@@ -2189,14 +2189,15 @@ Init *TGParser::ParseValue(Record *CurRe
// Create a !strconcat() operation, first casting each operand to
// a string if necessary.
if (LHS->getType() != StringRecTy::get()) {
- LHS = dyn_cast<TypedInit>(
+ auto CastLHS = dyn_cast<TypedInit>(
UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get())
->Fold(CurRec));
- if (!LHS) {
- Error(PasteLoc, Twine("can't cast '") + LHS->getAsString() +
- "' to string");
+ if (!CastLHS) {
+ Error(PasteLoc,
+ Twine("can't cast '") + LHS->getAsString() + "' to string");
return nullptr;
}
+ LHS = CastLHS;
}
TypedInit *RHS = nullptr;
@@ -2223,14 +2224,15 @@ Init *TGParser::ParseValue(Record *CurRe
}
if (RHS->getType() != StringRecTy::get()) {
- RHS = dyn_cast<TypedInit>(
+ auto CastRHS = dyn_cast<TypedInit>(
UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get())
->Fold(CurRec));
- if (!RHS) {
- Error(PasteLoc, Twine("can't cast '") + RHS->getAsString() +
- "' to string");
+ if (!CastRHS) {
+ Error(PasteLoc,
+ Twine("can't cast '") + RHS->getAsString() + "' to string");
return nullptr;
}
+ RHS = CastRHS;
}
break;
More information about the llvm-commits
mailing list