Преглед изворни кода

Cleanup part of compiling warnings (#2903)

Try to fix some compiler warnings produced by clang when building the dxc compiler
Minmin Gong пре 5 година
родитељ
комит
7e0f44fa6f
44 измењених фајлова са 283 додато и 251 уклоњено
  1. 3 3
      include/dxc/DXIL/DxilConstants.h
  2. 17 13
      include/dxc/DXIL/DxilResourceProperties.h
  3. 3 3
      include/dxc/Test/DxcTestUtils.h
  4. 8 6
      include/dxc/Test/HlslTestUtils.h
  5. 2 2
      include/dxc/Test/WEXAdapter.h
  6. 1 1
      include/dxc/dxcisense.h
  7. 2 1
      include/llvm/ADT/PointerUnion.h
  8. 1 1
      include/llvm/Analysis/DxilValueCache.h
  9. 7 0
      include/llvm/LinkAllPasses.h
  10. 1 1
      include/llvm/Transforms/IPO/PassManagerBuilder.h
  11. 1 1
      lib/Bitcode/Reader/BitcodeReader.cpp
  12. 4 0
      lib/DXIL/DxilModule.cpp
  13. 2 2
      lib/DxcSupport/HLSLOptions.cpp
  14. 0 2
      lib/DxilContainer/DxilContainerReader.cpp
  15. 5 4
      lib/DxilPIXPasses/DxilAnnotateWithVirtualRegister.cpp
  16. 1 1
      lib/DxrFallback/Reducibility.cpp
  17. 1 1
      lib/HLSL/DxilCondenseResources.cpp
  18. 1 1
      lib/HLSL/DxilLegalizeSampleOffsetPass.cpp
  19. 3 4
      lib/HLSL/DxilNoops.cpp
  20. 1 1
      lib/HLSL/DxilPatchShaderRecordBindings.cpp
  21. 4 4
      lib/IR/Attributes.cpp
  22. 1 1
      lib/Transforms/Scalar/DxilLoopUnroll.cpp
  23. 1 1
      tools/clang/include/clang/Frontend/CodeGenOptions.h
  24. 3 3
      tools/clang/include/clang/Sema/Sema.h
  25. 1 1
      tools/clang/lib/CodeGen/CGExprScalar.cpp
  26. 2 2
      tools/clang/lib/CodeGen/CGHLSLMS.cpp
  27. 1 1
      tools/clang/lib/Parse/HLSLRootSignature.cpp
  28. 0 1
      tools/clang/lib/Parse/ParsePragma.cpp
  29. 12 10
      tools/clang/lib/SPIRV/CapabilityVisitor.h
  30. 64 62
      tools/clang/lib/SPIRV/EmitVisitor.h
  31. 24 22
      tools/clang/lib/SPIRV/LiteralTypeVisitor.h
  32. 6 4
      tools/clang/lib/SPIRV/LowerTypeVisitor.h
  33. 10 8
      tools/clang/lib/SPIRV/NonUniformVisitor.h
  34. 21 19
      tools/clang/lib/SPIRV/PreciseVisitor.h
  35. 29 27
      tools/clang/lib/SPIRV/RelaxedPrecisionVisitor.h
  36. 4 2
      tools/clang/lib/SPIRV/RemoveBufferBlockVisitor.h
  37. 4 4
      tools/clang/lib/SPIRV/SpirvEmitter.cpp
  38. 2 2
      tools/clang/lib/Sema/SemaHLSL.cpp
  39. 3 2
      tools/clang/tools/dxcompiler/dxclibrary.cpp
  40. 1 1
      tools/clang/tools/libclang/dxcisenseimpl.cpp
  41. 1 1
      tools/clang/tools/libclang/dxcisenseimpl.h
  42. 12 12
      tools/clang/unittests/HLSL/DXIsenseTest.cpp
  43. 9 9
      tools/clang/unittests/HLSL/DxilModuleTest.cpp
  44. 4 4
      tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp

+ 3 - 3
include/dxc/DXIL/DxilConstants.h

@@ -1438,9 +1438,9 @@ namespace DXIL {
   extern const char* kFP32DenormValuePreserveString;
   extern const char* kFP32DenormValueFtzString;
 
-  static const char *kDxBreakFuncName = "dx.break";
-  static const char *kDxBreakCondName = "dx.break.cond";
-  static const char *kDxBreakMDName = "dx.break.br";
+  extern const char *kDxBreakFuncName;
+  extern const char *kDxBreakCondName;
+  extern const char *kDxBreakMDName;
 
 } // namespace DXIL
 

+ 17 - 13
include/dxc/DXIL/DxilResourceProperties.h

@@ -25,26 +25,30 @@ struct DxilResourceProperties {
   DXIL::ResourceKind  Kind;
   static constexpr unsigned kSampleCountUndefined = 0x7;
 
+  struct DxilTyped {
+    DXIL::ComponentType CompType : 5; // TypedBuffer/Image.
+    uint32_t SingleComponent : 1;     // Return type is single component.
+    // 2^SampleCountPow2 for Sample count of Texture2DMS.
+    uint32_t SampleCountPow2 : 3;
+    uint32_t Reserved : 23;
+  };
+
   union {
-    struct {
-      DXIL::ComponentType CompType : 5; // TypedBuffer/Image.
-      uint32_t SingleComponent : 1;     // Return type is single component.
-      // 2^SampleCountPow2 for Sample count of Texture2DMS.
-      uint32_t SampleCountPow2 : 3;
-      uint32_t Reserved : 23;
-    } Typed;
+    DxilTyped Typed;
     uint32_t ElementStride; // in bytes for StructurizedBuffer.
     DXIL::SamplerFeedbackType SamplerFeedbackType; // FeedbackTexture2D.
     uint32_t SizeInBytes; // Cbuffer instance size in bytes.
     uint32_t RawDword0;
   };
 
+  struct DxilUAV {
+    uint32_t bROV : 1;              // UAV
+    uint32_t bGloballyCoherent : 1; // UAV
+    uint32_t Reserved : 30;
+  };
+
   union {
-    struct {
-      uint32_t bROV : 1;              // UAV
-      uint32_t bGloballyCoherent : 1; // UAV
-      uint32_t Reserved : 30;
-    } UAV;
+    DxilUAV UAV;
     uint32_t RawDword1;
   };
 
@@ -72,6 +76,6 @@ loadFromAnnotateHandle(DxilInst_AnnotateHandle &annotateHandle, llvm::Type *Ty,
                        const ShaderModel &);
 DxilResourceProperties loadFromResourceBase(DxilResourceBase *);
 
-}; // namespace resource_helper
+} // namespace resource_helper
 
 } // namespace hlsl

+ 3 - 3
include/dxc/Test/DxcTestUtils.h

