[llvm] r373001 - DAGISelMatcherOpt - TGParser::ParseOperation - silence static analyzer cast_or_null<CheckTypeMatcher> null dereference warning. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 10:38:47 PDT 2019
Author: rksimon
Date: Thu Sep 26 10:38:47 2019
New Revision: 373001
URL: http://llvm.org/viewvc/llvm-project?rev=373001&view=rev
Log:
DAGISelMatcherOpt - TGParser::ParseOperation - silence static analyzer cast_or_null<CheckTypeMatcher> null dereference warning. NFCI.
The static analyzer is warning about a potential null dereference, replace with an null/isa assertion and cast<CheckTypeMatcher>.
Modified:
llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp?rev=373001&r1=373000&r2=373001&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp Thu Sep 26 10:38:47 2019
@@ -409,13 +409,14 @@ static void FactorNodes(std::unique_ptr<
DenseMap<unsigned, unsigned> TypeEntry;
SmallVector<std::pair<MVT::SimpleValueType, Matcher*>, 8> Cases;
for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) {
- CheckTypeMatcher *CTM =
- cast_or_null<CheckTypeMatcher>(FindNodeWithKind(NewOptionsToMatch[i],
- Matcher::CheckType));
+ Matcher* M = FindNodeWithKind(NewOptionsToMatch[i], Matcher::CheckType);
+ assert(M && isa<CheckTypeMatcher>(M) && "Unknown Matcher type");
+
+ auto *CTM = cast<CheckTypeMatcher>(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.
More information about the llvm-commits
mailing list