[clang] Implement resource binding type prefix mismatch diagnostic infrastructure (PR #97103)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 15:48:40 PDT 2024


================
@@ -551,24 +541,21 @@ getHLSLResourceAttrFromEitherDecl(VarDecl *VD,
 
     // the resource attr could be on the record decl itself or on one of
     // its fields (the resource handle, most commonly)
-    const auto *Attr = TheRecordDecl->getAttr<HLSLResourceAttr>();
+    const auto *Attr = TheRecordDecl->getAttr<T>();
     if (!Attr) {
       for (auto *FD : TheRecordDecl->fields()) {
-        Attr = FD->getAttr<HLSLResourceAttr>();
+        Attr = FD->getAttr<T>();
         if (Attr)
           break;
       }
     }
     return Attr;
-  } else if (CBufferOrTBuffer) {
-    const auto *Attr = CBufferOrTBuffer->getAttr<HLSLResourceAttr>();
-    return Attr;
   }
-  llvm_unreachable("one of the two conditions should be true.");
+  llvm_unreachable("VD should not be null");
   return nullptr;
 }
 
-void traverseType(QualType TheQualTy, RegisterBindingFlags &Flags) {
+static void setFlagsFromType(QualType TheQualTy, RegisterBindingFlags &Flags) {
----------------
bob80905 wrote:

I think set is the proper word to use, because the highest level call is technically setting the appropriate flags for the variable type with the register annotation. It's a recursive function, so the subcalls won't be setting all the flags, but the highest call will set all the necessary flags.

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


More information about the cfe-commits mailing list