diff --git a/include/dxc/DxilContainer/DxilRuntimeReflection.h b/include/dxc/DxilContainer/DxilRuntimeReflection.h index 20b8925c8..9489c11b3 100644 --- a/include/dxc/DxilContainer/DxilRuntimeReflection.h +++ b/include/dxc/DxilContainer/DxilRuntimeReflection.h @@ -237,39 +237,19 @@ public: template class RecordTraits { public: - static constexpr const char *TypeName() { -#ifdef _WIN32 - static_assert(false, ""); -#else - assert(false); -#endif - return nullptr; - } + static constexpr const char *TypeName(); - static constexpr RuntimeDataPartType PartType() { -#ifdef _WIN32 - static_assert(false, ""); -#else - assert(false); -#endif - return RuntimeDataPartType::Invalid; - } + static constexpr RuntimeDataPartType PartType(); // If the following static assert is hit, it means a structure defined with // RDAT_STRUCT is being used in ref type, which requires the struct to have // a table and be defined with RDAT_STRUCT_TABLE instead. - static constexpr RecordTableIndex TableIndex() { -#ifdef _WIN32 - static_assert(false, ""); -#else - assert(false); -#endif - return (RecordTableIndex)-1; - } + static constexpr RecordTableIndex TableIndex(); + // RecordSize() is defined in order to allow for use of forward decl type in RecordRef - static constexpr size_t RecordSize() { /*static_assert(false, "");*/ return sizeof(_T); } + static constexpr size_t RecordSize() { return sizeof(_T); } static constexpr size_t MaxRecordSize() { return RecordTraits<_T>::DerivedRecordSize(); } - static constexpr size_t DerivedRecordSize() { return sizeof(_T); } + static constexpr size_t DerivedRecordSize(); }; /////////////////////////////////////// diff --git a/include/dxc/Test/RDATDumper.h b/include/dxc/Test/RDATDumper.h index 5db6c0586..fe35b68b6 100644 --- a/include/dxc/Test/RDATDumper.h +++ b/include/dxc/Test/RDATDumper.h @@ -44,19 +44,19 @@ void DumpWithBase(const hlsl::RDAT::RDATContext &ctx, DumpContext &d, const _Rec template class RecordRefDumper : public hlsl::RDAT::RecordRef<_RecordType> { public: - RecordRefDumper(uint32_t index) { Index = index; } + RecordRefDumper(uint32_t index) { this->Index = index; } template const char *TypeName(const hlsl::RDAT::RDATContext &ctx) const { - if (const char *name = RecordRefDumper<_DumpTy>(Index).TypeNameDerived(ctx)) + if (const char *name = RecordRefDumper<_DumpTy>(this->Index).TypeNameDerived(ctx)) return name; - RecordRef<_DumpTy> rr = { Index }; + RecordRef<_DumpTy> rr = { this->Index }; if (rr.Get(ctx)) return RecordTraits<_DumpTy>::TypeName(); return nullptr; } template void Dump(const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const { - RecordRefDumper<_DumpTy> rrDumper(Index); + RecordRefDumper<_DumpTy> rrDumper(this->Index); if (const _DumpTy *ptr = rrDumper.Get(ctx)) { static_cast< const RecordDumper<_DumpTy>* >(ptr)->Dump(ctx, d); rrDumper.DumpDerived(ctx, d); diff --git a/lib/DxcSupport/dxcapi.use.cpp b/lib/DxcSupport/dxcapi.use.cpp index f91e4314c..1b1c3a657 100644 --- a/lib/DxcSupport/dxcapi.use.cpp +++ b/lib/DxcSupport/dxcapi.use.cpp @@ -33,7 +33,7 @@ static std::string GetWin32ErrorMessage(DWORD err) { DWORD formattedMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, err, 0, formattedMsg, _countof(formattedMsg), 0); - if (formattedMsg > 0 && formattedMsgLen < _countof(formattedMsg)) { + if (formattedMsgLen > 0 && formattedMsgLen < _countof(formattedMsg)) { TrimEOL(formattedMsg); return std::string(formattedMsg); } diff --git a/lib/DxilDia/DxcPixTypes.cpp b/lib/DxilDia/DxcPixTypes.cpp index a6ae74655..5cb0881f0 100644 --- a/lib/DxilDia/DxcPixTypes.cpp +++ b/lib/DxilDia/DxcPixTypes.cpp @@ -275,7 +275,7 @@ STDMETHODIMP dxil_debug_info::DxcPixStructType::GetFieldByName( _In_ LPCWSTR lpName, _Outptr_result_z_ IDxcPixStructField **ppField) { - std::string name = CW2A(lpName); + std::string name = std::string(CW2A(lpName)); for (auto *Node : m_pStruct->getElements()) { auto* pDIField = llvm::dyn_cast(Node); diff --git a/lib/DxilDia/DxcPixVariables.cpp b/lib/DxilDia/DxcPixVariables.cpp index a48ce07dd..00cfbd9be 100644 --- a/lib/DxilDia/DxcPixVariables.cpp +++ b/lib/DxilDia/DxcPixVariables.cpp @@ -208,7 +208,7 @@ STDMETHODIMP dxil_debug_info::DxcPixDxilLiveVariables::GetVariableByName( _In_ LPCWSTR Name, _Outptr_result_z_ IDxcPixVariable **ppVariable) { - std::string name = CW2A(Name); + std::string name = std::string(CW2A(Name)); for (auto *VarInfo : m_LiveVars) { diff --git a/lib/DxilDia/DxilDiaSymbolManager.cpp b/lib/DxilDia/DxilDiaSymbolManager.cpp index 029d12388..971d0823a 100644 --- a/lib/DxilDia/DxilDiaSymbolManager.cpp +++ b/lib/DxilDia/DxilDiaSymbolManager.cpp @@ -103,7 +103,7 @@ struct DISymbol : public Symbol { template struct TypedSymbol : public DISymbol { - TypedSymbol(IMalloc *M, N Node, DWORD dwTypeID, llvm::DIType *Type) : DISymbol(M, Node), m_dwTypeID(dwTypeID), m_pType(Type) {} + TypedSymbol(IMalloc *M, N Node, DWORD dwTypeID, llvm::DIType *Type) : DISymbol(M, Node), m_dwTypeID(dwTypeID), m_pType(Type) {} STDMETHODIMP get_type( /* [retval][out] */ IDiaSymbol **ppRetVal) override { diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc index 327c76b33..8e7de6746 100644 --- a/lib/Support/Windows/Program.inc +++ b/lib/Support/Windows/Program.inc @@ -97,7 +97,7 @@ ErrorOr sys::findProgramByName(StringRef Name, return std::string(U8Result.begin(), U8Result.end()); #else - return ""; + return std::string(""); #endif } diff --git a/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h b/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h index 1f331a5de..585594285 100644 --- a/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h +++ b/projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h @@ -407,12 +407,9 @@ protected: }; vector > SwitchCases; // Switch - Scope() : Kind(Kind::Function), pPreScopeBB(nullptr), pPostScopeBB(nullptr), NameIndex(0), - pThenBB(nullptr), pElseBB(nullptr), pCond(nullptr), - pLoopBB(nullptr), ContinueIndex(0), LoopBreakIndex(0), - pDefaultBB(nullptr), pSelector(nullptr), CaseGroupIndex(0), SwitchBreakIndex(0), - LabelIdx(0), CallIdx(0), ReturnTokenOffset(0), ReturnIndex(0), bEntryFunc(false), - pHullLoopBB(nullptr), HullLoopBreakIndex(0), pInductionVar(nullptr), HullLoopTripCount(0) {} + Scope() : Kind(Kind::Function), pPreScopeBB(nullptr), pPostScopeBB(nullptr), NameIndex(0) { + memset(reinterpret_cast(&pThenBB), '\0', reinterpret_cast(&SwitchCases) - reinterpret_cast(&pThenBB)); + } void SetEntry(bool b = true) { DXASSERT_NOMSG(Kind==Function); bEntryFunc = b; } bool IsEntry() const { DXASSERT_NOMSG(Kind==Function); return bEntryFunc; } diff --git a/projects/dxilconv/lib/DxbcConverter/DxbcUtil.h b/projects/dxilconv/lib/DxbcConverter/DxbcUtil.h index 048bbb886..372db5723 100644 --- a/projects/dxilconv/lib/DxbcConverter/DxbcUtil.h +++ b/projects/dxilconv/lib/DxbcConverter/DxbcUtil.h @@ -19,12 +19,12 @@ #include "dxc/DXIL/DxilResource.h" #include "dxc/DXIL/DxilConstants.h" +#include "llvm/IR/Instructions.h" + namespace llvm { class Type; class LLVMContext; class Value; -class AtomicRMWInst; -enum AtomicRMWInst::BinOp; } #define DXASSERT_DXBC(__exp) DXASSERT(__exp, "otherwise incorrect assumption about DXBC") diff --git a/projects/dxilconv/unittests/DxilConvTests.cpp b/projects/dxilconv/unittests/DxilConvTests.cpp index a3db2ddfd..1284fc65e 100644 --- a/projects/dxilconv/unittests/DxilConvTests.cpp +++ b/projects/dxilconv/unittests/DxilConvTests.cpp @@ -188,7 +188,7 @@ TEST_F(DxilConvTest, ManualFileCheckTest) { WEX::Common::String value; VERIFY_SUCCEEDED(RuntimeParameters::TryGetValue(L"InputPath", value)); - std::wstring path = value; + std::wstring path = static_cast(value); if (!llvm::sys::path::is_absolute(CW2A(path.c_str()).m_psz)) { path = hlsl_test::GetPathToHlslDataFile(path.c_str()); } diff --git a/tools/clang/tools/dxa/dxa.cpp b/tools/clang/tools/dxa/dxa.cpp index 8fe58cb76..cd4ce9bc5 100644 --- a/tools/clang/tools/dxa/dxa.cpp +++ b/tools/clang/tools/dxa/dxa.cpp @@ -18,7 +18,7 @@ #include "dxc/Support/HLSLOptions.h" #include "dxc/DxilContainer/DxilContainer.h" #include "dxc/DxilRootSignature/DxilRootSignature.h" -#include "dxc/test/RDATDumper.h" +#include "dxc/Test/RDATDumper.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support//MSFileSystem.h" diff --git a/tools/clang/tools/dxcompiler/DXCompiler.cpp b/tools/clang/tools/dxcompiler/DXCompiler.cpp index 2101e0cb7..bfe0d7872 100644 --- a/tools/clang/tools/dxcompiler/DXCompiler.cpp +++ b/tools/clang/tools/dxcompiler/DXCompiler.cpp @@ -29,7 +29,7 @@ HRESULT SetupRegistryPassForPIX(); #ifdef LLVM_ON_WIN32 // operator new and friends. -void * __CRTDECL operator new(std::size_t size) throw(std::bad_alloc) { +void * __CRTDECL operator new(std::size_t size) noexcept(false) { void * ptr = DxcGetThreadMallocNoRef()->Alloc(size); if (ptr == nullptr) throw std::bad_alloc(); diff --git a/tools/clang/tools/dxcompiler/dxclinker.cpp b/tools/clang/tools/dxcompiler/dxclinker.cpp index dabf8a0ab..438a422ec 100644 --- a/tools/clang/tools/dxcompiler/dxclinker.cpp +++ b/tools/clang/tools/dxcompiler/dxclinker.cpp @@ -300,7 +300,7 @@ HRESULT STDMETHODCALLTYPE DxcLinker::Link( } } DiagStream.flush(); - CComPtr pStream = pDiagStream; + CComPtr pStream = static_cast>(pDiagStream); dxcutil::CreateOperationResultFromOutputs(pOutputBlob, pStream, warnings, hasErrorOccurred, ppResult); } diff --git a/tools/clang/tools/dxlib-sample/dxlib_sample.cpp b/tools/clang/tools/dxlib-sample/dxlib_sample.cpp index bab610696..370a5bcd4 100644 --- a/tools/clang/tools/dxlib-sample/dxlib_sample.cpp +++ b/tools/clang/tools/dxlib-sample/dxlib_sample.cpp @@ -21,7 +21,7 @@ using namespace hlsl; #pragma warning( disable : 4290 ) // operator new and friends. -void * __CRTDECL operator new(std::size_t size) throw(std::bad_alloc) { +void * __CRTDECL operator new(std::size_t size) noexcept(false) { void * ptr = DxcGetThreadMallocNoRef()->Alloc(size); if (ptr == nullptr) throw std::bad_alloc(); diff --git a/tools/clang/tools/dxrfallbackcompiler/DXCompiler.cpp b/tools/clang/tools/dxrfallbackcompiler/DXCompiler.cpp index b06eadb98..a31aea105 100644 --- a/tools/clang/tools/dxrfallbackcompiler/DXCompiler.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/DXCompiler.cpp @@ -23,7 +23,7 @@ namespace hlsl { HRESULT SetupRegistryPassForHLSL(); } #pragma warning( disable : 4290 ) // operator new and friends. -void * __CRTDECL operator new(std::size_t size) throw(std::bad_alloc) { +void * __CRTDECL operator new(std::size_t size) noexcept(false) { void * ptr = DxcGetThreadMallocNoRef()->Alloc(size); if (ptr == nullptr) throw std::bad_alloc(); diff --git a/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp b/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp index 882958fe1..560be6726 100644 --- a/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp +++ b/tools/clang/tools/dxrfallbackcompiler/dxcdxrfallbackcompiler.cpp @@ -331,7 +331,7 @@ HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::RenameAndLink( } DiagStream.flush(); - CComPtr pStream = pDiagStream; + CComPtr pStream = static_cast>(pDiagStream); std::string warnings; dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, hasErrors, ppResult); } @@ -415,7 +415,7 @@ HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::PatchShaderBindingTables( } DiagStream.flush(); - CComPtr pStream = pDiagStream; + CComPtr pStream = static_cast>(pDiagStream); std::string warnings; dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, false, ppResult); } @@ -574,7 +574,7 @@ HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::Link( } DiagStream.flush(); - CComPtr pStream = pDiagStream; + CComPtr pStream = static_cast>(pDiagStream); std::string warnings; dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, hasErrors, ppResult); } @@ -729,7 +729,7 @@ HRESULT STDMETHODCALLTYPE DxcDxrFallbackCompiler::Compile( } DiagStream.flush(); - CComPtr pStream = pDiagStream; + CComPtr pStream = static_cast>(pDiagStream); std::string warnings; dxcutil::CreateOperationResultFromOutputs(pResultBlob, pStream, warnings, hasErrors, ppResult); diff --git a/tools/clang/unittests/HLSL/CompilerTest.cpp b/tools/clang/unittests/HLSL/CompilerTest.cpp index 5ad1dd823..2ce9e59f2 100644 --- a/tools/clang/unittests/HLSL/CompilerTest.cpp +++ b/tools/clang/unittests/HLSL/CompilerTest.cpp @@ -1854,7 +1854,7 @@ TEST_F(CompilerTest, CompileThenTestPdbUtilsWarningOpt) { CComBSTR pMainFileName; VERIFY_SUCCEEDED(pPdbUtils->GetMainFileName(&pMainFileName)); - std::wstring mainFileName = pMainFileName; + std::wstring mainFileName = static_cast(pMainFileName); VERIFY_ARE_EQUAL(mainFileName, L"hlsl.hlsl"); }; @@ -4037,7 +4037,7 @@ TEST_F(CompilerTest, DISABLED_ManualFileCheckTest) { WEX::Common::String value; VERIFY_SUCCEEDED(RuntimeParameters::TryGetValue(L"InputPath", value)); - std::wstring path = value; + std::wstring path = static_cast(value); if (!llvm::sys::path::is_absolute(CW2A(path.c_str()).m_psz)) { path = hlsl_test::GetPathToHlslDataFile(path.c_str()); } diff --git a/tools/clang/unittests/HLSL/ExecutionTest.cpp b/tools/clang/unittests/HLSL/ExecutionTest.cpp index 36b2fb40d..778cadb75 100644 --- a/tools/clang/unittests/HLSL/ExecutionTest.cpp +++ b/tools/clang/unittests/HLSL/ExecutionTest.cpp @@ -624,7 +624,7 @@ public: void VerifyRawBufferLdStTestResults(const std::shared_ptr test, const RawBufferLdStTestData &testData); bool SetupRawBufferLdStTest(D3D_SHADER_MODEL shaderModel, RawBufferLdStType dataType, CComPtr &pDevice, - CComPtr &pStream, char *&sTy, char *&additionalOptions); + CComPtr &pStream, const char *&sTy, const char *&additionalOptions); template void RunBasicShaderModelTest(CComPtr pDevice, const char *pShaderModelStr, const char *pShader, Ty *pInputDataPairs, unsigned inputDataCount); @@ -9225,7 +9225,7 @@ TEST_F(ExecutionTest, GraphicsRawBufferLdStHalf) { bool ExecutionTest::SetupRawBufferLdStTest(D3D_SHADER_MODEL shaderModel, RawBufferLdStType dataType, CComPtr &pDevice, CComPtr &pStream, - char *&sTy, char *&additionalOptions) { + const char *&sTy, const char *&additionalOptions) { if (!CreateDevice(&pDevice, shaderModel)) { return false; } @@ -9333,7 +9333,8 @@ void ExecutionTest::RunComputeRawBufferLdStTest(D3D_SHADER_MODEL shaderModel, Ra CComPtr pDevice; CComPtr pStream; - char *sTy = nullptr, *additionalOptions = nullptr; + const char *sTy = nullptr; + const char *additionalOptions = nullptr; if (!SetupRawBufferLdStTest(shaderModel, dataType, pDevice, pStream, sTy, additionalOptions)) { return; @@ -9373,7 +9374,8 @@ void ExecutionTest::RunGraphicsRawBufferLdStTest(D3D_SHADER_MODEL shaderModel, R CComPtr pDevice; CComPtr pStream; - char *sTy = nullptr, *additionalOptions = nullptr; + const char *sTy = nullptr; + const char *additionalOptions = nullptr; if (!SetupRawBufferLdStTest(shaderModel, dataType, pDevice, pStream, sTy, additionalOptions)) { return; diff --git a/tools/clang/unittests/HLSLTestLib/RDATDumper.cpp b/tools/clang/unittests/HLSLTestLib/RDATDumper.cpp index 252af4990..c85a5c82d 100644 --- a/tools/clang/unittests/HLSLTestLib/RDATDumper.cpp +++ b/tools/clang/unittests/HLSLTestLib/RDATDumper.cpp @@ -10,7 +10,7 @@ /////////////////////////////////////////////////////////////////////////////// #include "dxc/Support/Global.h" -#include "dxc/test/RDATDumper.h" +#include "dxc/Test/RDATDumper.h" using namespace hlsl; using namespace RDAT; diff --git a/tools/dxexp/dxexp.cpp b/tools/dxexp/dxexp.cpp index d3ba7757c..6f7b79a01 100644 --- a/tools/dxexp/dxexp.cpp +++ b/tools/dxexp/dxexp.cpp @@ -152,21 +152,21 @@ typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS14 #define DXEXP_HIGHEST_SHADER_MODEL D3D_SHADER_MODEL_6_8 -static char *BoolToStrJson(bool value) { +static const char *BoolToStrJson(bool value) { return value ? "true" : "false"; } -static char *BoolToStrText(bool value) { +static const char *BoolToStrText(bool value) { return value ? "YES" : "NO"; } -static char *(*BoolToStr)(bool value); +static const char *(*BoolToStr)(bool value); static bool IsOutputJson; #define json_printf(...) if (IsOutputJson) { printf(__VA_ARGS__); } #define text_printf(...) if (!IsOutputJson) { printf(__VA_ARGS__); } -static char *ShaderModelToStr(D3D_SHADER_MODEL SM) { +static const char *ShaderModelToStr(D3D_SHADER_MODEL SM) { switch ((UINT32)SM) { case D3D_SHADER_MODEL_5_1: return "5.1"; case D3D_SHADER_MODEL_6_0: return "6.0";