From 2dfd238c4be1231de1ff6cbd7f2598349fde25c8 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 26 Sep 2019 17:38:47 +0000 Subject: [PATCH] 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. llvm-svn: 373001 --- utils/TableGen/DAGISelMatcherOpt.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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.