[clang] Switch sanity check to assert; NFC (PR #151181)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 29 09:10:38 PDT 2025


https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/151181

This was written out of an abundance of caution because the changes were being added to the release branch. Now we can be a little less cautious and switch to using an assert. No behavioral changes are expected.

>From 4ef1f4cb106a253df8e32c83e96f87fb56a88afe Mon Sep 17 00:00:00 2001
From: Aaron Ballman <aaron at aaronballman.com>
Date: Tue, 29 Jul 2025 12:09:02 -0400
Subject: [PATCH] Switch sanity check to assert; NFC

This was written out of an abundance of caution because the changes
were being added to the release branch. Now we can be a little less
cautious and switch to using an assert. No behavioral changes are
expected.
---
 clang/lib/AST/ASTStructuralEquivalence.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp
index f113b32d6eb30..52c28a54c3129 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -884,12 +884,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
       // class comparison.
       if (T1->getTypeClass() == Type::Enum) {
         T1 = T1->getAs<EnumType>()->getDecl()->getIntegerType();
-        if (!T2->isBuiltinType() || T1.isNull()) // Sanity check
-          return false;
+        assert(T2->isBuiltinType() && !T1.isNull()); // Sanity check
       } else if (T2->getTypeClass() == Type::Enum) {
         T2 = T2->getAs<EnumType>()->getDecl()->getIntegerType();
-        if (!T1->isBuiltinType() || T2.isNull()) // Sanity check
-          return false;
+        assert(T1->isBuiltinType() && !T2.isNull()); // Sanity check
       }
       TC = Type::Builtin;
     } else



More information about the cfe-commits mailing list