]> granicus.if.org Git - llvm/commitdiff
DAGISelMatcherOpt - TGParser::ParseOperation - silence static analyzer cast_or_null...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 26 Sep 2019 17:38:47 +0000 (17:38 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 26 Sep 2019 17:38:47 +0000 (17:38 +0000)
The static analyzer is warning about a potential null dereference, replace with an null/isa assertion and cast<CheckTypeMatcher>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373001 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelMatcherOpt.cpp

index 7d51b07693720ff8953637703c102ada3a65a260..6746fdd676a7fd1a4aa11a2cdff1ff5e6ba4ddc2 100644 (file)
@@ -409,13 +409,14 @@ static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) {
     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.