[clang] d86349c - Fix some warnings in SemaHLSL.cpp.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 11:02:52 PDT 2024


Author: Haojian Wu
Date: 2024-08-23T20:02:37+02:00
New Revision: d86349cf40196bc7f52e3f294ed2afafacadf1f5

URL: https://github.com/llvm/llvm-project/commit/d86349cf40196bc7f52e3f294ed2afafacadf1f5
DIFF: https://github.com/llvm/llvm-project/commit/d86349cf40196bc7f52e3f294ed2afafacadf1f5.diff

LOG: Fix some warnings in SemaHLSL.cpp.

Added: 
    

Modified: 
    clang/lib/Sema/SemaHLSL.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 320e38b740a742..17cb47f80590d9 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -673,7 +673,7 @@ static RegisterType getRegisterType(StringRef Slot) {
   case 'U':
     return RegisterType::UAV;
   case 'b':
-  case 'B ':
+  case 'B':
     return RegisterType::CBuffer;
   case 's':
   case 'S':
@@ -721,16 +721,6 @@ static void ValidateMultipleRegisterAnnotations(Sema &S, Decl *TheDecl,
   }
 }
 
-static std::string getHLSLResourceTypeStr(Sema &S, Decl *TheDecl) {
-  if (VarDecl *TheVarDecl = dyn_cast<VarDecl>(TheDecl)) {
-    QualType TheQualTy = TheVarDecl->getType();
-    PrintingPolicy PP = S.getPrintingPolicy();
-    return QualType::getAsString(TheQualTy.split(), PP);
-  }
-  if (HLSLBufferDecl *CBufferOrTBuffer = dyn_cast<HLSLBufferDecl>(TheDecl))
-    return CBufferOrTBuffer->isCBuffer() ? "cbuffer" : "tbuffer";
-}
-
 static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
                                           Decl *TheDecl, RegisterType regType) {
 
@@ -785,7 +775,7 @@ static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
         RegisterType::CBuffer,
         RegisterType::Sampler,
     };
-    assert((int)DeclResourceClass <
+    assert((size_t)DeclResourceClass <
                std::size(ExpectedRegisterTypesForResourceClass) &&
            "DeclResourceClass has unexpected value");
 
@@ -820,7 +810,7 @@ static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
   if (Flags.UDT) {
     const bool ExpectedRegisterTypesForUDT[] = {
         Flags.SRV, Flags.UAV, Flags.CBV, Flags.Sampler, Flags.ContainsNumeric};
-    assert(regTypeNum < std::size(ExpectedRegisterTypesForUDT) &&
+    assert((size_t)regTypeNum < std::size(ExpectedRegisterTypesForUDT) &&
            "regType has unexpected value");
 
     if (!ExpectedRegisterTypesForUDT[regTypeNum])


        


More information about the cfe-commits mailing list