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

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 29 09:11:04 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Aaron Ballman (AaronBallman)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/151181.diff


1 Files Affected:

- (modified) clang/lib/AST/ASTStructuralEquivalence.cpp (+2-4) 


``````````diff
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

``````````

</details>


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


More information about the cfe-commits mailing list