Selaa lähdekoodia

Remove some warnings from GCC when building DXC (#5262)

* remove warnings on dxc

* address feedback

* remove removed functions' declarations

* get rid of another unused function

* use maybe_unused instead of if 0 when removing unused functions

* address commenting issues

* Revert "use maybe_unused instead of if 0 when removing unused functions" because c++17 extensions aren't enabled

This reverts commit 3a00d8eb844ce76b8b1f8f3f4763bb5070090c10.

* remove incorrect scope
Joshua Batista 2 vuotta sitten
vanhempi
commit
071972d7df

+ 1 - 1
lib/Analysis/DependenceAnalysis.cpp

@@ -3773,7 +3773,7 @@ DependenceAnalysis::depends(Instruction *Src, Instruction *Dst,
 
 
   auto Final = make_unique<FullDependence>(Result);
   auto Final = make_unique<FullDependence>(Result);
   Result.DV = nullptr;
   Result.DV = nullptr;
-  return std::move(Final);
+  return Final;
 }
 }
 
 
 
 

+ 12 - 3
lib/Bitcode/Reader/BitcodeReader.cpp

@@ -220,7 +220,8 @@ class BitcodeReader : public GVMaterializer {
 
 
 public:
 public:
   std::error_code error(BitcodeError E, const Twine &Message);
   std::error_code error(BitcodeError E, const Twine &Message);
-  std::error_code error(BitcodeError E);
+  // HLSL Change: Remove unused function declaration
+  // std::error_code error(BitcodeError E);
   std::error_code error(const Twine &Message);
   std::error_code error(const Twine &Message);
 
 
   BitcodeReader(std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context, // HLSL Change: unique_ptr
   BitcodeReader(std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context, // HLSL Change: unique_ptr
@@ -233,7 +234,8 @@ public:
 
 
   void freeState();
   void freeState();
 
 
-  void releaseBuffer();
+  // HLSL Change: remove unused function declaration
+  // void releaseBuffer();
 
 
   bool ShouldTrackBitstreamUsage = false; // HLSL Change
   bool ShouldTrackBitstreamUsage = false; // HLSL Change
   BitstreamUseTracker Tracker; // HLSL Change
   BitstreamUseTracker Tracker; // HLSL Change
@@ -399,10 +401,13 @@ static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
   return EC;
   return EC;
 }
 }
 
 
+// HLSL Change: remove unused function
+#if 0
 static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
 static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
                              std::error_code EC) {
                              std::error_code EC) {
   return error(DiagnosticHandler, EC, EC.message());
   return error(DiagnosticHandler, EC, EC.message());
 }
 }
+#endif
 
 
 static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
 static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
                              const Twine &Message) {
                              const Twine &Message) {
@@ -419,9 +424,12 @@ std::error_code BitcodeReader::error(const Twine &Message) {
                  make_error_code(BitcodeError::CorruptedBitcode), Message);
                  make_error_code(BitcodeError::CorruptedBitcode), Message);
 }
 }
 
 
+// HLSL Change: remove unused function
+#if 0
 std::error_code BitcodeReader::error(BitcodeError E) {
 std::error_code BitcodeReader::error(BitcodeError E) {
   return ::error(DiagnosticHandler, make_error_code(E));
   return ::error(DiagnosticHandler, make_error_code(E));
 }
 }
