[clang] [HLSL] Simplify debug check in ResourceBindings::addDeclBindingInfo (PR #112661)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 16 21:37:28 PDT 2024


https://github.com/hekota created https://github.com/llvm/llvm-project/pull/112661

Follow-up for https://github.com/llvm/llvm-project/pull/111203#pullrequestreview-2373679837.

>From a541abfbda23c9e8b2d2959bf319b8319757af6b Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Wed, 16 Oct 2024 21:35:10 -0700
Subject: [PATCH] [HLSL] Simplify debug check in
 ResourceBindings::addDeclBindingInfo

---
 clang/lib/Sema/SemaHLSL.cpp | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 0d23c4935e9196..efb0fbaa432d76 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -110,15 +110,7 @@ DeclBindingInfo *ResourceBindings::addDeclBindingInfo(const VarDecl *VD,
                                                       ResourceClass ResClass) {
   assert(getDeclBindingInfo(VD, ResClass) == nullptr &&
          "DeclBindingInfo already added");
-#ifndef NDEBUG
-  // Verify that existing bindings for this decl are stored sequentially
-  // and at the end of the BindingsList
-  auto I = DeclToBindingListIndex.find(VD);
-  if (I != DeclToBindingListIndex.end()) {
-    for (unsigned Index = I->getSecond(); Index < BindingsList.size(); ++Index)
-      assert(BindingsList[Index].Decl == VD);
-  }
-#endif
+  assert(!hasBindingInfoForDecl(VD) || BindingsList.back().Decl == VD);
   // VarDecl may have multiple entries for different resource classes.
   // DeclToBindingListIndex stores the index of the first binding we saw
   // for this decl. If there are any additional ones then that index



More information about the cfe-commits mailing list