From: Simon Pilgrim Date: Thu, 26 Sep 2019 17:11:02 +0000 (+0000) Subject: TGParser::ParseOperation - silence static analyzer dyn_cast null dereferen... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4951b5ac2b8f38aceabc8fe28f783c8dc7aad18b;p=llvm TGParser::ParseOperation - silence static analyzer dyn_cast null dereference warning. NFCI. The static analyzer is warning about a potential null dereference, but we should be able to use cast 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372997 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index a076966aff0..c373e2899a5 100644 --- a/lib/TableGen/TGParser.cpp +++ b/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(InitList.back()); + RecTy *ListType = cast(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 &&