From 67fde166276257eb67fcce263e8b57a4151b726a Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Thu, 14 Sep 2023 13:25:46 -0400 Subject: [PATCH] [CLANG_CL] Fix clang-cl warnings (#5660) Add -Wno-unused-parameter -Wno-unknown-pragams -Wno-switch which are enabled for clang in linux build. Fix -Wimplicit-fallthrough -Wconstant-logical-operand (Thanks patch from Chris) -Wunused-function -Wunused-variable -Wtrigraphs -Wnonportable-include-path Still more warnings to be fixed. --- cmake/modules/HandleLLVMOptions.cmake | 17 ++ include/llvm/Support/Compiler.h | 2 + lib/DxilDia/DxcPixDxilDebugInfo.cpp | 4 +- lib/DxilDia/DxilDiaSymbolManager.cpp | 1 - lib/Support/ConvertUTF.c | 2 +- lib/Support/Windows/MSFileSystem.inc.cpp | 1 + lib/Support/Windows/Process.inc | 2 +- lib/Support/regcomp.c | 18 +- .../DxilConvPasses/ScopeNestIterator.h | 4 +- .../include/ShaderBinary/ShaderBinary.h | 18 +- .../lib/DxilConvPasses/NormalizeDxil.cpp | 2 +- .../lib/ShaderBinary/ShaderBinary.cpp | 34 +-- .../lib/ShaderBinary/ShaderBinaryIncludes.h | 2 +- projects/dxilconv/unittests/DxilConvTests.cpp | 6 +- .../include/clang/Basic/LangOptions.fixed.def | 230 ++++++++++-------- tools/clang/include/clang/Basic/LangOptions.h | 1 + tools/clang/lib/Basic/LangOptions.cpp | 1 + tools/clang/lib/Sema/SemaHLSL.cpp | 2 +- tools/clang/lib/Serialization/ASTReader.cpp | 4 + tools/clang/lib/Serialization/ASTWriter.cpp | 2 + .../DxrFallback/test_DxrFallback.cpp | 2 +- tools/clang/unittests/HLSL/CompilerTest.cpp | 4 +- tools/clang/unittests/HLSL/MSFileSysTest.cpp | 31 ++- .../unittests/HLSLExec/ExecutionTest.cpp | 5 - .../clang/unittests/HLSLExec/ShaderOpTest.cpp | 2 +- tools/clang/unittests/HLSLHost/HLSLHost.cpp | 2 + 26 files changed, 231 insertions(+), 168 deletions(-) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 57ea20f93..4f425b1e6 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -363,6 +363,23 @@ if( MSVC ) if (LLVM_ENABLE_PEDANTIC) # No MSVC equivalent available endif (LLVM_ENABLE_PEDANTIC) + + if (CLANG_CL) + append("-Wall -W -Wno-unused-parameter -Wwrite-strings -Wimplicit-fallthrough" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wcast-qual" CMAKE_CXX_FLAGS) + + # Disable unknown pragma warnings because the output is just too long with them. + append("-Wno-unknown-pragmas" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + + add_flag_if_supported("-Wno-unused-but-set-variable" UNUSED_BUT_SET_VARIABLE) + append("-Wno-switch" CMAKE_CXX_FLAGS) + + append("-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + + # enable warnings explicitly. + append("-Wnonportable-include-path -Wunused-function" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-Wtrigraphs -Wconstant-logical-operand -Wunused-variable" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + endif (CLANG_CL) endif (LLVM_ENABLE_WARNINGS) if (LLVM_ENABLE_WERROR) append("/WX" msvc_warning_flags) diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 6670dd4cf..bb2217550 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -233,6 +233,8 @@ #if defined(_MSC_VER) #if __cplusplus > 201402L #define LLVM_C_FALLTHROUGH [[fallthrough]] +#elif __has_attribute(fallthrough) +#define LLVM_C_FALLTHROUGH __attribute__((fallthrough)) #else #define LLVM_C_FALLTHROUGH #endif diff --git a/lib/DxilDia/DxcPixDxilDebugInfo.cpp b/lib/DxilDia/DxcPixDxilDebugInfo.cpp index 88bcbc115..babb311db 100644 --- a/lib/DxilDia/DxcPixDxilDebugInfo.cpp +++ b/lib/DxilDia/DxcPixDxilDebugInfo.cpp @@ -22,7 +22,7 @@ #include "DxcPixLiveVariables.h" #include "DxcPixDxilDebugInfo.h" #include "DxcPixBase.h" -#include "dxc/DxilPixPasses/DxilPixVirtualRegisters.h" +#include "dxc/DxilPIXPasses/DxilPIXVirtualRegisters.h" STDMETHODIMP dxil_debug_info::DxcPixDxilDebugInfo::GetLiveVariablesAt( DWORD InstructionOffset, IDxcPixDxilLiveVariables **ppLiveVariables) { @@ -58,7 +58,7 @@ dxil_debug_info::DxcPixDxilDebugInfo::GetFunctionName(DWORD InstructionOffset, } } - *ppFunctionName = CComBSTR(L"").Detach(); + *ppFunctionName = CComBSTR(L"<\?\?\?>").Detach(); return S_FALSE; } diff --git a/lib/DxilDia/DxilDiaSymbolManager.cpp b/lib/DxilDia/DxilDiaSymbolManager.cpp index 17b64b932..8cdc69d5b 100644 --- a/lib/DxilDia/DxilDiaSymbolManager.cpp +++ b/lib/DxilDia/DxilDiaSymbolManager.cpp @@ -1070,7 +1070,6 @@ STDMETHODIMP dxil_dia::hlsl_symbols::LocalVariableSymbol::get_sizeInUdt( return E_INVALIDARG; } - static constexpr DWORD kBitsPerByte = 8; //auto *DT = llvm::cast(m_pType); *pRetVal = 4; //DT->getSizeInBits() / kBitsPerByte; return S_OK; diff --git a/lib/Support/ConvertUTF.c b/lib/Support/ConvertUTF.c index 9d6f83fb1..ceb2137c9 100644 --- a/lib/Support/ConvertUTF.c +++ b/lib/Support/ConvertUTF.c @@ -48,7 +48,7 @@ #include "llvm/Support/ConvertUTF.h" -#include "llvm/Support/Compiler.h" // HLSL Change - for LLVM_FALLTHROUGH +#include "llvm/Support/Compiler.h" // HLSL Change - for LLVM_C_FALLTHROUGH #ifdef CVTUTF_DEBUG #include #endif diff --git a/lib/Support/Windows/MSFileSystem.inc.cpp b/lib/Support/Windows/MSFileSystem.inc.cpp index 49fbda05e..48f3f1fbd 100644 --- a/lib/Support/Windows/MSFileSystem.inc.cpp +++ b/lib/Support/Windows/MSFileSystem.inc.cpp @@ -539,6 +539,7 @@ std::error_code access(const Twine &Path, AccessMode Mode) { return std::error_code(); default: assert(Mode == AccessMode::Write && "no other enum value allowed"); + LLVM_FALLTHROUGH; case AccessMode::Write: return !(Attr & FILE_ATTRIBUTE_READONLY) ? std::error_code() : make_error_code(std::errc::permission_denied); diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index 87957b4d0..d2eb3abec 100644 --- a/lib/Support/Windows/Process.inc +++ b/lib/Support/Windows/Process.inc @@ -156,6 +156,7 @@ Optional Process::GetEnv(StringRef Name) { return std::string(Res.data()); } +#if 0 // HLSL Change - comment out unused function. static void AllocateAndPush(const SmallVectorImpl &S, SmallVectorImpl &Vector, SpecificBumpPtrAllocator &Allocator) { @@ -176,7 +177,6 @@ ConvertAndPushArg(const wchar_t *Arg, SmallVectorImpl &Args, return std::error_code(); } -#if 0 // HLSL Change - comment out unused function. /// \brief Perform wildcard expansion of Arg, or just push it into Args if it /// doesn't have wildcards or doesn't match any files. static std::error_code diff --git a/lib/Support/regcomp.c b/lib/Support/regcomp.c index 002521a2e..f8c179000 100644 --- a/lib/Support/regcomp.c +++ b/lib/Support/regcomp.c @@ -63,8 +63,8 @@ * other clumsinesses */ struct parse { - char *next; /* next character in RE */ - char *end; /* end of string (-> NUL normally) */ + const char *next; /* next character in RE */ + const char *end; /* end of string (-> NUL normally) */ int error; /* has an error been seen? */ sop *strip; /* malloced strip */ sopno ssize; /* malloced strip size (allocated) */ @@ -202,7 +202,7 @@ llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags) /* set things up */ p->g = g; - p->next = (char *)pattern; /* convenience; we do not modify it */ + p->next = pattern; /* convenience; we do not modify it */ p->end = p->next + len; p->error = 0; p->ncsalloc = 0; @@ -813,7 +813,7 @@ p_b_term(struct parse *p, cset *cs) static void p_b_cclass(struct parse *p, cset *cs) { - char *sp = p->next; + const char *sp = p->next; struct cclass *cp; size_t len; const char *u; @@ -877,7 +877,7 @@ static char /* value of collating element */ p_b_coll_elem(struct parse *p, int endc) /* name ended by endc,']' */ { - char *sp = p->next; + const char *sp = p->next; struct cname *cp; int len; @@ -921,8 +921,8 @@ othercase(int ch) static void bothcases(struct parse *p, int ch) { - char *oldnext = p->next; - char *oldend = p->end; + const char *oldnext = p->next; + const char *oldend = p->end; char bracket[3]; ch = (uch)ch; @@ -963,8 +963,8 @@ ordinary(struct parse *p, int ch) static void nonnewline(struct parse *p) { - char *oldnext = p->next; - char *oldend = p->end; + const char *oldnext = p->next; + const char *oldend = p->end; char bracket[4]; p->next = bracket; diff --git a/projects/dxilconv/include/DxilConvPasses/ScopeNestIterator.h b/projects/dxilconv/include/DxilConvPasses/ScopeNestIterator.h index 722dda444..e93746df1 100644 --- a/projects/dxilconv/include/DxilConvPasses/ScopeNestIterator.h +++ b/projects/dxilconv/include/DxilConvPasses/ScopeNestIterator.h @@ -985,8 +985,8 @@ private: // ScopeNestIterator Implementation } void StartNewScope(Block *startOfScopeBlock, BranchKind startOfScopeKind) { - Scope::Type scopeType; - ScopeNestEvent::Type nestType; + Scope::Type scopeType = Scope::Type::TopLevel; + ScopeNestEvent::Type nestType = ScopeNestEvent::Type::Invalid; switch (startOfScopeKind) { case BranchKind::IfBegin: case BranchKind::IfNoEnd: diff --git a/projects/dxilconv/include/ShaderBinary/ShaderBinary.h b/projects/dxilconv/include/ShaderBinary/ShaderBinary.h index 33b8c47f9..25c83e99d 100644 --- a/projects/dxilconv/include/ShaderBinary/ShaderBinary.h +++ b/projects/dxilconv/include/ShaderBinary/ShaderBinary.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // // -// ShaderBinary.h // +// ShaderBinary.h // // Copyright (C) Microsoft Corporation. All rights reserved. // // This file is distributed under the University of Illinois Open Source // // License. See LICENSE.TXT for details. // @@ -2579,12 +2579,12 @@ public: CONST CShaderToken* pBuffer, CONST CShaderToken* pBufferEnd) { - CShaderToken* pCurTok = m_pCurrentToken; - CShaderToken* pEndTok = m_pShaderEndToken; - CShaderToken* pRet; + const CShaderToken *pCurTok = m_pCurrentToken; + const CShaderToken *pEndTok = m_pShaderEndToken; + const CShaderToken *pRet; - m_pCurrentToken = (CShaderToken*)pBuffer; - m_pShaderEndToken = (CShaderToken*)pBufferEnd; + m_pCurrentToken = (pBuffer); + m_pShaderEndToken = (pBufferEnd); ParseOperand(pOperand); pRet = m_pCurrentToken; @@ -2596,10 +2596,10 @@ public: } protected: - CShaderToken* m_pCurrentToken; - CShaderToken* m_pShaderCode; + const CShaderToken* m_pCurrentToken; + const CShaderToken* m_pShaderCode; // Points to the last token of the current shader - CShaderToken* m_pShaderEndToken; + const CShaderToken* m_pShaderEndToken; }; }; // name space D3D10ShaderBinary diff --git a/projects/dxilconv/lib/DxilConvPasses/NormalizeDxil.cpp b/projects/dxilconv/lib/DxilConvPasses/NormalizeDxil.cpp index 915f6d464..5dd4c3987 100644 --- a/projects/dxilconv/lib/DxilConvPasses/NormalizeDxil.cpp +++ b/projects/dxilconv/lib/DxilConvPasses/NormalizeDxil.cpp @@ -20,7 +20,7 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/Dominators.h" -#include "dxc/DXIL/DXILOperations.h" +#include "dxc/DXIL/DxilOperations.h" #include "dxc/DXIL/DxilInstructions.h" #include diff --git a/projects/dxilconv/lib/ShaderBinary/ShaderBinary.cpp b/projects/dxilconv/lib/ShaderBinary/ShaderBinary.cpp index ddfc21a80..b13c36abe 100644 --- a/projects/dxilconv/lib/ShaderBinary/ShaderBinary.cpp +++ b/projects/dxilconv/lib/ShaderBinary/ShaderBinary.cpp @@ -11,6 +11,7 @@ // HLSL change start #include "ShaderBinaryIncludes.h" +#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH // HLSL change end /*==========================================================================; @@ -297,10 +298,10 @@ void InitInstructionInfo() void CShaderCodeParser::SetShader(CONST CShaderToken* pBuffer) { - m_pShaderCode = (CShaderToken*)pBuffer; - m_pShaderEndToken = (CShaderToken*)pBuffer + pBuffer[1]; + m_pShaderCode = pBuffer; + m_pShaderEndToken = pBuffer + pBuffer[1]; // First OpCode token - m_pCurrentToken = (CShaderToken*)&pBuffer[2]; + m_pCurrentToken = &pBuffer[2]; } D3D10_SB_TOKENIZED_PROGRAM_TYPE CShaderCodeParser::ShaderType() @@ -482,8 +483,8 @@ void CShaderCodeParser::ParseOperand(COperandBase* pOperand) void CShaderCodeParser::ParseInstruction(CInstruction* pInstruction) { pInstruction->Clear(true); - CShaderToken* pStart = m_pCurrentToken; - CShaderToken Token = *m_pCurrentToken++; + const CShaderToken *pStart = m_pCurrentToken; + const CShaderToken Token = *m_pCurrentToken++; pInstruction->m_OpCode = DECODE_D3D10_SB_OPCODE_TYPE(Token); pInstruction->m_PreciseMask = DECODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(Token); pInstruction->m_bSaturate = DECODE_IS_D3D10_SB_INSTRUCTION_SATURATE_ENABLED(Token); @@ -888,22 +889,22 @@ void CShaderCodeParser::ParseInstruction(CInstruction* pInstruction) break; case D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR: - pInstruction->m_HSMaxTessFactorDecl.MaxTessFactor = *(float*)m_pCurrentToken; + pInstruction->m_HSMaxTessFactorDecl.MaxTessFactor = *(const float*)m_pCurrentToken; m_pCurrentToken++; break; case D3D11_SB_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT: - pInstruction->m_HSForkPhaseInstanceCountDecl.InstanceCount = *(UINT*)m_pCurrentToken; + pInstruction->m_HSForkPhaseInstanceCountDecl.InstanceCount = *(const UINT*)m_pCurrentToken; m_pCurrentToken++; break; case D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT: - pInstruction->m_HSJoinPhaseInstanceCountDecl.InstanceCount = *(UINT*)m_pCurrentToken; + pInstruction->m_HSJoinPhaseInstanceCountDecl.InstanceCount = *(const UINT*)m_pCurrentToken; m_pCurrentToken++; break; case D3D11_SB_OPCODE_DCL_THREAD_GROUP: - pInstruction->m_ThreadGroupDecl.x = *(UINT*)m_pCurrentToken++; - pInstruction->m_ThreadGroupDecl.y = *(UINT*)m_pCurrentToken++; - pInstruction->m_ThreadGroupDecl.z = *(UINT*)m_pCurrentToken++; + pInstruction->m_ThreadGroupDecl.x = *(const UINT*)m_pCurrentToken++; + pInstruction->m_ThreadGroupDecl.y = *(const UINT*)m_pCurrentToken++; + pInstruction->m_ThreadGroupDecl.z = *(const UINT*)m_pCurrentToken++; break; case D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED: pInstruction->m_TypedUAVDecl.Dimension = DECODE_D3D10_SB_RESOURCE_DIMENSION(Token); @@ -932,7 +933,7 @@ void CShaderCodeParser::ParseInstruction(CInstruction* pInstruction) case D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED: pInstruction->m_StructuredUAVDecl.Flags = DECODE_D3D11_SB_RESOURCE_FLAGS(Token); ParseOperand(&pInstruction->m_Operands[0]); - pInstruction->m_StructuredUAVDecl.ByteStride = *(UINT*)m_pCurrentToken++; + pInstruction->m_StructuredUAVDecl.ByteStride = *(const UINT*)m_pCurrentToken++; pInstruction->m_StructuredUAVDecl.Space = 0; if(b51PlusShader) { @@ -941,12 +942,12 @@ void CShaderCodeParser::ParseInstruction(CInstruction* pInstruction) break; case D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW: ParseOperand(&pInstruction->m_Operands[0]); - pInstruction->m_RawTGSMDecl.ByteCount = *(UINT*)m_pCurrentToken++; + pInstruction->m_RawTGSMDecl.ByteCount = *(const UINT*)m_pCurrentToken++; break; case D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED: ParseOperand(&pInstruction->m_Operands[0]); - pInstruction->m_StructuredTGSMDecl.StructByteStride = *(UINT*)m_pCurrentToken++; - pInstruction->m_StructuredTGSMDecl.StructCount = *(UINT*)m_pCurrentToken++; + pInstruction->m_StructuredTGSMDecl.StructByteStride = *(const UINT*)m_pCurrentToken++; + pInstruction->m_StructuredTGSMDecl.StructCount = *(const UINT*)m_pCurrentToken++; break; case D3D11_SB_OPCODE_DCL_RESOURCE_RAW: ParseOperand(&pInstruction->m_Operands[0]); @@ -958,7 +959,7 @@ void CShaderCodeParser::ParseInstruction(CInstruction* pInstruction) break; case D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED: ParseOperand(&pInstruction->m_Operands[0]); - pInstruction->m_StructuredSRVDecl.ByteStride = *(UINT*)m_pCurrentToken++; + pInstruction->m_StructuredSRVDecl.ByteStride = *(const UINT*)m_pCurrentToken++; pInstruction->m_StructuredSRVDecl.Space = 0; if(b51PlusShader) { @@ -1120,6 +1121,7 @@ void CShaderAsm::EmitOperand(const COperandBase& operand) case D3D10_SB_OPERAND_INDEX_IMMEDIATE32_PLUS_RELATIVE: FUNC(operand.m_Index[i].m_RegIndex); // Fall through + LLVM_FALLTHROUGH; case D3D10_SB_OPERAND_INDEX_RELATIVE: { D3D10_SB_OPERAND_TYPE RelRegType = operand.m_Index[i].m_RelRegType; diff --git a/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h b/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h index 47f166479..360230b8d 100644 --- a/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h +++ b/projects/dxilconv/lib/ShaderBinary/ShaderBinaryIncludes.h @@ -20,7 +20,7 @@ #include #define D3DX12_NO_STATE_OBJECT_HELPERS #include "dxc/Support/d3dx12.h" -#include "dxc/Support/D3D12TokenizedProgramFormat.hpp" +#include "dxc/Support/d3d12TokenizedProgramFormat.hpp" #include "ShaderBinary/ShaderBinary.h" // clang-format on diff --git a/projects/dxilconv/unittests/DxilConvTests.cpp b/projects/dxilconv/unittests/DxilConvTests.cpp index 233a8a277..a23a605d4 100644 --- a/projects/dxilconv/unittests/DxilConvTests.cpp +++ b/projects/dxilconv/unittests/DxilConvTests.cpp @@ -26,9 +26,9 @@ #include "dxc/dxcapi.h" #include -#include "dxc/test/HLSLTestData.h" -#include "dxc/test/HlslTestUtils.h" -#include "dxc/test/DxcTestUtils.h" +#include "dxc/Test/HLSLTestData.h" +#include "dxc/Test/HlslTestUtils.h" +#include "dxc/Test/DxcTestUtils.h" #include "llvm/Support/raw_os_ostream.h" #include "dxc/Support/Global.h" diff --git a/tools/clang/include/clang/Basic/LangOptions.fixed.def b/tools/clang/include/clang/Basic/LangOptions.fixed.def index a1da37bf8..351eb3b9a 100644 --- a/tools/clang/include/clang/Basic/LangOptions.fixed.def +++ b/tools/clang/include/clang/Basic/LangOptions.fixed.def @@ -45,6 +45,21 @@ COMPATIBLE_LANGOPT(Name, Bits, Default, Description) #endif +#ifndef COMPATIBLE_LANGOPT_BOOL +# define COMPATIBLE_LANGOPT_BOOL(Name, Default, Description) \ + LANGOPT_BOOL(Name, Default, Description) +#endif + +#ifndef BENIGN_LANGOPT_BOOL +# define BENIGN_LANGOPT_BOOL(Name, Default, Description) \ + COMPATIBLE_LANGOPT_BOOL(Name, Default, Description) +#endif + +// add default LANGOPT_BOOL. +#ifndef LANGOPT_BOOL + #define LANGOPT_BOOL(Name, Default, Description) +#endif + #ifndef ENUM_LANGOPT # define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ LANGOPT(Name, Bits, Default, Description) @@ -68,135 +83,135 @@ // FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead. LANGOPT(C99 , 1, 0, "C99") LANGOPT(C11 , 1, 0, "C11") -LANGOPT(MSVCCompat , 1, 0, "Microsoft Visual C++ full compatibility mode") -LANGOPT(MicrosoftExt , 1, 0, "Microsoft C++ extensions") -LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks") -LANGOPT(Borland , 1, 0, "Borland extensions") -LANGOPT(CPlusPlus , 1, 1, "C++") -LANGOPT(CPlusPlus11 , 1, 0, "C++11") +LANGOPT_BOOL(MSVCCompat, 0, "Microsoft Visual C++ full compatibility mode") +LANGOPT_BOOL(MicrosoftExt, 0, "Microsoft C++ extensions") +LANGOPT_BOOL(AsmBlocks, 0, "Microsoft inline asm blocks") +LANGOPT_BOOL(Borland, 0, "Borland extensions") +LANGOPT_BOOL(CPlusPlus, 1, "C++") +LANGOPT_BOOL(CPlusPlus11, 0, "C++11") LANGOPT(CPlusPlus14 , 1, 0, "C++14") LANGOPT(CPlusPlus1z , 1, 0, "C++1z") LANGOPT(ObjC1 , 1, 0, "Objective-C 1") LANGOPT(ObjC2 , 1, 0, "Objective-C 2") -BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, +BENIGN_LANGOPT_BOOL(ObjCDefaultSynthProperties, 0, "Objective-C auto-synthesized properties") -BENIGN_LANGOPT(EncodeExtendedBlockSig , 1, 0, +BENIGN_LANGOPT_BOOL(EncodeExtendedBlockSig, 0, "Encoding extended block type signature") -BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1, +BENIGN_LANGOPT_BOOL(ObjCInferRelatedResultType, 1, "Objective-C related result type inference") -LANGOPT(AppExt , 1, 0, "Objective-C App Extension") -LANGOPT(Trigraphs , 1, 0,"trigraphs") -LANGOPT(LineComment , 1, 1, "'//' comments") -LANGOPT(Bool , 1, 1, "bool, true, and false keywords") -LANGOPT(Half , 1, 0, "half keyword") -LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword") -BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers") -BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode") -BENIGN_LANGOPT(GNUMode , 1, 0, "GNU extensions") -LANGOPT(GNUKeywords , 1, 0, "GNU keywords") -BENIGN_LANGOPT(ImplicitInt, 1, !C99 && !CPlusPlus, "C89 implicit 'int'") -LANGOPT(Digraphs , 1, 0, "digraphs") -BENIGN_LANGOPT(HexFloats , 1, C99, "C99 hexadecimal float constants") -LANGOPT(CXXOperatorNames , 1, 0, "C++ operator name keywords") -LANGOPT(AppleKext , 1, 0, "Apple kext support") -BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support") -LANGOPT(WritableStrings , 1, 0, "writable string support") -LANGOPT(ConstStrings , 1, 0, "const-qualified string support") -LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions") -LANGOPT(AltiVec , 1, 0, "AltiVec-style vector initializers") -LANGOPT(ZVector , 1, 0, "System z vector extensions") -LANGOPT(Exceptions , 1, 0, "exception handling") -LANGOPT(ObjCExceptions , 1, 0, "Objective-C exceptions") -LANGOPT(CXXExceptions , 1, 0, "C++ exceptions") -LANGOPT(SjLjExceptions , 1, 0, "setjmp-longjump exception handling") -LANGOPT(TraditionalCPP , 1, 0, "traditional CPP emulation") -LANGOPT(RTTI , 1, 0, "run-time type information") -LANGOPT(RTTIData , 1, 0, "emit run-time type information data") -LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout") -LANGOPT(Freestanding, 1, 0, "freestanding implementation") -LANGOPT(NoBuiltin , 1, 0, "disable builtin functions") -LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions") -LANGOPT(GNUAsm , 1, 1, "GNU-style inline assembly") +LANGOPT_BOOL(AppExt, 0, "Objective-C App Extension") +LANGOPT_BOOL(Trigraphs, 0,"trigraphs") +LANGOPT_BOOL(LineComment, 1, "'//' comments") +LANGOPT_BOOL(Bool, 1, "bool, true, and false keywords") +LANGOPT_BOOL(Half, 0, "half keyword") +LANGOPT_BOOL(WChar, CPlusPlus, "wchar_t keyword") +BENIGN_LANGOPT_BOOL(DollarIdents, 1, "'$' in identifiers") +BENIGN_LANGOPT_BOOL(AsmPreprocessor, 0, "preprocessor in asm mode") +BENIGN_LANGOPT_BOOL(GNUMode, 0, "GNU extensions") +LANGOPT_BOOL(GNUKeywords, 0, "GNU keywords") +BENIGN_LANGOPT_BOOL(ImplicitInt, !C99 && !CPlusPlus, "C89 implicit 'int'") +LANGOPT_BOOL(Digraphs, 0, "digraphs") +BENIGN_LANGOPT_BOOL(HexFloats, C99, "C99 hexadecimal float constants") +LANGOPT_BOOL(CXXOperatorNames, 0, "C++ operator name keywords") +LANGOPT_BOOL(AppleKext, 0, "Apple kext support") +BENIGN_LANGOPT_BOOL(PascalStrings, 0, "Pascal string support") +LANGOPT_BOOL(WritableStrings, 0, "writable string support") +LANGOPT_BOOL(ConstStrings, 0, "const-qualified string support") +LANGOPT_BOOL(LaxVectorConversions, 1, "lax vector conversions") +LANGOPT_BOOL(AltiVec, 0, "AltiVec-style vector initializers") +LANGOPT_BOOL(ZVector, 0, "System z vector extensions") +LANGOPT_BOOL(Exceptions, 0, "exception handling") +LANGOPT_BOOL(ObjCExceptions, 0, "Objective-C exceptions") +LANGOPT_BOOL(CXXExceptions, 0, "C++ exceptions") +LANGOPT_BOOL(SjLjExceptions, 0, "setjmp-longjump exception handling") +LANGOPT_BOOL(TraditionalCPP, 0, "traditional CPP emulation") +LANGOPT_BOOL(RTTI, 0, "run-time type information") +LANGOPT_BOOL(RTTIData, 0, "emit run-time type information data") +LANGOPT_BOOL(MSBitfields, 0, "Microsoft-compatible structure layout") +LANGOPT_BOOL(Freestanding, 0, "freestanding implementation") +LANGOPT_BOOL(NoBuiltin, 0, "disable builtin functions") +LANGOPT_BOOL(NoMathBuiltin, 0, "disable math builtin functions") +LANGOPT_BOOL(GNUAsm, 1, "GNU-style inline assembly") -BENIGN_LANGOPT(ThreadsafeStatics , 1, 0, "thread-safe static initializers") -LANGOPT(POSIXThreads , 1, 0, "POSIX thread support") -LANGOPT(Blocks , 1, 0, "blocks extension to C") -BENIGN_LANGOPT(EmitAllDecls , 1, 0, "support for emitting all declarations") -LANGOPT(MathErrno , 1, 0, "errno support for math functions") -BENIGN_LANGOPT(HeinousExtensions , 1, 0, "Extensions that we really don't like and may be ripped out at any time") -LANGOPT(Modules , 1, 0, "modules extension to C") -COMPATIBLE_LANGOPT(ModulesDeclUse , 1, 0, "require declaration of module uses") -LANGOPT(ModulesSearchAll , 1, 0, "search even non-imported modules to find unresolved references") -COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "require declaration of module uses and all headers to be in modules") -BENIGN_LANGOPT(ModulesErrorRecovery, 1, 0, "automatically import modules as needed when performing error recovery") -BENIGN_LANGOPT(ImplicitModules, 1, 0, "build modules that are not specified via -fmodule-file") -COMPATIBLE_LANGOPT(ModulesLocalVisibility, 1, 0, "local submodule visibility") -COMPATIBLE_LANGOPT(ModulesHideInternalLinkage, 1, 0, "hiding non-visible internal linkage declarations from redeclaration lookup") -COMPATIBLE_LANGOPT(Optimize , 1, 0, "__OPTIMIZE__ predefined macro") -COMPATIBLE_LANGOPT(OptimizeSize , 1, 0, "__OPTIMIZE_SIZE__ predefined macro") -LANGOPT(Static , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)") +BENIGN_LANGOPT_BOOL(ThreadsafeStatics, 0, "thread-safe static initializers") +LANGOPT_BOOL(POSIXThreads, 0, "POSIX thread support") +LANGOPT_BOOL(Blocks, 0, "blocks extension to C") +BENIGN_LANGOPT_BOOL(EmitAllDecls, 0, "support for emitting all declarations") +LANGOPT_BOOL(MathErrno, 0, "errno support for math functions") +BENIGN_LANGOPT_BOOL(HeinousExtensions, 0, "Extensions that we really don't like and may be ripped out at any time") +LANGOPT_BOOL(Modules, 0, "modules extension to C") +COMPATIBLE_LANGOPT_BOOL(ModulesDeclUse, 0, "require declaration of module uses") +LANGOPT_BOOL(ModulesSearchAll, 0, "search even non-imported modules to find unresolved references") +COMPATIBLE_LANGOPT_BOOL(ModulesStrictDeclUse, 0, "require declaration of module uses and all headers to be in modules") +BENIGN_LANGOPT_BOOL(ModulesErrorRecovery, 0, "automatically import modules as needed when performing error recovery") +BENIGN_LANGOPT_BOOL(ImplicitModules, 0, "build modules that are not specified via -fmodule-file") +COMPATIBLE_LANGOPT_BOOL(ModulesLocalVisibility, 0, "local submodule visibility") +COMPATIBLE_LANGOPT_BOOL(ModulesHideInternalLinkage, 0, "hiding non-visible internal linkage declarations from redeclaration lookup") +COMPATIBLE_LANGOPT_BOOL(Optimize, 0, "__OPTIMIZE__ predefined macro") +COMPATIBLE_LANGOPT_BOOL(OptimizeSize, 0, "__OPTIMIZE_SIZE__ predefined macro") +LANGOPT_BOOL(Static, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)") VALUE_LANGOPT(PackStruct , 32, 0, "default struct packing maximum alignment") VALUE_LANGOPT(MaxTypeAlign , 32, 0, "default maximum alignment for types") VALUE_LANGOPT(PICLevel , 2, 0, "__PIC__ level") VALUE_LANGOPT(PIELevel , 2, 0, "__PIE__ level") -LANGOPT(GNUInline , 1, 0, "GNU inline semantics") -COMPATIBLE_LANGOPT(NoInlineDefine , 1, 0, "__NO_INLINE__ predefined macro") -COMPATIBLE_LANGOPT(Deprecated , 1, 0, "__DEPRECATED predefined macro") -LANGOPT(FastMath , 1, 0, "__FAST_MATH__ predefined macro") -LANGOPT(FiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") +LANGOPT_BOOL(GNUInline, 0, "GNU inline semantics") +COMPATIBLE_LANGOPT_BOOL(NoInlineDefine, 0, "__NO_INLINE__ predefined macro") +COMPATIBLE_LANGOPT_BOOL(Deprecated, 0, "__DEPRECATED predefined macro") +LANGOPT_BOOL(FastMath, 0, "__FAST_MATH__ predefined macro") +LANGOPT_BOOL(FiniteMathOnly, 0, "__FINITE_MATH_ONLY__ predefined macro") -BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars") +BENIGN_LANGOPT_BOOL(ObjCGCBitmapPrint, 0, "printing of GC's bitmap layout for __weak/__strong ivars") -BENIGN_LANGOPT(AccessControl , 1, 1, "C++ access control") -LANGOPT(CharIsSigned , 1, 1, "signed char") -LANGOPT(ShortWChar , 1, 0, "unsigned short wchar_t") +BENIGN_LANGOPT_BOOL(AccessControl, 1, "C++ access control") +LANGOPT_BOOL(CharIsSigned, 1, "signed char") +LANGOPT_BOOL(ShortWChar, 0, "unsigned short wchar_t") ENUM_LANGOPT(MSPointerToMemberRepresentationMethod, PragmaMSPointersToMembersKind, 2, PPTMK_BestCase, "member-pointer representation method") -LANGOPT(ShortEnums , 1, 0, "short enum types") +LANGOPT_BOOL(ShortEnums, 0, "short enum types") -LANGOPT(HLSL , 1, 1, "Microsoft HLSL") // HLSL Change: LangOption for HLSL -LANGOPT(OpenCL , 1, 0, "OpenCL") +LANGOPT_BOOL(HLSL, 1, "Microsoft HLSL") // HLSL Change: LangOption for HLSL +LANGOPT_BOOL(OpenCL, 0, "OpenCL") LANGOPT(OpenCLVersion , 32, 0, "OpenCL version") -LANGOPT(NativeHalfType , 1, 1, "Native half type support") -LANGOPT(HalfArgsAndReturns, 1, 1, "half args and returns") -LANGOPT(CUDA , 1, 0, "CUDA") -LANGOPT(OpenMP , 1, 0, "OpenMP support") -LANGOPT(OpenMPUseTLS , 1, 0, "Use TLS for threadprivates or runtime calls") -LANGOPT(CUDAIsDevice , 1, 0, "Compiling for CUDA device") -LANGOPT(CUDAAllowHostCallsFromHostDevice, 1, 0, "Allow host device functions to call host functions") -LANGOPT(CUDADisableTargetCallChecks, 1, 0, "Disable checks for call targets (host, device, etc.)") +LANGOPT_BOOL(NativeHalfType, 1, "Native half type support") +LANGOPT_BOOL(HalfArgsAndReturns, 1, "half args and returns") +LANGOPT_BOOL(CUDA, 0, "CUDA") +LANGOPT_BOOL(OpenMP, 0, "OpenMP support") +LANGOPT_BOOL(OpenMPUseTLS, 0, "Use TLS for threadprivates or runtime calls") +LANGOPT_BOOL(CUDAIsDevice, 0, "Compiling for CUDA device") +LANGOPT_BOOL(CUDAAllowHostCallsFromHostDevice, 0, "Allow host device functions to call host functions") +LANGOPT_BOOL(CUDADisableTargetCallChecks, 0, "Disable checks for call targets (host, device, etc.)") -LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for C++'s new operators") -LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions") -LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts") -BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision") -BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records") -BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd records in a simple form") -BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables") -LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings") -BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for inline C++ methods") -BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype") -BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support") -BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast the result to id if it is of unknown type") -BENIGN_LANGOPT(DebuggerObjCLiteral , 1, 0, "debugger Objective-C literals and subscripting support") +LANGOPT_BOOL(AssumeSaneOperatorNew, 1, "implicit __attribute__((malloc)) for C++'s new operators") +LANGOPT_BOOL(SizedDeallocation, 0, "enable sized deallocation functions") +LANGOPT_BOOL(ConceptsTS, 0, "enable C++ Extensions for Concepts") +BENIGN_LANGOPT_BOOL(ElideConstructors, 1, "C++ copy constructor elision") +BENIGN_LANGOPT_BOOL(DumpRecordLayouts, 0, "dumping the layout of IRgen'd records") +BENIGN_LANGOPT_BOOL(DumpRecordLayoutsSimple, 0, "dumping the layout of IRgen'd records in a simple form") +BENIGN_LANGOPT_BOOL(DumpVTableLayouts, 0, "dumping the layouts of emitted vtables") +LANGOPT_BOOL(NoConstantCFStrings, 0, "no constant CoreFoundation strings") +BENIGN_LANGOPT_BOOL(InlineVisibilityHidden, 0, "hidden default visibility for inline C++ methods") +BENIGN_LANGOPT_BOOL(ParseUnknownAnytype, 0, "__unknown_anytype") +BENIGN_LANGOPT_BOOL(DebuggerSupport, 0, "debugger support") +BENIGN_LANGOPT_BOOL(DebuggerCastResultToId, 0, "for 'po' in the debugger, cast the result to id if it is of unknown type") +BENIGN_LANGOPT_BOOL(DebuggerObjCLiteral, 0, "debugger Objective-C literals and subscripting support") -BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking") -LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating point constants as single precision constants") -LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math") -LANGOPT(DefaultFPContract , 1, 0, "FP_CONTRACT") -LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment") +BENIGN_LANGOPT_BOOL(SpellChecking, 1, "spell-checking") +LANGOPT_BOOL(SinglePrecisionConstants, 0, "treating double-precision floating point constants as single precision constants") +LANGOPT_BOOL(FastRelaxedMath, 0, "OpenCL fast relaxed math") +LANGOPT_BOOL(DefaultFPContract, 0, "FP_CONTRACT") +LANGOPT_BOOL(NoBitFieldTypeAlign, 0, "bit-field type alignment") LANGOPT(HexagonQdsp6Compat , 1, 0, "hexagon-qdsp6 backward compatibility") -LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting") -LANGOPT(ObjCARCWeak , 1, 0, "__weak support in the ARC runtime") -LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, "Subscripting support in legacy ObjectiveC runtime") -LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map") +LANGOPT_BOOL(ObjCAutoRefCount, 0, "Objective-C automated reference counting") +LANGOPT_BOOL(ObjCARCWeak, 0, "__weak support in the ARC runtime") +LANGOPT_BOOL(ObjCSubscriptingLegacyRuntime, 0, "Subscripting support in legacy ObjectiveC runtime") +LANGOPT_BOOL(FakeAddressSpaceMap, 0, "OpenCL fake address space map") ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, "OpenCL address space map mangling mode") -LANGOPT(MRTD , 1, 0, "-mrtd calling convention") -BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing") -LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime") +LANGOPT_BOOL(MRTD, 0, "-mrtd calling convention") +BENIGN_LANGOPT_BOOL(DelayedTemplateParsing, 0, "delayed template parsing") +LANGOPT_BOOL(BlocksRuntimeOptional, 0, "optional blocks runtime") ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode") ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility, @@ -223,9 +238,9 @@ BENIGN_LANGOPT(NumLargeByValueCopy, 32, 0, VALUE_LANGOPT(MSCompatibilityVersion, 32, 0, "Microsoft Visual C/C++ Version") VALUE_LANGOPT(VtorDispMode, 2, 1, "How many vtordisps to insert") -LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling") +LANGOPT_BOOL(ApplePragmaPack, 0, "Apple gcc-compatible #pragma pack handling") -LANGOPT(RetainCommentsFromSystemHeaders, 1, 0, "retain documentation comments from system headers in the AST") +LANGOPT_BOOL(RetainCommentsFromSystemHeaders, 0, "retain documentation comments from system headers in the AST") LANGOPT(SanitizeAddressFieldPadding, 2, 0, "controls how aggressive is ASan " "field padding (0: none, 1:least " @@ -239,3 +254,6 @@ LANGOPT(SanitizeAddressFieldPadding, 2, 0, "controls how aggressive is ASan " #undef BENIGN_ENUM_LANGOPT #undef VALUE_LANGOPT +#undef LANGOPT_BOOL +#undef COMPATIBLE_LANGOPT_BOOL +#undef BENIGN_LANGOPT_BOOL diff --git a/tools/clang/include/clang/Basic/LangOptions.h b/tools/clang/include/clang/Basic/LangOptions.h index 1c0d6dbe7..101445f97 100644 --- a/tools/clang/include/clang/Basic/LangOptions.h +++ b/tools/clang/include/clang/Basic/LangOptions.h @@ -40,6 +40,7 @@ public: #else #define LANGOPT(Name, Bits, Default, Description) static const unsigned Name = Default; +#define LANGOPT_BOOL(Name, Default, Description) static const bool Name = static_cast( Default ); #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) #include "clang/Basic/LangOptions.fixed.def" diff --git a/tools/clang/lib/Basic/LangOptions.cpp b/tools/clang/lib/Basic/LangOptions.cpp index a45bfbe69..87d207400 100644 --- a/tools/clang/lib/Basic/LangOptions.cpp +++ b/tools/clang/lib/Basic/LangOptions.cpp @@ -19,6 +19,7 @@ using namespace clang; #ifdef LLVM_ON_UNIX #ifndef MS_SUPPORT_VARIABLE_LANGOPTS #define LANGOPT(Name, Bits, Default, Description) const unsigned LangOptionsBase::Name; +#define LANGOPT_BOOL(Name, Default, Description) const bool LangOptionsBase::Name; #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) #include "clang/Basic/LangOptions.fixed.def" #endif // MS_SUPPORT_VARIABLE_LANGOPTS diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index 2d9c253f1..3309c9a5a 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -7378,7 +7378,7 @@ UINT64 HLSLExternalSource::ScoreCast(QualType pLType, QualType pRType) #undef SCORE_COND // Make sure our scores fit in a UINT64. - C_ASSERT(SCORE_MIN_SHIFT + SCORE_PARAM_SHIFT * 8 <= 64); + static_assert(SCORE_MIN_SHIFT + SCORE_PARAM_SHIFT * 8 <= 64); return uScore; } diff --git a/tools/clang/lib/Serialization/ASTReader.cpp b/tools/clang/lib/Serialization/ASTReader.cpp index dd0bf4176..7f9bb2673 100644 --- a/tools/clang/lib/Serialization/ASTReader.cpp +++ b/tools/clang/lib/Serialization/ASTReader.cpp @@ -201,6 +201,10 @@ static bool checkLanguageOptions(const LangOptions &LangOpts, if (!AllowCompatibleDifferences) \ LANGOPT(Name, Bits, Default, Description) +#define COMPATIBLE_LANGOPT_BOOL(Name, Default, Description) \ + if (!AllowCompatibleDifferences) \ + LANGOPT_BOOL(Name, Default, Description) + #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \ if (!AllowCompatibleDifferences) \ ENUM_LANGOPT(Name, Bits, Default, Description) diff --git a/tools/clang/lib/Serialization/ASTWriter.cpp b/tools/clang/lib/Serialization/ASTWriter.cpp index 1e63cbaca..7c58e81a2 100644 --- a/tools/clang/lib/Serialization/ASTWriter.cpp +++ b/tools/clang/lib/Serialization/ASTWriter.cpp @@ -1267,6 +1267,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, const LangOptions &LangOpts = Context.getLangOpts(); #define LANGOPT(Name, Bits, Default, Description) \ Record.push_back(LangOpts.Name); +#define LANGOPT_BOOL(Name, Default, Description) \ + Record.push_back(LangOpts.Name); #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ Record.push_back(static_cast(LangOpts.get##Name())); #include "clang/Basic/LangOptions.fixed.def" diff --git a/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp b/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp index af92b25b8..c2ce74764 100644 --- a/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp +++ b/tools/clang/unittests/DxrFallback/test_DxrFallback.cpp @@ -6,7 +6,7 @@ #include "dxc/Support/FileIOHelper.h" #include "dxc/Support/dxcapi.impl.h" #include "dxc/dxcdxrfallbackcompiler.h" -#include "dxc/support/dxcapi.use.h" +#include "dxc/Support/dxcapi.use.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" diff --git a/tools/clang/unittests/HLSL/CompilerTest.cpp b/tools/clang/unittests/HLSL/CompilerTest.cpp index c4b0baba1..d330ac2a1 100644 --- a/tools/clang/unittests/HLSL/CompilerTest.cpp +++ b/tools/clang/unittests/HLSL/CompilerTest.cpp @@ -1559,7 +1559,7 @@ TEST_F(CompilerTest, CompileThenTestPdbUtilsStripped) { pInclude->CallResults.emplace_back(included_File.c_str()); const WCHAR *pArgs[] = { L"/Zi", L"/Od", L"-flegacy-macro-expansion", L"-Qstrip_debug", L"/DTHIS_IS_A_DEFINE=HELLO" }; - const DxcDefine pDefines[] = { L"THIS_IS_ANOTHER_DEFINE", L"1" }; + const DxcDefine pDefines[] = {{L"THIS_IS_ANOTHER_DEFINE", L"1"}}; VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"PSMain", L"ps_6_0", pArgs, _countof(pArgs), pDefines, _countof(pDefines), pInclude, &pOperationResult)); @@ -1667,7 +1667,7 @@ void CompilerTest::TestPdbUtils(bool bSlim, bool bSourceInDebugModule, bool bStr AddArg(L"-D", L"THIS_IS_A_DEFINE=HELLO", true); - const DxcDefine pDefines[] = { L"THIS_IS_ANOTHER_DEFINE", L"1" }; + const DxcDefine pDefines[] = {{L"THIS_IS_ANOTHER_DEFINE", L"1"}}; expectedDefines.push_back(L"THIS_IS_ANOTHER_DEFINE=1"); expectedDefines.push_back(L"THIS_IS_A_DEFINE=HELLO"); diff --git a/tools/clang/unittests/HLSL/MSFileSysTest.cpp b/tools/clang/unittests/HLSL/MSFileSysTest.cpp index 9f2cfa721..cd59fe820 100644 --- a/tools/clang/unittests/HLSL/MSFileSysTest.cpp +++ b/tools/clang/unittests/HLSL/MSFileSysTest.cpp @@ -145,12 +145,31 @@ public: } virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName, IEnumSTATSTG** pResult) override { - STATSTG items[] = - { - { L"filename.hlsl", STGTY_STREAM, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 0, 0, GUID_NULL, 0, 0 }, - { L"filename2.fx", STGTY_STREAM, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 0, 0, GUID_NULL, 0, 0 } - }; - unsigned testCount = (unsigned)_countof(items); + wchar_t hlslName[] = L"filename.hlsl"; + wchar_t fxName[] = L"filename2.fx"; + STATSTG items[] = {{hlslName, + STGTY_STREAM, + {{0, 0}}, + {0, 0}, + {0, 0}, + {0, 0}, + 0, + 0, + GUID_NULL, + 0, + 0}, + {fxName, + STGTY_STREAM, + {{0, 0}}, + {0, 0}, + {0, 0}, + {0, 0}, + 0, + 0, + GUID_NULL, + 0, + 0}}; + unsigned testCount = (unsigned)std::size(items); FixedEnumSTATSTG* resultEnum = new (std::nothrow) FixedEnumSTATSTG(items, std::min(testCount, findCount)); if (resultEnum == nullptr) { *pResult = nullptr; diff --git a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp index 99288cb82..d26101784 100644 --- a/tools/clang/unittests/HLSLExec/ExecutionTest.cpp +++ b/tools/clang/unittests/HLSLExec/ExecutionTest.cpp @@ -2445,11 +2445,6 @@ TEST_F(ExecutionTest, SignTest) { " int val = g_bab.Load(addr);\r\n" " g_bab.Store(addr, (uint)(sign(val)));\r\n" "}"; - static const int NumThreadsX = 8; - static const int NumThreadsY = 1; - static const int NumThreadsZ = 1; - static const int ThreadsPerGroup = NumThreadsX * NumThreadsY * NumThreadsZ; - static const int DispatchGroupCount = 1; CComPtr pDevice; if (!CreateDevice(&pDevice)) diff --git a/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp b/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp index c57927f00..72338fc0d 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp +++ b/tools/clang/unittests/HLSLExec/ShaderOpTest.cpp @@ -27,7 +27,7 @@ #include "dxc/Support/dxcapi.use.h" // DxcDllSupport #include "dxc/DXIL/DxilConstants.h" // ComponentType #include "WexTestClass.h" // TAEF -#include "HLSLTestUtils.h" // LogCommentFmt +#include "HlslTestUtils.h" // LogCommentFmt #include #include diff --git a/tools/clang/unittests/HLSLHost/HLSLHost.cpp b/tools/clang/unittests/HLSLHost/HLSLHost.cpp index 1dc6c7bf3..6a4228618 100644 --- a/tools/clang/unittests/HLSLHost/HLSLHost.cpp +++ b/tools/clang/unittests/HLSLHost/HLSLHost.cpp @@ -13,6 +13,7 @@ #include "dxc/Support/WinIncludes.h" #include "dxc/Support/FileIOHelper.h" #include "dxc/Support/microcom.h" +#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH #include #include #include @@ -723,6 +724,7 @@ public: WriteRequestResultReply(MsgKind, m_renderer.SetSize(pSetSize->Width, pSetSize->Height)); } + LLVM_FALLTHROUGH; case SetParentWndMsgId: { if (cb < sizeof(HhSetParentWndMessage)) { WriteRequestResultReply(MsgKind, E_INVALIDARG);