From: Simon Pilgrim Date: Thu, 26 Sep 2019 17:38:47 +0000 (+0000) Subject: DAGISelMatcherOpt - TGParser::ParseOperation - silence static analyzer cast_or_null... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=895e9adef95e313f4fd2d40a161ccf3249ca42c2;p=llvm DAGISelMatcherOpt - TGParser::ParseOperation - silence static analyzer cast_or_null null dereference warning. NFCI. The static analyzer is warning about a potential null dereference, replace with an null/isa assertion and cast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373001 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 7d51b076937..6746fdd676a 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -409,13 +409,14 @@ static void FactorNodes(std::unique_ptr &InputMatcherPtr) { DenseMap TypeEntry; SmallVector, 8> Cases; for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) { - CheckTypeMatcher *CTM = - cast_or_null(FindNodeWithKind(NewOptionsToMatch[i], - Matcher::CheckType)); + Matcher* M = FindNodeWithKind(NewOptionsToMatch[i], Matcher::CheckType); + assert(M && isa(M) && "Unknown Matcher type"); + + auto *CTM = cast(M); Matcher *MatcherWithoutCTM = NewOptionsToMatch[i]->unlinkNode(CTM); MVT::SimpleValueType CTMTy = CTM->getType(); delete CTM; - + unsigned &Entry = TypeEntry[CTMTy]; if (Entry != 0) { // If we have unfactored duplicate types, then we should factor them.