TGParser::ParseOperation - silence static analyzer dyn_cast<TypedInit> null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use cast<TypedInit> directly and if not assert will fire for us.

I've also pulled out the repeated getType() call which was the only user of the pointer.

llvm-svn: 372997
This commit is contained in:
Simon Pilgrim 2019-09-26 17:11:02 +00:00
parent f1e1451946
commit 5c6ea055f6
1 changed files with 5 additions and 5 deletions

View File

@ -1147,9 +1147,9 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
if (!InitList.back()) return nullptr;
// All BinOps require their arguments to be of compatible types.
TypedInit *TI = dyn_cast<TypedInit>(InitList.back());
RecTy *ListType = cast<TypedInit>(InitList.back())->getType();
if (!ArgType) {
ArgType = TI->getType();
ArgType = ListType;
switch (Code) {
case BinOpInit::LISTCONCAT:
@ -1198,11 +1198,11 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
default: llvm_unreachable("other ops have fixed argument types");
}
} else {
RecTy *Resolved = resolveTypes(ArgType, TI->getType());
RecTy *Resolved = resolveTypes(ArgType, ListType);
if (!Resolved) {
Error(InitLoc, Twine("expected value of type '") +
ArgType->getAsString() + "', got '" +
TI->getType()->getAsString() + "'");
ArgType->getAsString() + "', got '" +
ListType->getAsString() + "'");
return nullptr;
}
if (Code != BinOpInit::ADD && Code != BinOpInit::AND &&