[PATCH] D147771: [NFC] add check for potentially dereferencing null return value

Bing Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 7 01:35:54 PDT 2023


yubing created this revision.
Herald added a project: All.
yubing requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147771

Files:
  llvm/utils/TableGen/DAGISelMatcherGen.cpp


Index: llvm/utils/TableGen/DAGISelMatcherGen.cpp
===================================================================
--- llvm/utils/TableGen/DAGISelMatcherGen.cpp
+++ llvm/utils/TableGen/DAGISelMatcherGen.cpp
@@ -603,16 +603,17 @@
     // Get the slot we recorded the value in from the name on the node.
     unsigned RecNodeEntry = MatchedComplexPatterns[i].second;
 
-    const ComplexPattern &CP = *N->getComplexPatternInfo(CGP);
+    const ComplexPattern *CP = N->getComplexPatternInfo(CGP);
+    assert(CP && "Not a valid ComplexPattern!");
 
     // Emit a CheckComplexPat operation, which does the match (aborting if it
     // fails) and pushes the matched operands onto the recorded nodes list.
-    AddMatcher(new CheckComplexPatMatcher(CP, RecNodeEntry,
-                                          N->getName(), NextRecordedOperandNo));
+    AddMatcher(new CheckComplexPatMatcher(*CP, RecNodeEntry, N->getName(),
+                                          NextRecordedOperandNo));
 
     // Record the right number of operands.
-    NextRecordedOperandNo += CP.getNumOperands();
-    if (CP.hasProperty(SDNPHasChain)) {
+    NextRecordedOperandNo += CP->getNumOperands();
+    if (CP->hasProperty(SDNPHasChain)) {
       // If the complex pattern has a chain, then we need to keep track of the
       // fact that we just recorded a chain input.  The chain input will be
       // matched as the last operand of the predicate if it was successful.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147771.511640.patch
Type: text/x-patch
Size: 1458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230407/71375f26/attachment.bin>


More information about the llvm-commits mailing list