=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/89...@github.com>


================
@@ -153,61 +178,57 @@ size_t 
TaggedUnionMemberCountCheck::getNumberOfValidEnumValues(
         CeIsLast = true;
         CeValue = Val;
         CeCount += 1;
-        CountingEnumConstantDecl = Enumerator;
+        OutCountingEnumConstantDecl = Enumerator;
       } else {
         CeIsLast = false;
       }
     }
   }
 
-  size_t ValidValuesCount = EnumValues.size();
+  std::size_t ValidValuesCount = EnumValues.size();
   if (CeCount == 1 && CeIsLast && CeValue == MaxTagValue) {
     ValidValuesCount -= 1;
   } else {
-    CountingEnumConstantDecl = nullptr;
+    OutCountingEnumConstantDecl = nullptr;
   }
 
   return ValidValuesCount;
 }
 
 void TaggedUnionMemberCountCheck::check(
     const MatchFinder::MatchResult &Result) {
-  const auto *Root = Result.Nodes.getNodeAs<RecordDecl>("root");
-  const auto *UnionField = Result.Nodes.getNodeAs<FieldDecl>("union");
-  const auto *TagField = Result.Nodes.getNodeAs<FieldDecl>("tags");
-
-  // The matcher can only narrow down the type to recordType()
-  if (!isUnion(UnionField))
-    return;
-
-  if (hasMultipleUnionsOrEnums(Root))
-    return;
+  const auto *Root = Result.Nodes.getNodeAs<RecordDecl>(RootMatchBindName);
+  const auto *UnionField =
+      Result.Nodes.getNodeAs<FieldDecl>(UnionMatchBindName);
+  const auto *TagField = Result.Nodes.getNodeAs<FieldDecl>(TagMatchBindName);
+  assert(Root && UnionField && TagField);
----------------
isuckatcs wrote:

How about adding a return if one of these is missing, so we don't crash in 
release mode? Also it's a good idea to separate the assertions, so that we know 
which of the 3 conditions fails on a crash.

https://github.com/llvm/llvm-project/pull/89925
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to