[llvm] r372997 - TGParser::ParseOperation - silence static analyzer dyn_cast<TypedInit> null dereference warning. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 10:11:02 PDT 2019
Author: rksimon
Date: Thu Sep 26 10:11:02 2019
New Revision: 372997
URL: http://llvm.org/viewvc/llvm-project?rev=372997&view=rev
Log:
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.
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=372997&r1=372996&r2=372997&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Thu Sep 26 10:11:02 2019
@@ -1147,9 +1147,9 @@ Init *TGParser::ParseOperation(Record *C
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 *C
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 &&
More information about the llvm-commits
mailing list