@@ -67,21 +67,21 @@ struct FileRunCommandResult {
   static inline FileRunCommandResult Success() {
     FileRunCommandResult result;
     result.ExitCode = 0;
-    return std::move(result);
+    return result;
   }
 
   static inline FileRunCommandResult Success(std::string StdOut) {
     FileRunCommandResult result;
     result.ExitCode = 0;
     result.StdOut = std::move(StdOut);
-    return std::move(result);
+    return result;
   }
 
   static inline FileRunCommandResult Error(int ExitCode, std::string StdErr) {
     FileRunCommandResult result;
     result.ExitCode = ExitCode;
     result.StdErr = std::move(StdErr);
-    return std::move(result);
+    return result;
   }
 
   static inline FileRunCommandResult Error(std::string StdErr) {

+ 8 - 6
include/dxc/Test/HlslTestUtils.h

@@ -19,6 +19,7 @@
 #include <dxgiformat.h>
 #include "WexTestClass.h"
 #else
+#include "dxc/Support/Global.h" // DXASSERT_LOCALVAR
 #include "WEXAdapter.h"
 #endif
 #include "dxc/Support/Unicode.h"
@@ -79,28 +80,28 @@ using namespace std;
 
 static constexpr char whitespaceChars[] = " \t\r\n";
 
-static std::string strltrim(const std::string &value) {
+inline std::string strltrim(const std::string &value) {
   size_t first = value.find_first_not_of(whitespaceChars);
   return first == string::npos ? value : value.substr(first);
 }
 
-static std::string strrtrim(const std::string &value) {
+inline std::string strrtrim(const std::string &value) {
   size_t last = value.find_last_not_of(whitespaceChars);
   return last == string::npos ? value : value.substr(0, last + 1);
 }
 
-static std::string strtrim(const std::string &value) {
+inline std::string strtrim(const std::string &value) {
   return strltrim(strrtrim(value));
 }
 
-static bool strstartswith(const std::string& value, const char* pattern) {
+inline bool strstartswith(const std::string& value, const char* pattern) {
   for (size_t i = 0; ; ++i) {
     if (pattern[i] == '\0') return true;
     if (i == value.size() || value[i] != pattern[i]) return false;
   }
 }
 
-static std::vector<std::string> strtok(const std::string &value, const char *delimiters = whitespaceChars) {
+inline std::vector<std::string> strtok(const std::string &value, const char *delimiters = whitespaceChars) {
   size_t searchOffset = 0;
   std::vector<std::string> tokens;
   while (searchOffset != value.size()) {
@@ -126,7 +127,8 @@ vFormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, va_list argpt
 #else
   wchar_t fmtOut[1000];
   int len = vswprintf(fmtOut, 1000, fmt, argptr);
-  assert(len >= 0 && "Too long formatted string in vFormatToWstring");
+  DXASSERT_LOCALVAR(len, len >= 0,
+                    "Too long formatted string in vFormatToWstring");
   result = fmtOut;
 #endif
   return result;

+ 2 - 2
include/dxc/Test/WEXAdapter.h

@@ -158,8 +158,8 @@ HRESULT TryGetValue(const wchar_t *param, Common::String &retStr);
 } // namespace TestExecution
 namespace Logging {
 namespace Log {
-inline void StartGroup(const wchar_t *name) { wprintf(L"BEGIN TEST(S): <%ls>\n", name); };
-inline void EndGroup(const wchar_t *name) { wprintf(L"END TEST(S): <%ls>\n", name); };
+inline void StartGroup(const wchar_t *name) { wprintf(L"BEGIN TEST(S): <%ls>\n", name); }
+inline void EndGroup(const wchar_t *name) { wprintf(L"END TEST(S): <%ls>\n", name); }
 inline void Comment(const wchar_t *msg) {
   fputws(msg, stdout);
   fputwc(L'\n', stdout);

+ 1 - 1
include/dxc/dxcisense.h

@@ -785,7 +785,7 @@ IDxcTranslationUnit : public IUnknown
     _Out_ BSTR* errorMessage) = 0;
   virtual HRESULT STDMETHODCALLTYPE GetInclusionList(_Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcInclusion*** pResult) = 0;
   virtual HRESULT STDMETHODCALLTYPE CodeCompleteAt(
-      _In_ char *fileName, unsigned line, unsigned column,
+      _In_ const char *fileName, unsigned line, unsigned column,
       _In_ IDxcUnsavedFile** pUnsavedFiles, unsigned numUnsavedFiles,
       _In_ DxcCodeCompleteFlags options,
       _Outptr_result_nullonfailure_ IDxcCodeCompleteResults **pResult) = 0;

+ 2 - 1
include/llvm/ADT/PointerUnion.h

@@ -152,7 +152,8 @@ namespace llvm {
       assert(is<PT1>() && "Val is not the first pointer");
       assert(get<PT1>() == Val.getPointer() &&
          "Can't get the address because PointerLikeTypeTraits changes the ptr");
-      return (PT1 *)Val.getAddrOfPointer();
+      return const_cast<PT1 *>(
+          reinterpret_cast<const PT1 *>(Val.getAddrOfPointer()));
     }
 
     /// \brief Assignment from nullptr which just clears the union.

+ 1 - 1
include/llvm/Analysis/DxilValueCache.h

@@ -69,7 +69,7 @@ public:
 
   const char *getPassName() const override;
   DxilValueCache();
-  void getAnalysisUsage(AnalysisUsage &) const;
+  void getAnalysisUsage(AnalysisUsage &) const override;
 
   void dump() const;
   Value *GetValue(Value *V, DominatorTree *DT=nullptr);

+ 7 - 0
include/llvm/LinkAllPasses.h

@@ -42,6 +42,10 @@
 namespace {
   struct ForcePassLinking {
     ForcePassLinking() {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnull-dereference"
+#endif
       // We must reference the passes in such a way that compilers will not
       // delete it all as dead code, even with whole program optimization,
       // yet is effectively a NO-OP. As the compiler isn't smart enough
@@ -187,6 +191,9 @@ namespace {
       X.add(nullptr, 0, llvm::AAMDNodes()); // for -print-alias-sets
       (void) llvm::AreStatisticsEnabled();
       (void) llvm::sys::RunningOnValgrind();
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
     }
   } ForcePassLinking; // Force link by creating a global definition.
 }

+ 1 - 1
include/llvm/Transforms/IPO/PassManagerBuilder.h

@@ -132,7 +132,7 @@ public:
   hlsl::HLSLExtensionsCodegenHelper *HLSLExtensionsCodeGen = nullptr; // HLSL Change
   bool HLSLResMayAlias = false; // HLSL Change
   unsigned ScanLimit = 0; // HLSL Change
-  hlsl::OptimizationOptions HLSLOptimizationOptions = {0}; // HLSL Change
+  hlsl::OptimizationOptions HLSLOptimizationOptions = {}; // HLSL Change
 
 private:
   /// ExtensionList - This is list of all of the extensions that are registered.

+ 1 - 1
lib/Bitcode/Reader/BitcodeReader.cpp

@@ -372,7 +372,7 @@ private:
   std::error_code resolveGlobalAndAliasInits();
   std::error_code parseMetadata();
   std::error_code parseSelectNamedMetadata(ArrayRef<StringRef> NamedMetadata); // HLSL Change
-  std::error_code materializeSelectNamedMetadata(ArrayRef<StringRef> NamedMetadata); // HLSL Change
+  std::error_code materializeSelectNamedMetadata(ArrayRef<StringRef> NamedMetadata) override; // HLSL Change
   std::error_code parseMetadataAttachment(Function &F);
   ErrorOr<std::string> parseModuleTriple();
   std::error_code parseUseLists();

+ 4 - 0
lib/DXIL/DxilModule.cpp

@@ -76,6 +76,10 @@ const char* kFP32DenormKindString          = "fp32-denorm-mode";
 const char* kFP32DenormValueAnyString      = "any";
 const char* kFP32DenormValuePreserveString = "preserve";
 const char* kFP32DenormValueFtzString      = "ftz";
+
+const char *kDxBreakFuncName = "dx.break";
+const char *kDxBreakCondName = "dx.break.cond";
+const char *kDxBreakMDName = "dx.break.br";
 }
 
 // Avoid dependency on DxilModule from llvm::Module using this:

+ 2 - 2
lib/DxcSupport/HLSLOptions.cpp

@@ -303,7 +303,7 @@ static bool handleVkShiftArgs(const InputArgList &args, OptSpecifier id,
     return false;
   }
   return true;
-};
+}
 #endif
 // SPIRV Change Ends
 
@@ -492,7 +492,7 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
   if (!limit.empty())
     opts.ScanLimit = std::stoul(std::string(limit));
 
-  opts.DxcOptimizationOptions = {0};
+  opts.DxcOptimizationOptions = {};
   std::vector<std::string> DisabledOptimizations = Args.getAllArgValues(OPT_opt_disable);
   for (std::string opt : DisabledOptimizations) {
     llvm::StringRef gvn("gvn");

+ 0 - 2
lib/DxilContainer/DxilContainerReader.cpp

@@ -9,8 +9,6 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#pragma once
-
 #include "dxc/Support/Global.h"
 #include "dxc/Support/WinAdapter.h"
 #include "dxc/DxilContainer/DxilContainer.h"

+ 5 - 4
lib/DxilPIXPasses/DxilAnnotateWithVirtualRegister.cpp

@@ -101,7 +101,7 @@ bool DxilAnnotateWithVirtualRegister::runOnModule(llvm::Module &M) {
   unsigned int Major = 0;
   unsigned int Minor = 0;
   m_DM->GetDxilVersion(Major, Minor);
-  if (Major < 6 || Major == 6 && Minor <= 4) {
+  if (Major < 6 || (Major == 6 && Minor <= 4)) {
     m_DM->SetValidatorVersion(1, 4);
   }
 
@@ -279,9 +279,10 @@ bool DxilAnnotateWithVirtualRegister::IsAllocaRegisterWrite(
     uint32_t GEPOperandIndex = 1;
     auto *pBaseArrayIndex =
         llvm::dyn_cast<llvm::ConstantInt>(pGEP->getOperand(GEPOperandIndex++));
-    DXASSERT(pBaseArrayIndex != nullptr, "null base array index pointer");
-    DXASSERT(pBaseArrayIndex->getLimitedValue() == 0, "unexpected >0 array index");
-    pBaseArrayIndex;
+    DXASSERT_LOCALVAR(pBaseArrayIndex, pBaseArrayIndex != nullptr,
+                      "null base array index pointer");
+    DXASSERT_LOCALVAR(pBaseArrayIndex, pBaseArrayIndex->getLimitedValue() == 0,
+                      "unexpected >0 array index");
 
     // From here on, the indices always come in groups: first, the type 
     // referenced in the current struct. If that type is an (n-dimensional)

+ 1 - 1
lib/DxrFallback/Reducibility.cpp

@@ -344,7 +344,7 @@ int makeReducible(Function* F)
         if (nodes[i]->in.size() <= 1)
           continue;
 
-        if (idxMin == ~0 || nodes[i]->numInstructions < nodes[idxMin]->numInstructions)
+        if (idxMin == ~0u || nodes[i]->numInstructions < nodes[idxMin]->numInstructions)
           idxMin = i;
       }
       nodes.push_back(split(nodes[idxMin], bbToNode, numSplits == 0));

+ 1 - 1
lib/HLSL/DxilCondenseResources.cpp

@@ -1678,7 +1678,7 @@ Type *UpdateFieldTypeForLegacyLayout(Type *Ty,
       rows = matrix.Rows;
       cols = matrix.Cols;
     } else {
-      DXASSERT(matrix.Orientation == MatrixOrientation::ColumnMajor, "");
+      DXASSERT_NOMSG(matrix.Orientation == MatrixOrientation::ColumnMajor);
       cols = matrix.Rows;
       rows = matrix.Cols;
     }

+ 1 - 1
lib/HLSL/DxilLegalizeSampleOffsetPass.cpp

@@ -48,7 +48,7 @@ public:
     return "DXIL legalize sample offset";
   }
 
-  void getAnalysisUsage(AnalysisUsage &AU) const {
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.addRequired<DxilValueCache>();
     AU.setPreservesAll();
   }

+ 3 - 4
lib/HLSL/DxilNoops.cpp

@@ -225,7 +225,7 @@ static Value *GetOrCreatePreserveCond(Function *F) {
   }
 
   for (User *U : GV->users()) {
-    GEPOperator *Gep = Gep = cast<GEPOperator>(U);
+    GEPOperator *Gep = cast<GEPOperator>(U);
     for (User *GepU : Gep->users()) {
       LoadInst *LI = cast<LoadInst>(GepU);
       if (LI->getParent()->getParent() == F) {
@@ -516,9 +516,8 @@ public:
 
         DIExpression *Expr = Declare->getExpression();
         if (Expr->getNumElements() == 1 && Expr->getElement(0) == dwarf::DW_OP_deref) {
-          while (Ty &&
-            Ty->getTag() == dwarf::DW_TAG_reference_type ||
-            Ty->getTag() == dwarf::DW_TAG_restrict_type)
+          while (Ty && (Ty->getTag() == dwarf::DW_TAG_reference_type ||
+                        Ty->getTag() == dwarf::DW_TAG_restrict_type))
           {
             Ty = cast<DIDerivedType>(Ty)->getBaseType().resolve(EmptyMap);
           }

+ 1 - 1
lib/HLSL/DxilPatchShaderRecordBindings.cpp

@@ -423,7 +423,7 @@ DxilResourceBase &GetResourceFromID(DxilModule &DM, DXIL::ResourceClass resClass
         break;
     default:
         ThrowFailure();
-        return *(DxilResourceBase*)nullptr;
+        llvm_unreachable("invalid resource class");
     }
 }
 

+ 4 - 4
lib/IR/Attributes.cpp

@@ -703,7 +703,7 @@ AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index,
   }
 
   // Add target-dependent (string) attributes.
-  for (const AttrBuilder::td_type &TDA : B.td_attrs())
+  for (const auto &TDA : B.td_attrs())
     Attrs.push_back(
         std::make_pair(Index, Attribute::get(C, TDA.first, TDA.second)));
 
@@ -1263,7 +1263,7 @@ AttrBuilder &AttrBuilder::merge(const AttrBuilder &B) {
 
   Attrs |= B.Attrs;
 
-  for (auto I : B.td_attrs())
+  for (const auto &I : B.td_attrs())
     TargetDepAttrs[I.first] = I.second;
 
   return *this;
@@ -1285,7 +1285,7 @@ AttrBuilder &AttrBuilder::remove(const AttrBuilder &B) {
 
   Attrs &= ~B.Attrs;
 
-  for (auto I : B.td_attrs())
+  for (const auto &I : B.td_attrs())
     TargetDepAttrs.erase(I.first);
 
   return *this;
@@ -1297,7 +1297,7 @@ bool AttrBuilder::overlaps(const AttrBuilder &B) const {
     return true;
 
   // Then check if any target dependent ones do.
-  for (auto I : td_attrs())
+  for (const auto &I : td_attrs())
     if (B.contains(I.first))
       return true;
 

+ 1 - 1
lib/Transforms/Scalar/DxilLoopUnroll.cpp

@@ -362,7 +362,7 @@ static bool blockDominatesAnExit(BasicBlock *BB,
     if (DT.dominates(DomNode, DT.getNode(Exit)))
       return true;
   return false;
-};
+}
 
 // Copied from LCSSA.cpp
 //

+ 1 - 1
tools/clang/include/clang/Frontend/CodeGenOptions.h

@@ -224,7 +224,7 @@ public:
   /// Lookback scan limit for memory dependencies
   unsigned ScanLimit = 0;
   /// Disabled optimization passes
-  hlsl::OptimizationOptions HLSLOptimizationOptions = {0};
+  hlsl::OptimizationOptions HLSLOptimizationOptions = {};
   // HLSL Change Ends
 
   // SPIRV Change Starts

+ 3 - 3
tools/clang/include/clang/Sema/Sema.h

@@ -1504,7 +1504,6 @@ public:
     ExprResult Expr;
     TemplateName Template;
     ParsedType Type;
-    const IdentifierInfo *Keyword;
 
     explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
 
@@ -1513,8 +1512,9 @@ public:
 
     NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
 
-    NameClassification(const IdentifierInfo *Keyword)
-      : Kind(NC_Keyword), Keyword(Keyword) { }
+    NameClassification(const IdentifierInfo *)
+      : Kind(NC_Keyword) {
+    }
 
     static NameClassification Error() {
       return NameClassification(NC_Error);

+ 1 - 1
tools/clang/lib/CodeGen/CGExprScalar.cpp

@@ -1825,7 +1825,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
     // and a numeric type (scalar, vector or matrix) on the other.
     // If the aggregate type is the cast source, it should be a pointer.
     // Aggregate to aggregate casts are handled in CGExprAgg.cpp
-    auto areCompoundAndNumeric = [this](QualType lhs, QualType rhs) {
+    auto areCompoundAndNumeric = [](QualType lhs, QualType rhs) {
       return hlsl::IsHLSLAggregateType(lhs)
         && (rhs->isBuiltinType() || hlsl::IsHLSLVecMatType(rhs));
     };

+ 2 - 2
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -690,7 +690,7 @@ MDNode *CGMSHLSLRuntime::GetOrAddResTypeMD(QualType resTy, bool bCreate) {
 
 namespace {
 MatrixOrientation GetMatrixMajor(QualType Ty, bool bDefaultRowMajor) {
-  DXASSERT(hlsl::IsHLSLMatType(Ty), "");
+  DXASSERT_NOMSG(hlsl::IsHLSLMatType(Ty));
   bool bIsRowMajor = bDefaultRowMajor;
   HasHLSLMatOrientation(Ty, &bIsRowMajor);
   return bIsRowMajor ? MatrixOrientation::RowMajor
@@ -2717,7 +2717,7 @@ std::vector<StringRef> CGMSHLSLRuntime::ParseSubobjectExportsAssociations(String
     parsedExports.emplace_back(StringRef(pLast, pData - pLast));
   }
   
-  return std::move(parsedExports);
+  return parsedExports;
 }
 
 

+ 1 - 1
tools/clang/lib/Parse/HLSLRootSignature.cpp

@@ -654,7 +654,7 @@ HRESULT RootSignatureParser::ParseRootSignature(DxilVersionedRootSignatureDesc *
     {
         DxilVersionedRootSignatureDesc *pRS1 = NULL;
         try {
-          hlsl::ConvertRootSignature(pRS, m_Version, (const DxilVersionedRootSignatureDesc **)&pRS1);
+          hlsl::ConvertRootSignature(pRS, m_Version, const_cast<const DxilVersionedRootSignatureDesc **>(&pRS1));
         }
         CATCH_CPP_ASSIGN_HRESULT();
         IFC(hr);

+ 0 - 1
tools/clang/lib/Parse/ParsePragma.cpp

@@ -2199,7 +2199,6 @@ void PragmaPackMatrixHandler::HandlePragma(Preprocessor &PP,
                                            PragmaIntroducerKind Introducer,
                                            Token &Tok) {
   assert(PP.getLangOpts().HLSL && "only supported in HLSL");
-  Token PragmaName = Tok;
   PP.Lex(Tok);
   if (!Tok.is(tok::l_paren)) {
     PP.Diag(Tok, diag::err_expected) << tok::l_brace;

+ 12 - 10
tools/clang/lib/SPIRV/CapabilityVisitor.h

@@ -26,22 +26,24 @@ public:
       : Visitor(opts, spvCtx), spvBuilder(builder),
         featureManager(astCtx.getDiagnostics(), opts) {}
 
-  bool visit(SpirvDecoration *decor);
-  bool visit(SpirvEntryPoint *);
-  bool visit(SpirvExecutionMode *);
-  bool visit(SpirvImageQuery *);
-  bool visit(SpirvImageOp *);
-  bool visit(SpirvImageSparseTexelsResident *);
-  bool visit(SpirvExtInstImport *);
-  bool visit(SpirvExtInst *);
-  bool visit(SpirvDemoteToHelperInvocationEXT *);
+  bool visit(SpirvDecoration *decor) override;
+  bool visit(SpirvEntryPoint *) override;
+  bool visit(SpirvExecutionMode *) override;
+  bool visit(SpirvImageQuery *) override;
+  bool visit(SpirvImageOp *) override;
+  bool visit(SpirvImageSparseTexelsResident *) override;
+  bool visit(SpirvExtInstImport *) override;
+  bool visit(SpirvExtInst *) override;
+  bool visit(SpirvDemoteToHelperInvocationEXT *) override;
+
+  using Visitor::visit;
 
   /// The "sink" visit function for all instructions.
   ///
   /// By default, all other visit instructions redirect to this visit function.
   /// So that you want override this visit function to handle all instructions,
   /// regardless of their polymorphism.
-  bool visitInstruction(SpirvInstruction *instr);
+  bool visitInstruction(SpirvInstruction *instr) override;
 
 private:
   /// Adds necessary capabilities for using the given type.

+ 64 - 62
tools/clang/lib/SPIRV/EmitVisitor.h

@@ -199,68 +199,70 @@ public:
         lastOpWasMergeInst(false) {}
 
   // Visit different SPIR-V constructs for emitting.
-  bool visit(SpirvModule *, Phase phase);
-  bool visit(SpirvFunction *, Phase phase);
-  bool visit(SpirvBasicBlock *, Phase phase);
-
-  bool visit(SpirvCapability *);
-  bool visit(SpirvExtension *);
-  bool visit(SpirvExtInstImport *);
-  bool visit(SpirvMemoryModel *);
-  bool visit(SpirvEmitVertex *);
-  bool visit(SpirvEndPrimitive *);
-  bool visit(SpirvEntryPoint *);
-  bool visit(SpirvExecutionMode *);
-  bool visit(SpirvString *);
-  bool visit(SpirvSource *);
-  bool visit(SpirvModuleProcessed *);
-  bool visit(SpirvDecoration *);
-  bool visit(SpirvVariable *);
-  bool visit(SpirvFunctionParameter *);
-  bool visit(SpirvLoopMerge *);
-  bool visit(SpirvSelectionMerge *);
-  bool visit(SpirvBranch *);
-  bool visit(SpirvBranchConditional *);
-  bool visit(SpirvKill *);
-  bool visit(SpirvReturn *);
-  bool visit(SpirvSwitch *);
-  bool visit(SpirvUnreachable *);
-  bool visit(SpirvAccessChain *);
-  bool visit(SpirvAtomic *);
-  bool visit(SpirvBarrier *);
-  bool visit(SpirvBinaryOp *);
-  bool visit(SpirvBitFieldExtract *);
-  bool visit(SpirvBitFieldInsert *);
-  bool visit(SpirvConstantBoolean *);
-  bool visit(SpirvConstantInteger *);
-  bool visit(SpirvConstantFloat *);
-  bool visit(SpirvConstantComposite *);
-  bool visit(SpirvConstantNull *);
-  bool visit(SpirvCompositeConstruct *);
-  bool visit(SpirvCompositeExtract *);
-  bool visit(SpirvCompositeInsert *);
-  bool visit(SpirvExtInst *);
-  bool visit(SpirvFunctionCall *);
-  bool visit(SpirvNonUniformBinaryOp *);
-  bool visit(SpirvNonUniformElect *);
-  bool visit(SpirvNonUniformUnaryOp *);
-  bool visit(SpirvImageOp *);
-  bool visit(SpirvImageQuery *);
-  bool visit(SpirvImageSparseTexelsResident *);
-  bool visit(SpirvImageTexelPointer *);
-  bool visit(SpirvLoad *);
-  bool visit(SpirvCopyObject *);
-  bool visit(SpirvSampledImage *);
-  bool visit(SpirvSelect *);
-  bool visit(SpirvSpecConstantBinaryOp *);
-  bool visit(SpirvSpecConstantUnaryOp *);
-  bool visit(SpirvStore *);
-  bool visit(SpirvUnaryOp *);
-  bool visit(SpirvVectorShuffle *);
-  bool visit(SpirvArrayLength *);
-  bool visit(SpirvRayTracingOpNV *);
-  bool visit(SpirvDemoteToHelperInvocationEXT *);
-  bool visit(SpirvRayQueryOpKHR *);
+  bool visit(SpirvModule *, Phase phase) override;
+  bool visit(SpirvFunction *, Phase phase) override;
+  bool visit(SpirvBasicBlock *, Phase phase) override;
+
+  bool visit(SpirvCapability *) override;
+  bool visit(SpirvExtension *) override;
+  bool visit(SpirvExtInstImport *) override;
+  bool visit(SpirvMemoryModel *) override;
+  bool visit(SpirvEmitVertex *) override;
+  bool visit(SpirvEndPrimitive *) override;
+  bool visit(SpirvEntryPoint *) override;
+  bool visit(SpirvExecutionMode *) override;
+  bool visit(SpirvString *) override;
+  bool visit(SpirvSource *) override;
+  bool visit(SpirvModuleProcessed *) override;
+  bool visit(SpirvDecoration *) override;
+  bool visit(SpirvVariable *) override;
+  bool visit(SpirvFunctionParameter *) override;
+  bool visit(SpirvLoopMerge *) override;
+  bool visit(SpirvSelectionMerge *) override;
+  bool visit(SpirvBranch *) override;
+  bool visit(SpirvBranchConditional *) override;
+  bool visit(SpirvKill *) override;
+  bool visit(SpirvReturn *) override;
+  bool visit(SpirvSwitch *) override;
+  bool visit(SpirvUnreachable *) override;
+  bool visit(SpirvAccessChain *) override;
+  bool visit(SpirvAtomic *) override;
+  bool visit(SpirvBarrier *) override;
+  bool visit(SpirvBinaryOp *) override;
+  bool visit(SpirvBitFieldExtract *) override;
+  bool visit(SpirvBitFieldInsert *) override;
+  bool visit(SpirvConstantBoolean *) override;
+  bool visit(SpirvConstantInteger *) override;
+  bool visit(SpirvConstantFloat *) override;
+  bool visit(SpirvConstantComposite *) override;
+  bool visit(SpirvConstantNull *) override;
+  bool visit(SpirvCompositeConstruct *) override;
+  bool visit(SpirvCompositeExtract *) override;
+  bool visit(SpirvCompositeInsert *) override;
+  bool visit(SpirvExtInst *) override;
+  bool visit(SpirvFunctionCall *) override;
+  bool visit(SpirvNonUniformBinaryOp *) override;
+  bool visit(SpirvNonUniformElect *) override;
+  bool visit(SpirvNonUniformUnaryOp *) override;
+  bool visit(SpirvImageOp *) override;
+  bool visit(SpirvImageQuery *) override;
+  bool visit(SpirvImageSparseTexelsResident *) override;
+  bool visit(SpirvImageTexelPointer *) override;
+  bool visit(SpirvLoad *) override;
+  bool visit(SpirvCopyObject *) override;
+  bool visit(SpirvSampledImage *) override;
+  bool visit(SpirvSelect *) override;
+  bool visit(SpirvSpecConstantBinaryOp *) override;
+  bool visit(SpirvSpecConstantUnaryOp *) override;
+  bool visit(SpirvStore *) override;
+  bool visit(SpirvUnaryOp *) override;
+  bool visit(SpirvVectorShuffle *) override;
+  bool visit(SpirvArrayLength *) override;
+  bool visit(SpirvRayTracingOpNV *) override;
+  bool visit(SpirvDemoteToHelperInvocationEXT *) override;
+  bool visit(SpirvRayQueryOpKHR *) override;
+
+  using Visitor::visit;
 
   // Returns the assembled binary built up in this visitor.
   std::vector<uint32_t> takeBinary();

+ 24 - 22
tools/clang/lib/SPIRV/LiteralTypeVisitor.h

@@ -22,27 +22,29 @@ public:
                      const SpirvCodeGenOptions &opts)
       : Visitor(opts, spvCtx), astContext(ctx), curFnAstReturnType({}) {}
 
-  bool visit(SpirvFunction *, Phase);
-
-  bool visit(SpirvVariable *);
-  bool visit(SpirvAtomic *);
-  bool visit(SpirvUnaryOp *);
-  bool visit(SpirvBinaryOp *);
-  bool visit(SpirvBitFieldInsert *);
-  bool visit(SpirvBitFieldExtract *);
-  bool visit(SpirvSelect *);
-  bool visit(SpirvVectorShuffle *);
-  bool visit(SpirvNonUniformUnaryOp *);
-  bool visit(SpirvNonUniformBinaryOp *);
-  bool visit(SpirvStore *);
-  bool visit(SpirvConstantComposite *);
-  bool visit(SpirvCompositeConstruct *);
-  bool visit(SpirvCompositeExtract *);
-  bool visit(SpirvAccessChain *);
-  bool visit(SpirvExtInst *);
-  bool visit(SpirvReturn *);
-  bool visit(SpirvCompositeInsert *);
-  bool visit(SpirvImageOp *);
+  bool visit(SpirvFunction *, Phase) override;
+
+  bool visit(SpirvVariable *) override;
+  bool visit(SpirvAtomic *) override;
+  bool visit(SpirvUnaryOp *) override;
+  bool visit(SpirvBinaryOp *) override;
+  bool visit(SpirvBitFieldInsert *) override;
+  bool visit(SpirvBitFieldExtract *) override;
+  bool visit(SpirvSelect *) override;
+  bool visit(SpirvVectorShuffle *) override;
+  bool visit(SpirvNonUniformUnaryOp *) override;
+  bool visit(SpirvNonUniformBinaryOp *) override;
+  bool visit(SpirvStore *) override;
+  bool visit(SpirvConstantComposite *) override;
+  bool visit(SpirvCompositeConstruct *) override;
+  bool visit(SpirvCompositeExtract *) override;
+  bool visit(SpirvAccessChain *) override;
+  bool visit(SpirvExtInst *) override;
+  bool visit(SpirvReturn *) override;
+  bool visit(SpirvCompositeInsert *) override;
+  bool visit(SpirvImageOp *) override;
+
+  using Visitor::visit;
 
   // Note: We currently don't do anything to deduce literal types for the
   // following instructions:
@@ -57,7 +59,7 @@ public:
   /// By default, all other visit instructions redirect to this visit function.
   /// So that you want override this visit function to handle all instructions,
   /// regardless of their polymorphism.
-  bool visitInstruction(SpirvInstruction *instr);
+  bool visitInstruction(SpirvInstruction *instr) override;
 
 private:
   /// If the given instruction's return type is a literal type and the given

+ 6 - 4
tools/clang/lib/SPIRV/LowerTypeVisitor.h

@@ -28,16 +28,18 @@ public:
         alignmentCalc(astCtx, opts) {}
 
   // Visiting different SPIR-V constructs.
-  bool visit(SpirvModule *, Phase) { return true; }
-  bool visit(SpirvFunction *, Phase);
-  bool visit(SpirvBasicBlock *, Phase) { return true; }
+  bool visit(SpirvModule *, Phase) override { return true; }
+  bool visit(SpirvFunction *, Phase) override;
+  bool visit(SpirvBasicBlock *, Phase) override { return true; }
+
+  using Visitor::visit;
 
   /// The "sink" visit function for all instructions.
   ///
   /// By default, all other visit instructions redirect to this visit function.
   /// So that you want override this visit function to handle all instructions,
   /// regardless of their polymorphism.
-  bool visitInstruction(SpirvInstruction *instr);
+  bool visitInstruction(SpirvInstruction *instr) override;
 
 private:
   /// Emits error to the diagnostic engine associated with this visitor.

+ 10 - 8
tools/clang/lib/SPIRV/NonUniformVisitor.h

@@ -32,20 +32,22 @@ public:
       : Visitor(opts, spvCtx) {}
 
 
-  bool visit(SpirvLoad *);
-  bool visit(SpirvAccessChain *);
-  bool visit(SpirvUnaryOp *);
-  bool visit(SpirvBinaryOp *);
-  bool visit(SpirvSampledImage *);
-  bool visit(SpirvImageTexelPointer *);
-  bool visit(SpirvAtomic *);
+  bool visit(SpirvLoad *) override;
+  bool visit(SpirvAccessChain *) override;
+  bool visit(SpirvUnaryOp *) override;
+  bool visit(SpirvBinaryOp *) override;
+  bool visit(SpirvSampledImage *) override;
+  bool visit(SpirvImageTexelPointer *) override;
+  bool visit(SpirvAtomic *) override;
+
+  using Visitor::visit;
 
   /// The "sink" visit function for all instructions.
   ///
   /// By default, all other visit instructions redirect to this visit function.
   /// So that you want override this visit function to handle all instructions,
   /// regardless of their polymorphism.
-  bool visitInstruction(SpirvInstruction *instr) { return true; }
+  bool visitInstruction(SpirvInstruction *instr) override { return true; }
 
 private:
 };

+ 21 - 19
tools/clang/lib/SPIRV/PreciseVisitor.h

@@ -20,25 +20,27 @@ public:
   PreciseVisitor(SpirvContext &spvCtx, const SpirvCodeGenOptions &opts)
       : Visitor(opts, spvCtx) {}
 
-  bool visit(SpirvFunction *, Phase);
-
-  bool visit(SpirvVariable *);
-  bool visit(SpirvReturn *);
-  bool visit(SpirvSelect *);
-  bool visit(SpirvVectorShuffle *);
-  bool visit(SpirvBitFieldExtract *);
-  bool visit(SpirvBitFieldInsert *);
-  bool visit(SpirvAtomic *);
-  bool visit(SpirvCompositeConstruct *);
-  bool visit(SpirvCompositeExtract *);
-  bool visit(SpirvCompositeInsert *);
-  bool visit(SpirvLoad *);
-  bool visit(SpirvStore *);
-  bool visit(SpirvBinaryOp *);
-  bool visit(SpirvUnaryOp *);
-  bool visit(SpirvNonUniformBinaryOp *);
-  bool visit(SpirvNonUniformUnaryOp *);
-  bool visit(SpirvExtInst *);
+  bool visit(SpirvFunction *, Phase) override;
+
+  bool visit(SpirvVariable *) override;
+  bool visit(SpirvReturn *) override;
+  bool visit(SpirvSelect *) override;
+  bool visit(SpirvVectorShuffle *) override;
+  bool visit(SpirvBitFieldExtract *) override;
+  bool visit(SpirvBitFieldInsert *) override;
+  bool visit(SpirvAtomic *) override;
+  bool visit(SpirvCompositeConstruct *) override;
+  bool visit(SpirvCompositeExtract *) override;
+  bool visit(SpirvCompositeInsert *) override;
+  bool visit(SpirvLoad *) override;
+  bool visit(SpirvStore *) override;
+  bool visit(SpirvBinaryOp *) override;
+  bool visit(SpirvUnaryOp *) override;
+  bool visit(SpirvNonUniformBinaryOp *) override;
+  bool visit(SpirvNonUniformUnaryOp *) override;
+  bool visit(SpirvExtInst *) override;
+
+  using Visitor::visit;
 
   // TODO: Support propagation of 'precise' through OpSpecConstantOp and image
   // operations if necessary. Related instruction classes are:

+ 29 - 27
tools/clang/lib/SPIRV/RelaxedPrecisionVisitor.h

@@ -21,39 +21,41 @@ public:
   RelaxedPrecisionVisitor(SpirvContext &spvCtx, const SpirvCodeGenOptions &opts)
       : Visitor(opts, spvCtx) {}
 
-  bool visit(SpirvFunction *, Phase);
-
-  bool visit(SpirvVariable *);
-  bool visit(SpirvFunctionParameter *);
-  bool visit(SpirvAccessChain *);
-  bool visit(SpirvAtomic *);
-  bool visit(SpirvBitFieldExtract *);
-  bool visit(SpirvBitFieldInsert *);
-  bool visit(SpirvConstantBoolean *);
-  bool visit(SpirvConstantInteger *);
-  bool visit(SpirvConstantFloat *);
-  bool visit(SpirvConstantComposite *);
-  bool visit(SpirvCompositeConstruct *);
-  bool visit(SpirvCompositeExtract *);
-  bool visit(SpirvCompositeInsert *);
-  bool visit(SpirvExtInst *);
-  bool visit(SpirvFunctionCall *);
-  bool visit(SpirvLoad *);
-  bool visit(SpirvSelect *);
-  bool visit(SpirvStore *);
-  bool visit(SpirvSpecConstantBinaryOp *);
-  bool visit(SpirvSpecConstantUnaryOp *);
-  bool visit(SpirvBinaryOp *);
-  bool visit(SpirvUnaryOp *);
-  bool visit(SpirvVectorShuffle *);
-  bool visit(SpirvImageOp *);
+  bool visit(SpirvFunction *, Phase) override;
+
+  bool visit(SpirvVariable *) override;
+  bool visit(SpirvFunctionParameter *) override;
+  bool visit(SpirvAccessChain *) override;
+  bool visit(SpirvAtomic *) override;
+  bool visit(SpirvBitFieldExtract *) override;
+  bool visit(SpirvBitFieldInsert *) override;
+  bool visit(SpirvConstantBoolean *) override;
+  bool visit(SpirvConstantInteger *) override;
+  bool visit(SpirvConstantFloat *) override;
+  bool visit(SpirvConstantComposite *) override;
+  bool visit(SpirvCompositeConstruct *) override;
+  bool visit(SpirvCompositeExtract *) override;
+  bool visit(SpirvCompositeInsert *) override;
+  bool visit(SpirvExtInst *) override;
+  bool visit(SpirvFunctionCall *) override;
+  bool visit(SpirvLoad *) override;
+  bool visit(SpirvSelect *) override;
+  bool visit(SpirvStore *) override;
+  bool visit(SpirvSpecConstantBinaryOp *) override;
+  bool visit(SpirvSpecConstantUnaryOp *) override;
+  bool visit(SpirvBinaryOp *) override;
+  bool visit(SpirvUnaryOp *) override;
+  bool visit(SpirvVectorShuffle *) override;
+  bool visit(SpirvImageOp *) override;
+
+  using Visitor::visit;
 
   /// The "sink" visit function for all instructions.
   ///
   /// By default, all other visit instructions redirect to this visit function.
   /// So that you want override this visit function to handle all instructions,
   /// regardless of their polymorphism.
-  bool visitInstruction(SpirvInstruction *instr) { return true; }
+  bool visitInstruction(SpirvInstruction *instr) override { return true; }
 };
 
 } // end namespace spirv

+ 4 - 2
tools/clang/lib/SPIRV/RemoveBufferBlockVisitor.h

@@ -23,14 +23,16 @@ public:
                            const SpirvCodeGenOptions &opts)
       : Visitor(opts, spvCtx) {}
 
-  bool visit(SpirvModule *, Phase);
+  bool visit(SpirvModule *, Phase) override;
+
+  using Visitor::visit;
 
   /// The "sink" visit function for all instructions.
   ///
   /// By default, all other visit instructions redirect to this visit function.
   /// So that you want override this visit function to handle all instructions,
   /// regardless of their polymorphism.
-  bool visitInstruction(SpirvInstruction *instr);
+  bool visitInstruction(SpirvInstruction *instr) override;
 };
 
 } // end namespace spirv

+ 4 - 4
tools/clang/lib/SPIRV/SpirvEmitter.cpp

@@ -1167,9 +1167,9 @@ bool SpirvEmitter::validateVKAttributes(const NamedDecl *decl) {
     const auto loc = srbAttr->getLocation();
     const HLSLBufferDecl *bufDecl = nullptr;
     bool isValidType = false;
-    if (bufDecl = dyn_cast<HLSLBufferDecl>(decl))
+    if ((bufDecl = dyn_cast<HLSLBufferDecl>(decl)))
       isValidType = bufDecl->isCBuffer();
-    else if (bufDecl = dyn_cast<HLSLBufferDecl>(decl->getDeclContext()))
+    else if ((bufDecl = dyn_cast<HLSLBufferDecl>(decl->getDeclContext())))
       isValidType = bufDecl->isCBuffer();
 
     if (!isValidType) {
@@ -6165,7 +6165,7 @@ SpirvInstruction *SpirvEmitter::tryToAssignToMSOutAttrsOrIndices(
     varDecl = cast<DeclaratorDecl>(memberExpr->getMemberDecl());
   } else {
     if (const auto *arg = dyn_cast<DeclRefExpr>(base)) {
-      if (varDecl = dyn_cast<DeclaratorDecl>(arg->getDecl())) {
+      if ((varDecl = dyn_cast<DeclaratorDecl>(arg->getDecl()))) {
         if (varDecl->hasAttr<HLSLIndicesAttr>()) {
           isMSOutIndices = true;
         } else if (varDecl->hasAttr<HLSLVerticesAttr>() ||
@@ -11407,7 +11407,7 @@ SpirvEmitter::processTraceRayInline(const CXXMemberCallExpr *expr) {
   const auto accelStructure = doExpr(args[0]);
   SpirvInstruction *rayFlags = nullptr;
 
-  if (rayFlags = tryToEvaluateAsConst(args[1])) {
+  if ((rayFlags = tryToEvaluateAsConst(args[1]))) {
     rayFlags->setRValue();
   } else {
     rayFlags = doExpr(args[1]);

+ 2 - 2
tools/clang/lib/Sema/SemaHLSL.cpp

@@ -2791,7 +2791,7 @@ namespace hlsl {
       if (funcDecl) {
         if (m_sourceIt == m_callNodes.end()) {
           auto result = m_callNodes.insert(
-            std::pair<FunctionDecl*, CallNode>(m_source, CallNode{ m_source }));
+              std::make_pair(m_source, CallNode{m_source, {}}));
           DXASSERT(result.second == true,
             "else setSourceFn didn't assign m_sourceIt");
           m_sourceIt = result.first;
@@ -5447,7 +5447,7 @@ bool HLSLExternalSource::MatchArguments(
     }
 
     if (pIntrinsicArg->uLegalComponentTypes == LICOMPTYPE_USER_DEFINED_TYPE) {
-      DXASSERT(objectElement.isNull(), "");
+      DXASSERT_NOMSG(objectElement.isNull());
       QualType Ty = pCallArg->getType();
       // Must be user define type for LICOMPTYPE_USER_DEFINED_TYPE arg.
       if (TypeInfoShapeKind != AR_TOBJ_COMPOUND) {

+ 3 - 2
tools/clang/tools/dxcompiler/dxclibrary.cpp

@@ -502,8 +502,9 @@ public:
     CATCH_CPP_RETURN_HRESULT();
   }
 
-  virtual HRESULT STDMETHODCALLTYPE GetPDBContents(
-    _In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash, _COM_Outptr_ IDxcBlob **ppContainer)
+  virtual HRESULT STDMETHODCALLTYPE
+  GetPDBContents(_In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash,
+                 _COM_Outptr_ IDxcBlob **ppContainer) override
   {
     DxcThreadMalloc TM(m_pMalloc);
 

+ 1 - 1
tools/clang/tools/libclang/dxcisenseimpl.cpp

@@ -1845,7 +1845,7 @@ HRESULT DxcTranslationUnit::GetInclusionList(unsigned *pResultCount,
 
 _Use_decl_annotations_
 HRESULT DxcTranslationUnit::CodeCompleteAt(
-	char *fileName, unsigned line, unsigned column,
+	const char *fileName, unsigned line, unsigned column,
 	IDxcUnsavedFile **pUnsavedFiles, unsigned numUnsavedFiles,
 	DxcCodeCompleteFlags options, IDxcCodeCompleteResults **pResult)
 {

+ 1 - 1
tools/clang/tools/libclang/dxcisenseimpl.h

@@ -344,7 +344,7 @@ public:
       _Out_ BSTR* errorMessage) override;
     HRESULT STDMETHODCALLTYPE GetInclusionList(_Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcInclusion*** pResult) override;
     HRESULT STDMETHODCALLTYPE CodeCompleteAt(
-      _In_ char *fileName, unsigned line, unsigned column,
+      _In_ const char *fileName, unsigned line, unsigned column,
       _In_ IDxcUnsavedFile** pUnsavedFiles, unsigned numUnsavedFiles,
       _In_ DxcCodeCompleteFlags options,
       _Outptr_result_nullonfailure_ IDxcCodeCompleteResults **pResult)

+ 12 - 12
tools/clang/unittests/HLSL/DXIsenseTest.cpp

@@ -153,7 +153,7 @@ TEST_F(DXIntellisenseTest, CursorWhenCBufferRefThenFound) {
   unsigned line;
 
   CompilationResult c(CompilationResult::CreateForProgram(program, strlen(program)));
-  VERIFY_ARE_EQUAL(true, c.ParseSucceeded());
+  VERIFY_IS_TRUE(c.ParseSucceeded());
   ExpectCursorAt(c.TU, 4, 1, DxcCursor_DeclRefExpr, &varRefCursor);
   VERIFY_SUCCEEDED(c.TU->GetFile(CompilationResult::getDefaultFileName(), &file));
   VERIFY_SUCCEEDED(varRefCursor->FindReferencesInFile(file, 0, 4, refs.size_ref(), refs.data_ref()));
@@ -176,7 +176,7 @@ TEST_F(DXIntellisenseTest, CursorWhenPresumedLocationDifferentFromSpellingLocati
   unsigned presumedLine, presumedCol;
   
   CompilationResult c(CompilationResult::CreateForProgram(program, strlen(program)));
-  VERIFY_ARE_EQUAL(true, c.ParseSucceeded());
+  VERIFY_IS_TRUE(c.ParseSucceeded());
   ExpectCursorAt(c.TU, 2, 1, DxcCursor_StructDecl, &varCursor);
   VERIFY_SUCCEEDED(varCursor->GetLocation(&loc));
 
@@ -202,7 +202,7 @@ TEST_F(DXIntellisenseTest, CursorWhenPresumedLocationSameAsSpellingLocation) {
   unsigned presumedLine, presumedCol;
   
   CompilationResult c(CompilationResult::CreateForProgram(program, strlen(program)));
-  VERIFY_ARE_EQUAL(true, c.ParseSucceeded());
+  VERIFY_IS_TRUE(c.ParseSucceeded());
   ExpectCursorAt(c.TU, 1, 1, DxcCursor_StructDecl, &varCursor);
   VERIFY_SUCCEEDED(varCursor->GetLocation(&loc));
   
@@ -274,7 +274,7 @@ TEST_F(DXIntellisenseTest, InclusionWhenValidThenAvailable) {
 TEST_F(DXIntellisenseTest, TUWhenGetFileMissingThenFail) {
   const char program[] = "int i;";
   CompilationResult result = CompilationResult::CreateForProgram(program, strlen(program), nullptr);
-  VERIFY_ARE_EQUAL(true, result.ParseSucceeded());
+  VERIFY_IS_TRUE(result.ParseSucceeded());
   CComPtr<IDxcFile> file;
   VERIFY_FAILED(result.TU->GetFile("unknonwn.txt", &file));
 }
@@ -282,7 +282,7 @@ TEST_F(DXIntellisenseTest, TUWhenGetFileMissingThenFail) {
 TEST_F(DXIntellisenseTest, TUWhenGetFilePresentThenOK) {
   const char program[] = "int i;";
   CompilationResult result = CompilationResult::CreateForProgram(program, strlen(program), nullptr);
-  VERIFY_ARE_EQUAL(true, result.ParseSucceeded());
+  VERIFY_IS_TRUE(result.ParseSucceeded());
   CComPtr<IDxcFile> file;
   VERIFY_SUCCEEDED(result.TU->GetFile(CompilationResult::getDefaultFileName(), &file));
   VERIFY_IS_NOT_NULL(file.p);
@@ -299,17 +299,17 @@ TEST_F(DXIntellisenseTest, TUWhenEmptyStructThenErrorIfISense) {
   CompilationResult result15WithDef(
     CompilationResult::CreateForProgramAndArgs(programWithDef, _countof(programWithDef),
       args2015, _countof(args2015), nullptr));
-  VERIFY_ARE_EQUAL(true, result15WithDef.ParseSucceeded());
+  VERIFY_IS_TRUE(result15WithDef.ParseSucceeded());
 
   CompilationResult result15(
     CompilationResult::CreateForProgramAndArgs(program, _countof(program),
       args2015, _countof(args2015), nullptr));
-  VERIFY_ARE_EQUAL(false, result15.ParseSucceeded());
+  VERIFY_IS_FALSE(result15.ParseSucceeded());
 
   CompilationResult result16(
     CompilationResult::CreateForProgramAndArgs(program, _countof(program),
       args2016, _countof(args2016), nullptr));
-  VERIFY_ARE_EQUAL(true, result16.ParseSucceeded());
+  VERIFY_IS_TRUE(result16.ParseSucceeded());
 }
 
 TEST_F(DXIntellisenseTest, TUWhenRegionInactiveMissingThenCountIsZero) {
@@ -837,7 +837,7 @@ TEST_F(DXIntellisenseTest, TypeWhenICEThenEval)
     "float main() : SV_Target\r\n"
     "{ return c[0]; }";
   CompilationResult result(CompilationResult::CreateForProgram(program, _countof(program)));
-  VERIFY_ARE_EQUAL(true, result.ParseSucceeded());
+  VERIFY_IS_TRUE(result.ParseSucceeded());
   CComPtr<IDxcCursor> cCursor;
   ExpectCursorAt(result.TU, 1, 7, DxcCursor_VarDecl, &cCursor);
   CComPtr<IDxcType> typeCursor;
@@ -853,8 +853,8 @@ TEST_F(DXIntellisenseTest, CompletionWhenResultsAvailable)
 	"struct MyStruct {};"
 	"MyStr";
   CompilationResult result(CompilationResult::CreateForProgram(program, _countof(program)));
-  VERIFY_ARE_EQUAL(false, result.ParseSucceeded());
-  char* fileName = "filename.hlsl";
+  VERIFY_IS_FALSE(result.ParseSucceeded());
+  const char* fileName = "filename.hlsl";
   CComPtr<IDxcUnsavedFile> unsavedFile;
   VERIFY_SUCCEEDED(TrivialDxcUnsavedFile::Create(fileName, program, &unsavedFile));
   CComPtr<IDxcCodeCompleteResults> codeCompleteResults;
@@ -871,7 +871,7 @@ TEST_F(DXIntellisenseTest, CompletionWhenResultsAvailable)
   VERIFY_SUCCEEDED(completionResult->GetCompletionString(&completionString));
   unsigned numCompletionChunks;
   VERIFY_SUCCEEDED(completionString->GetNumCompletionChunks(&numCompletionChunks));
-  VERIFY_ARE_EQUAL(1, numCompletionChunks);
+  VERIFY_ARE_EQUAL(1u, numCompletionChunks);
   DxcCompletionChunkKind completionChunkKind;
   VERIFY_SUCCEEDED(completionString->GetCompletionChunkKind(0, &completionChunkKind));
   VERIFY_ARE_EQUAL(DxcCompletionChunk_TypedText, completionChunkKind);

+ 9 - 9
tools/clang/unittests/HLSL/DxilModuleTest.cpp

@@ -450,9 +450,9 @@ TEST_F(DxilModuleTest, CSGetNumThreads) {
   );
 
   DxilModule &DM = c.GetDxilModule();
-  VERIFY_ARE_EQUAL(8, DM.GetNumThreads(0));
-  VERIFY_ARE_EQUAL(4, DM.GetNumThreads(1));
-  VERIFY_ARE_EQUAL(2, DM.GetNumThreads(2));
+  VERIFY_ARE_EQUAL(8u, DM.GetNumThreads(0));
+  VERIFY_ARE_EQUAL(4u, DM.GetNumThreads(1));
+  VERIFY_ARE_EQUAL(2u, DM.GetNumThreads(2));
 }
 
 TEST_F(DxilModuleTest, MSGetNumThreads) {
@@ -472,9 +472,9 @@ TEST_F(DxilModuleTest, MSGetNumThreads) {
   );
 
   DxilModule &DM = c.GetDxilModule();
-  VERIFY_ARE_EQUAL(8, DM.GetNumThreads(0));
-  VERIFY_ARE_EQUAL(4, DM.GetNumThreads(1));
-  VERIFY_ARE_EQUAL(2, DM.GetNumThreads(2));
+  VERIFY_ARE_EQUAL(8u, DM.GetNumThreads(0));
+  VERIFY_ARE_EQUAL(4u, DM.GetNumThreads(1));
+  VERIFY_ARE_EQUAL(2u, DM.GetNumThreads(2));
 }
 
 TEST_F(DxilModuleTest, ASGetNumThreads) {
@@ -492,9 +492,9 @@ TEST_F(DxilModuleTest, ASGetNumThreads) {
   );
 
   DxilModule &DM = c.GetDxilModule();
-  VERIFY_ARE_EQUAL(8, DM.GetNumThreads(0));
-  VERIFY_ARE_EQUAL(4, DM.GetNumThreads(1));
-  VERIFY_ARE_EQUAL(2, DM.GetNumThreads(2));
+  VERIFY_ARE_EQUAL(8u, DM.GetNumThreads(0));
+  VERIFY_ARE_EQUAL(4u, DM.GetNumThreads(1));
+  VERIFY_ARE_EQUAL(2u, DM.GetNumThreads(2));
 }
 
 void DxilModuleTest::VerifyValidatorVersionFails(

+ 4 - 4
tools/clang/unittests/HLSLTestLib/DxcTestUtils.cpp

@@ -23,8 +23,8 @@
 using namespace std;
 using namespace hlsl_test;
 
-MODULE_SETUP(TestModuleSetup);
-MODULE_CLEANUP(TestModuleCleanup);
+MODULE_SETUP(TestModuleSetup)
+MODULE_CLEANUP(TestModuleCleanup)
 
 bool TestModuleSetup() {
   // Use this module-level function to set up LLVM dependencies.
@@ -252,7 +252,7 @@ std::string BlobToUtf8(_In_ IDxcBlob *pBlob) {
     if (length >= 1 && text[length-1] == '\0')
       length -= 1;  // Exclude null-terminator
     result.resize(length);
-    memcpy((void *)result.data(), text, length);
+    memcpy(&result[0], text, length);
     return result;
   } else {
     throw std::runtime_error("Unsupported codepage.");
@@ -281,7 +281,7 @@ std::wstring BlobToUtf16(_In_ IDxcBlob *pBlob) {
     if (length >= 1 && text[length-1] == L'\0')
       length -= 1;  // Exclude null-terminator
     result.resize(length);
-    memcpy((void *)result.data(), text, length);
+    memcpy(&result[0], text, length);
     return result;
   } else if (codePage == CP_UTF8) {
     const char* text = (const char *)pBlob->GetBufferPointer();