+#endif
 
 
 static DiagnosticHandlerFunction getDiagHandler(DiagnosticHandlerFunction F,
 static DiagnosticHandlerFunction getDiagHandler(DiagnosticHandlerFunction F,
                                                 LLVMContext &C) {
                                                 LLVMContext &C) {
@@ -4818,7 +4826,8 @@ std::error_code BitcodeReader::findFunctionInStream(
 // GVMaterializer implementation
 // GVMaterializer implementation
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
-void BitcodeReader::releaseBuffer() { Buffer.release(); }
+// HLSL Change: remove unused function 
+// void BitcodeReader::releaseBuffer() { Buffer.release(); }
 
 
 std::error_code BitcodeReader::materialize(GlobalValue *GV) {
 std::error_code BitcodeReader::materialize(GlobalValue *GV) {
   if (std::error_code EC = materializeMetadata())
   if (std::error_code EC = materializeMetadata())

+ 1 - 1
lib/DXIL/DxilCounters.cpp

@@ -60,7 +60,7 @@ PointerInfo GetPointerInfo(Value* V, PointerInfoMap &ptrInfoMap) {
              GV->getLinkage() == GlobalVariable::LinkageTypes::InternalLinkage &&
              GV->getLinkage() == GlobalVariable::LinkageTypes::InternalLinkage &&
              GV->getType()->getPointerAddressSpace() == DXIL::kDefaultAddrSpace)
              GV->getType()->getPointerAddressSpace() == DXIL::kDefaultAddrSpace)
       ptrInfoMap[V].memType = PointerInfo::MemType::Global_Static;
       ptrInfoMap[V].memType = PointerInfo::MemType::Global_Static;
-  } else if (AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
+  } else if (isa<AllocaInst>(V)) {
       ptrInfoMap[V].memType = PointerInfo::MemType::Alloca;
       ptrInfoMap[V].memType = PointerInfo::MemType::Alloca;
   } else if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
   } else if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
     ptrInfoMap[V] = GetPointerInfo(GEP->getPointerOperand(), ptrInfoMap);
     ptrInfoMap[V] = GetPointerInfo(GEP->getPointerOperand(), ptrInfoMap);

+ 1 - 1
lib/DXIL/DxilUtilDbgInfoAndMisc.cpp

@@ -124,7 +124,7 @@ bool MergeGepUse(Value *V) {
   addUsersToWorklist(V);
   addUsersToWorklist(V);
   while (worklist.size()) {
   while (worklist.size()) {
     V = worklist.pop_back_val();
     V = worklist.pop_back_val();
-    if (BitCastOperator *BCO = dyn_cast<BitCastOperator>(V)) {
+    if (isa<BitCastOperator>(V)) {
       if (Value *NewV = dxilutil::TryReplaceBaseCastWithGep(V)) {
       if (Value *NewV = dxilutil::TryReplaceBaseCastWithGep(V)) {
         changed = true;
         changed = true;
         worklist.push_back(NewV);
         worklist.push_back(NewV);

+ 5 - 3
lib/DxilPIXPasses/DxilDbgValueToDbgDeclare.cpp

@@ -588,8 +588,7 @@ GlobalStorageMap GatherGlobalEmbeddedArrayStorage(llvm::Module &M) {
       llvm::DIType *DIGVType = DIGV->getType().resolve(EmptyMap);
       llvm::DIType *DIGVType = DIGV->getType().resolve(EmptyMap);
       // We're only interested in aggregates, since only they might have
       // We're only interested in aggregates, since only they might have
       // embedded arrays:
       // embedded arrays:
-      if (auto *DIGVCompositeType =
-              llvm::dyn_cast<llvm::DICompositeType>(DIGVType)) {
+      if (isa<llvm::DICompositeType>(DIGVType)) {
         auto LocalMirrors = GenerateGlobalToLocalMirrorMap(M, DIGV);
         auto LocalMirrors = GenerateGlobalToLocalMirrorMap(M, DIGV);
         if (!LocalMirrors.empty()) {
         if (!LocalMirrors.empty()) {
           GlobalStaticVariables.push_back(DIGV);
           GlobalStaticVariables.push_back(DIGV);
@@ -789,7 +788,7 @@ static bool SortMembers(
             return false;
             return false;
         }
         }
         case llvm::dwarf::DW_TAG_subprogram: {
         case llvm::dwarf::DW_TAG_subprogram: {
-            if (auto* SubProgram = llvm::dyn_cast<llvm::DISubprogram>(Element)) {
+            if (isa<llvm::DISubprogram>(Element)) {
                 continue;
                 continue;
             }
             }
             assert(!"DISubprogram not understood");
             assert(!"DISubprogram not understood");
@@ -1456,6 +1455,8 @@ void VariableRegisters::PopulateAllocaMap_StructType(
   }
   }
 }
 }
 
 
+//HLSL Change: remove unused function
+#if 0
 llvm::DILocation *VariableRegisters::GetVariableLocation() const
 llvm::DILocation *VariableRegisters::GetVariableLocation() const
 {
 {
   const unsigned DefaultColumn = 1;
   const unsigned DefaultColumn = 1;
@@ -1465,6 +1466,7 @@ llvm::DILocation *VariableRegisters::GetVariableLocation() const
       DefaultColumn,
       DefaultColumn,
       m_Variable->getScope());
       m_Variable->getScope());
 }
 }
+#endif
 
 
 llvm::Value *VariableRegisters::GetMetadataAsValue(
 llvm::Value *VariableRegisters::GetMetadataAsValue(
     llvm::Metadata *M
     llvm::Metadata *M

+ 1 - 1
lib/DxilRootSignature/DxilRootSignatureSerializer.cpp

@@ -438,7 +438,7 @@ void DeserializeRootSignature(const void *pSrcData,
   const char *pData = (const char *)pSrcData;
   const char *pData = (const char *)pSrcData;
   IFTBOOL(pData + sizeof(uint32_t) < pData + SrcDataSizeInBytes, E_FAIL);
   IFTBOOL(pData + sizeof(uint32_t) < pData + SrcDataSizeInBytes, E_FAIL);
 
 
-  DxilRootSignatureVersion Version = (const DxilRootSignatureVersion)((const uint32_t*)pData)[0];
+  const DxilRootSignatureVersion Version = (const DxilRootSignatureVersion)((const uint32_t*)pData)[0];
 
 
   pRootSignature = new DxilVersionedRootSignatureDesc();
   pRootSignature = new DxilVersionedRootSignatureDesc();
 
 

+ 1 - 1
lib/HLSL/DxilContainerReflection.cpp

@@ -1705,7 +1705,7 @@ void DxilModuleReflection::CreateReflectionObjectForResource(DxilResourceBase *R
 static unsigned GetCBOffset(Value *V) {
 static unsigned GetCBOffset(Value *V) {
   if (ConstantInt *Imm = dyn_cast<ConstantInt>(V))
   if (ConstantInt *Imm = dyn_cast<ConstantInt>(V))
     return Imm->getLimitedValue();
     return Imm->getLimitedValue();
-  else if (UnaryInstruction *UI = dyn_cast<UnaryInstruction>(V)) {
+  else if (isa<UnaryInstruction>(V)) {
     return 0;
     return 0;
   } else if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V)) {
   } else if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V)) {
     switch (BO->getOpcode()) {
     switch (BO->getOpcode()) {

+ 5 - 5
lib/HLSL/DxilValidation.cpp

@@ -235,7 +235,7 @@ struct ValidationContext {
       DxilResourceProperties RP = resource_helper::loadPropsFromResourceBase(Res);
       DxilResourceProperties RP = resource_helper::loadPropsFromResourceBase(Res);
       ResPropMap[V] = RP;
       ResPropMap[V] = RP;
       for (User *U : V->users()) {
       for (User *U : V->users()) {
-        if (GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
+        if (isa<GEPOperator>(U)) {
           PropagateResMap(U, Res);
           PropagateResMap(U, Res);
         } else if (CallInst *CI = dyn_cast<CallInst>(U)) {
         } else if (CallInst *CI = dyn_cast<CallInst>(U)) {
           // Stop propagate on function call.
           // Stop propagate on function call.
@@ -245,7 +245,7 @@ struct ValidationContext {
                 resource_helper::loadPropsFromResourceBase(Res);
                 resource_helper::loadPropsFromResourceBase(Res);
             ResPropMap[CI] = RP;
             ResPropMap[CI] = RP;
           }
           }
-        } else if (LoadInst *LI = dyn_cast<LoadInst>(U)) {
+        } else if (isa<LoadInst>(U)) {
           PropagateResMap(U, Res);
           PropagateResMap(U, Res);
         } else if (isa<BitCastOperator>(U) && U->user_empty()) {
         } else if (isa<BitCastOperator>(U) && U->user_empty()) {
           // For hlsl type.
           // For hlsl type.
@@ -3015,13 +3015,13 @@ static void ValidateFunctionBody(Function *F, ValidationContext &ValCtx) {
       for (Value *op : I.operands()) {
       for (Value *op : I.operands()) {
         if (isa<UndefValue>(op)) {
         if (isa<UndefValue>(op)) {
           bool legalUndef = isa<PHINode>(&I);
           bool legalUndef = isa<PHINode>(&I);
-          if (InsertElementInst *InsertInst = dyn_cast<InsertElementInst>(&I)) {
+          if (isa<InsertElementInst>(&I)) {
             legalUndef = op == I.getOperand(0);
             legalUndef = op == I.getOperand(0);
           }
           }
-          if (ShuffleVectorInst *Shuf = dyn_cast<ShuffleVectorInst>(&I)) {
+          if (isa<ShuffleVectorInst>(&I)) {
             legalUndef = op == I.getOperand(1);
             legalUndef = op == I.getOperand(1);
           }
           }
-          if (StoreInst *Store = dyn_cast<StoreInst>(&I)) {
+          if (isa<StoreInst>(&I)) {
             legalUndef = op == I.getOperand(0);
             legalUndef = op == I.getOperand(0);
           }
           }
 
 

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

@@ -350,7 +350,7 @@ static unsigned IsPtrUsedByLoweredFn(
       if (IsPtrUsedByLoweredFn(user, CollectedUses))
       if (IsPtrUsedByLoweredFn(user, CollectedUses))
         bFound = true;
         bFound = true;
 
 
-    } else if (AddrSpaceCastInst *AC = dyn_cast<AddrSpaceCastInst>(user)) {
+    } else if (isa<AddrSpaceCastInst>(user)) {
       if (IsPtrUsedByLoweredFn(user, CollectedUses))
       if (IsPtrUsedByLoweredFn(user, CollectedUses))
         bFound = true;
         bFound = true;
 
 

+ 2 - 2
tools/clang/lib/AST/Type.cpp

@@ -3474,8 +3474,8 @@ bool Type::canHaveNullability() const {
   case Type::Builtin:
   case Type::Builtin:
     switch (cast<BuiltinType>(type.getTypePtr())->getKind()) {
     switch (cast<BuiltinType>(type.getTypePtr())->getKind()) {
       // Signed, unsigned, and floating-point types cannot have nullability.
       // Signed, unsigned, and floating-point types cannot have nullability.
-#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
-#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
+#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: LLVM_C_FALLTHROUGH;
+#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: LLVM_C_FALLTHROUGH;
 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define BUILTIN_TYPE(Id, SingletonId)
 #define BUILTIN_TYPE(Id, SingletonId)
 #include "clang/AST/BuiltinTypes.def"
 #include "clang/AST/BuiltinTypes.def"

+ 1 - 57
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -1518,7 +1518,7 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
   }
   }
 
 
   const ShaderModel *SM = m_pHLModule->GetShaderModel();
   const ShaderModel *SM = m_pHLModule->GetShaderModel();
-  if (auto *Attr = FD->getAttr<HLSLWaveOpsIncludeHelperLanesAttr>()) {
+  if (FD->hasAttr<HLSLWaveOpsIncludeHelperLanesAttr>()) {
     if (SM->IsSM67Plus() &&
     if (SM->IsSM67Plus() &&
         (funcProps->shaderKind == DXIL::ShaderKind::Pixel ||
         (funcProps->shaderKind == DXIL::ShaderKind::Pixel ||
          (isEntry && SM->GetKind() == DXIL::ShaderKind::Pixel)))
          (isEntry && SM->GetKind() == DXIL::ShaderKind::Pixel)))
@@ -2590,62 +2590,6 @@ hlsl::InterpolationMode CGMSHLSLRuntime::GetInterpMode(const Decl *decl,
   return Interp;
   return Interp;
 }
 }
 
 
-hlsl::CompType CGMSHLSLRuntime::GetCompType(const BuiltinType *BT) {
-
-  hlsl::CompType ElementType = hlsl::CompType::getInvalid();
-  switch (BT->getKind()) {
-  case BuiltinType::Bool:
-    ElementType = hlsl::CompType::getI1();
-    break;
-  case BuiltinType::Double:
-    ElementType = hlsl::CompType::getF64();
-    break;
-  case BuiltinType::HalfFloat: // HLSL Change
-  case BuiltinType::Float:
-    ElementType = hlsl::CompType::getF32();
-    break;
-  // HLSL Changes begin
-  case BuiltinType::Min10Float:
-  case BuiltinType::Min16Float:
-  // HLSL Changes end
-  case BuiltinType::Half:
-    ElementType = hlsl::CompType::getF16();
-    break;
-  case BuiltinType::Int:
-    ElementType = hlsl::CompType::getI32();
-    break;
-  case BuiltinType::LongLong:
-    ElementType = hlsl::CompType::getI64();
-    break;
-  // HLSL Changes begin
-  case BuiltinType::Min12Int:
-  case BuiltinType::Min16Int:
-  // HLSL Changes end
-  case BuiltinType::Short:
-    ElementType = hlsl::CompType::getI16();
-    break;
-    // HLSL Changes begin
-  case BuiltinType::Int8_4Packed:
-  case BuiltinType::UInt8_4Packed:
-    // HLSL Changes end
-  case BuiltinType::UInt:
-    ElementType = hlsl::CompType::getU32();
-    break;
-  case BuiltinType::ULongLong:
-    ElementType = hlsl::CompType::getU64();
-    break;
-  case BuiltinType::Min16UInt: // HLSL Change
-  case BuiltinType::UShort:
-    ElementType = hlsl::CompType::getU16();
-    break;
-  default:
-    llvm_unreachable("unsupported type");
-    break;
-  }
-
-  return ElementType;
-}
-
 /// Add resource to the program
 /// Add resource to the program
 void CGMSHLSLRuntime::addResource(Decl *D) {
 void CGMSHLSLRuntime::addResource(Decl *D) {
   if (HLSLBufferDecl *BD = dyn_cast<HLSLBufferDecl>(D))
   if (HLSLBufferDecl *BD = dyn_cast<HLSLBufferDecl>(D))

+ 3 - 0
tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

@@ -526,6 +526,8 @@ bool CGRecordLowering::hasOwnStorage(const CXXRecordDecl *Decl,
   return true;
   return true;
 }
 }
 
 
+// HLSL Change: Remove unused function
+#if 0
 void CGRecordLowering::calculateZeroInit() {
 void CGRecordLowering::calculateZeroInit() {
   for (std::vector<MemberInfo>::const_iterator Member = Members.begin(),
   for (std::vector<MemberInfo>::const_iterator Member = Members.begin(),
                                                MemberEnd = Members.end();
                                                MemberEnd = Members.end();
@@ -625,6 +627,7 @@ void CGRecordLowering::insertPadding() {
     Members.push_back(StorageInfo(Pad->first, getByteArrayType(Pad->second)));
     Members.push_back(StorageInfo(Pad->first, getByteArrayType(Pad->second)));
   std::stable_sort(Members.begin(), Members.end());
   std::stable_sort(Members.begin(), Members.end());
 }
 }
+#endif
 
 
 void CGRecordLowering::fillOutputFields() {
 void CGRecordLowering::fillOutputFields() {
   for (std::vector<MemberInfo>::const_iterator Member = Members.begin(),
   for (std::vector<MemberInfo>::const_iterator Member = Members.begin(),

+ 3 - 0
tools/clang/lib/Frontend/InitHeaderSearch.cpp

@@ -184,6 +184,8 @@ void InitHeaderSearch::AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
 #endif // HLSL Change Ends - simplify mapping based on actual usage
 #endif // HLSL Change Ends - simplify mapping based on actual usage
 }
 }
 
 
+// HLSL Change: Remove unused function;
+#if 0
 void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
 void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base,
                                                    StringRef ArchDir,
                                                    StringRef ArchDir,
                                                    StringRef Dir32,
                                                    StringRef Dir32,
@@ -434,6 +436,7 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp
   }
   }
 #endif // HLSL Change Ends
 #endif // HLSL Change Ends
 }
 }
+#endif
 
 
 void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
 void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
                                               const llvm::Triple &triple,
                                               const llvm::Triple &triple,

+ 7 - 5
tools/clang/lib/Parse/ParseExpr.cpp

@@ -454,16 +454,18 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
 
 
         LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
         LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
                                  OpToken.getKind(), LHS.get(), RHS.get());
                                  OpToken.getKind(), LHS.get(), RHS.get());
-      } else
+      } else {
         LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
         LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
                                          LHS.get(), TernaryMiddle.get(),
                                          LHS.get(), TernaryMiddle.get(),
                                          RHS.get());
                                          RHS.get());
-    } else
+      }
+    // HLSL Change Begin - Take care TernaryMiddle.
+    } else {
       // Ensure potential typos in the RHS aren't left undiagnosed.
       // Ensure potential typos in the RHS aren't left undiagnosed.
       Actions.CorrectDelayedTyposInExpr(RHS);
       Actions.CorrectDelayedTyposInExpr(RHS);
-      // HLSL Change Begin - Take care TernaryMiddle.
-      Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
-      // HLSL Change End.
+    }
+    Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
+    // HLSL Change End.
   }
   }
 }
 }
 
 

+ 1 - 1
tools/clang/lib/SPIRV/DebugTypeVisitor.cpp

@@ -98,7 +98,7 @@ void DebugTypeVisitor::addDebugTypeForMemberVariables(
 
 
     // Get offset (in bits) of this member within the composite.
     // Get offset (in bits) of this member within the composite.
     uint32_t offsetInBits = field.offset.hasValue()
     uint32_t offsetInBits = field.offset.hasValue()
-                                ? offsetInBits = *field.offset * 8
+                                ? *field.offset * 8
                                 : compositeSizeInBits;
                                 : compositeSizeInBits;
     // Get size (in bits) of this member within the composite.
     // Get size (in bits) of this member within the composite.
     uint32_t sizeInBits = field.sizeInBytes.hasValue()
     uint32_t sizeInBits = field.sizeInBytes.hasValue()

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

@@ -2413,7 +2413,7 @@ uint32_t EmitTypeHandler::emitType(const SpirvType *type) {
     finalizeTypeInstruction();
     finalizeTypeInstruction();
   }
   }
   // Sampler types
   // Sampler types
-  else if (const auto *samplerType = dyn_cast<SamplerType>(type)) {
+  else if (isa<SamplerType>(type)) {
     initTypeInstruction(spv::Op::OpTypeSampler);
     initTypeInstruction(spv::Op::OpTypeSampler);
     curTypeInst.push_back(id);
     curTypeInst.push_back(id);
     finalizeTypeInstruction();
     finalizeTypeInstruction();
@@ -2550,13 +2550,13 @@ uint32_t EmitTypeHandler::emitType(const SpirvType *type) {
     finalizeTypeInstruction();
     finalizeTypeInstruction();
   }
   }
   // Acceleration Structure NV type
   // Acceleration Structure NV type
-  else if (const auto *accType = dyn_cast<AccelerationStructureTypeNV>(type)) {
+  else if (isa<AccelerationStructureTypeNV>(type)) {
     initTypeInstruction(spv::Op::OpTypeAccelerationStructureNV);
     initTypeInstruction(spv::Op::OpTypeAccelerationStructureNV);
     curTypeInst.push_back(id);
     curTypeInst.push_back(id);
     finalizeTypeInstruction();
     finalizeTypeInstruction();
   }
   }
   // RayQueryType KHR type
   // RayQueryType KHR type
-  else if (const auto *rayQueryType = dyn_cast<RayQueryTypeKHR>(type)) {
+  else if (isa<RayQueryTypeKHR>(type)) {
     initTypeInstruction(spv::Op::OpTypeRayQueryKHR);
     initTypeInstruction(spv::Op::OpTypeRayQueryKHR);
     curTypeInst.push_back(id);
     curTypeInst.push_back(id);
     finalizeTypeInstruction();
     finalizeTypeInstruction();
@@ -2583,7 +2583,7 @@ uint32_t EmitTypeHandler::emitType(const SpirvType *type) {
   // Note: The type lowering pass should lower all types to SpirvTypes.
   // Note: The type lowering pass should lower all types to SpirvTypes.
   // Therefore, if we find a hybrid type when going through the emitting pass,
   // Therefore, if we find a hybrid type when going through the emitting pass,
   // that is clearly a bug.
   // that is clearly a bug.
-  else if (const auto *hybridType = dyn_cast<HybridType>(type)) {
+  else if (isa<HybridType>(type)) {
     llvm_unreachable("found hybrid type when emitting SPIR-V");
     llvm_unreachable("found hybrid type when emitting SPIR-V");
   }
   }
   // Unhandled types
   // Unhandled types

+ 2 - 2
tools/clang/lib/SPIRV/RawBufferMethods.cpp

@@ -680,7 +680,7 @@ QualType RawBufferHandler::serializeToScalarsOrStruct(
   if (isScalarType(valueType))
   if (isScalarType(valueType))
     return valueType;
     return valueType;
 
 
-  if (const auto *structType = valueType->getAs<RecordType>())
+  if (valueType->getAs<RecordType>())
     return valueType;
     return valueType;
 
 
   llvm_unreachable("unhandled type when serializing an array");
   llvm_unreachable("unhandled type when serializing an array");
@@ -741,7 +741,7 @@ void RawBufferHandler::processTemplatedStoreToBuffer(
     if (isScalarType(serializedType)) {
     if (isScalarType(serializedType)) {
       storeArrayOfScalars(elems, buffer, index, serializedType, bitOffset, loc,
       storeArrayOfScalars(elems, buffer, index, serializedType, bitOffset, loc,
                           range);
                           range);
-    } else if (const auto *structType = serializedType->getAs<RecordType>()) {
+    } else if (serializedType->getAs<RecordType>()) {
       for (auto elem : elems)
       for (auto elem : elems)
         processTemplatedStoreToBuffer(elem, buffer, index, serializedType,
         processTemplatedStoreToBuffer(elem, buffer, index, serializedType,
                                       bitOffset, range);
                                       bitOffset, range);

+ 1 - 2
tools/clang/lib/SPIRV/SpirvEmitter.cpp

@@ -930,8 +930,7 @@ void SpirvEmitter::doDecl(const Decl *decl) {
   } else if (const auto *classTemplateDecl =
   } else if (const auto *classTemplateDecl =
                  dyn_cast<ClassTemplateDecl>(decl)) {
                  dyn_cast<ClassTemplateDecl>(decl)) {
     doClassTemplateDecl(classTemplateDecl);
     doClassTemplateDecl(classTemplateDecl);
-  } else if (const auto *functionTemplateDecl =
-                 dyn_cast<FunctionTemplateDecl>(decl)) {
+  } else if (isa<FunctionTemplateDecl>(decl)) {
     // nothing to do.
     // nothing to do.
   } else {
   } else {
     emitError("decl type %0 unimplemented", decl->getLocation())
     emitError("decl type %0 unimplemented", decl->getLocation())

+ 3 - 0
tools/clang/lib/Sema/SemaCodeComplete.cpp

@@ -3063,6 +3063,7 @@ CXCursorKind clang::getCursorKindForDecl(const Decl *D) {
       switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
       switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
       case ObjCPropertyImplDecl::Dynamic:
       case ObjCPropertyImplDecl::Dynamic:
         return CXCursor_ObjCDynamicDecl;
         return CXCursor_ObjCDynamicDecl;
+        LLVM_C_FALLTHROUGH; //HLSL Change: avoid fallthrough warning
           
           
       case ObjCPropertyImplDecl::Synthesize:
       case ObjCPropertyImplDecl::Synthesize:
         return CXCursor_ObjCSynthesizeDecl;
         return CXCursor_ObjCSynthesizeDecl;
@@ -3070,8 +3071,10 @@ CXCursorKind clang::getCursorKindForDecl(const Decl *D) {
 
 
       case Decl::Import:
       case Decl::Import:
         return CXCursor_ModuleImportDecl;
         return CXCursor_ModuleImportDecl;
+        LLVM_C_FALLTHROUGH; //HLSL Change: avoid fallthrough warning
 
 
     case Decl::ObjCTypeParam:   return CXCursor_TemplateTypeParameter;
     case Decl::ObjCTypeParam:   return CXCursor_TemplateTypeParameter;
+    LLVM_C_FALLTHROUGH; //HLSL Change: avoid fallthrough warning
 
 
     default:
     default:
       if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
       if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {

+ 6 - 2
tools/clang/unittests/SPIRV/FileTestFixture.cpp

@@ -129,10 +129,12 @@ void FileTest::checkTestResult(llvm::StringRef filename, const bool compileOk,
     // All checks must have passed.
     // All checks must have passed.
     ASSERT_EQ(result.status(), effcee::Result::Status::Ok);
     ASSERT_EQ(result.status(), effcee::Result::Status::Ok);
 
 
-    if (runValidation)
+    // HLSL Change: Explicit braces
+    if (runValidation) {
       EXPECT_TRUE(utils::validateSpirvBinary(targetEnv, generatedBinary,
       EXPECT_TRUE(utils::validateSpirvBinary(targetEnv, generatedBinary,
                                              beforeHLSLLegalization, glLayout,
                                              beforeHLSLLegalization, glLayout,
                                              dxLayout, scalarLayout));
                                              dxLayout, scalarLayout));
+    }
   } else if (expect == Expect::Warning) {
   } else if (expect == Expect::Warning) {
     ASSERT_TRUE(compileOk);
     ASSERT_TRUE(compileOk);
 
 
@@ -155,10 +157,12 @@ void FileTest::checkTestResult(llvm::StringRef filename, const bool compileOk,
     // All checks must have passed.
     // All checks must have passed.
     ASSERT_EQ(result.status(), effcee::Result::Status::Ok);
     ASSERT_EQ(result.status(), effcee::Result::Status::Ok);
 
 
-    if (runValidation)
+    // HLSL Change: explicit braces
+    if (runValidation) {
       EXPECT_TRUE(utils::validateSpirvBinary(targetEnv, generatedBinary,
       EXPECT_TRUE(utils::validateSpirvBinary(targetEnv, generatedBinary,
                                              beforeHLSLLegalization, glLayout,
                                              beforeHLSLLegalization, glLayout,
                                              dxLayout, scalarLayout));
                                              dxLayout, scalarLayout));
+    }
   } else if (expect == Expect::Failure) {
   } else if (expect == Expect::Failure) {
     ASSERT_FALSE(compileOk);
     ASSERT_FALSE(compileOk);