summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-09-26 17:11:02 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-09-26 17:11:02 +0000
commit5c6ea055f6d4f0a976c82cec350b332a03ad42cb (patch)
tree95956fa10e20e86a1993e63b39064d16f058cfab /llvm/lib
parentf1e1451946502dd8f808c251bf4c3b571e80fd9d (diff)
downloadbcm5719-llvm-5c6ea055f6d4f0a976c82cec350b332a03ad42cb.tar.gz
bcm5719-llvm-5c6ea055f6d4f0a976c82cec350b332a03ad42cb.zip
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
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/TableGen/TGParser.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index a076966aff0..c373e2899a5 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -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 &&
OpenPOWER on IntegriCloud