From 1aeceaea7d011fcf8a3beef741da4553ddbe360f Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 15 Oct 2019 11:17:53 -0400 Subject: [PATCH 1/2] Fix config issues and revert previous fixes for semi-colon issues This reverts commit 41261d95a417bb3a121c162154d441433705a237. This reverts commit 7c9accb6534d4cde050555b8091b434dc7e4d218. Instead of trying to work around all of the potential semicolon issues in glslang, making it conform to Chromium's style, mark the code explicitly as non-chromium in the BUILD.gn, so chromium doesn't attempt to enforce its style rules on glslang. Fixes #1931 --- BUILD.gn | 15 +++++++++++++-- CMakeLists.txt | 4 ++-- SPIRV/GlslangToSpv.cpp | 8 ++++---- glslang/Include/Types.h | 4 ++-- glslang/MachineIndependent/ParseHelper.h | 2 +- glslang/MachineIndependent/iomapper.h | 12 ++++++------ glslang/Public/ShaderLang.h | 4 ++-- 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index b2878affa1..77d596e1b0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -159,7 +159,7 @@ source_set("glslang_sources") { } if (is_clang) { - cflags_cc = [ + cflags = [ "-Wno-extra-semi", "-Wno-ignored-qualifiers", "-Wno-implicit-fallthrough", @@ -168,7 +168,6 @@ source_set("glslang_sources") { "-Wno-unused-variable", "-Wno-missing-field-initializers", "-Wno-newline-eof", - "-Wextra-semi", ] } if (is_win && !is_clang) { @@ -182,6 +181,9 @@ source_set("glslang_sources") { "${spirv_tools_dir}:spvtools_opt", "${spirv_tools_dir}:spvtools_val", ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] } source_set("glslang_default_resource_limits_sources") { @@ -193,6 +195,9 @@ source_set("glslang_default_resource_limits_sources") { ":glslang_sources", ] public_configs = [ ":glslang_public" ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] } executable("glslang_validator") { @@ -208,6 +213,9 @@ executable("glslang_validator") { ":glslang_default_resource_limits_sources", ":glslang_sources", ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] } executable("spirv-remap") { @@ -218,4 +226,7 @@ executable("spirv-remap") { deps = [ ":glslang_sources", ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] } diff --git a/CMakeLists.txt b/CMakeLists.txt index da25533e77..41871ec87e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,12 +91,12 @@ endif(WIN32) if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs - -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions) + -Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable -fno-exceptions) add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over. add_compile_options(-fno-rtti) elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs - -Wunused-parameter -Wunused-value -Wunused-variable -Wextra-semi) + -Wunused-parameter -Wunused-value -Wunused-variable) add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over. add_compile_options(-fno-rtti) elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index f4e0fdbcfa..2d50074ff0 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -100,11 +100,11 @@ struct OpDecorations { spv::Decoration precision; #ifdef GLSLANG_WEB - void addNoContraction(spv::Builder&, spv::Id) const { } - void addNonUniform(spv::Builder&, spv::Id) const { } + void addNoContraction(spv::Builder&, spv::Id) const { }; + void addNonUniform(spv::Builder&, spv::Id) const { }; #else - void addNoContraction(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, noContraction); } - void addNonUniform(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, nonUniform); } + void addNoContraction(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, noContraction); }; + void addNonUniform(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, nonUniform); }; protected: spv::Decoration noContraction; spv::Decoration nonUniform; diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index ef933b4fc9..59ead22d7b 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -135,8 +135,8 @@ struct TSampler { // misnomer now; includes images, textures without sampler, bool isYuv() const { return yuv; } #endif void setCombined(bool c) { combined = c; } - void setBasicType(TBasicType t) { type = t; } - TBasicType getBasicType() const { return type; } + void setBasicType(TBasicType t) { type = t; }; + TBasicType getBasicType() const { return type; }; bool isShadow() const { return shadow; } bool isArrayed() const { return arrayed; } diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 39363f1a2a..5cee05e116 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -283,7 +283,7 @@ class TParseContext : public TParseContextBase { const TString* entryPoint = nullptr); virtual ~TParseContext(); - bool obeyPrecisionQualifiers() const { return precisionManager.respectingPrecisionQualifiers(); } + bool obeyPrecisionQualifiers() const { return precisionManager.respectingPrecisionQualifiers(); }; void setPrecisionDefaults(); void setLimits(const TBuiltInResource&) override; diff --git a/glslang/MachineIndependent/iomapper.h b/glslang/MachineIndependent/iomapper.h index 684e88d571..01afc5a21e 100644 --- a/glslang/MachineIndependent/iomapper.h +++ b/glslang/MachineIndependent/iomapper.h @@ -114,7 +114,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver { bool doAutoLocationMapping() const; TSlotSet::iterator findSlot(int set, int slot); bool checkEmpty(int set, int slot); - bool validateInOut(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; } + bool validateInOut(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; }; int reserveSlot(int set, int slot, int size = 1); int getFreeSlot(int set, int base, int size = 1); int resolveSet(EShLanguage /*stage*/, TVarEntryInfo& ent) override; @@ -125,7 +125,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver { void addStage(EShLanguage stage) override { if (stage < EShLangCount) stageMask[stage] = true; - } + }; uint32_t computeTypeLocationSize(const TType& type, EShLanguage stage); TSlotSetMap slots; @@ -191,7 +191,7 @@ struct TDefaultGlslIoResolver : public TDefaultIoResolverBase { typedef std::map TVarSlotMap; // typedef std::map TSlotMap; // TDefaultGlslIoResolver(const TIntermediate& intermediate); - bool validateBinding(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; } + bool validateBinding(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; }; TResourceType getResourceType(const glslang::TType& type) override; int resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) override; int resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) override; @@ -209,7 +209,7 @@ struct TDefaultGlslIoResolver : public TDefaultIoResolverBase { int buildStorageKey(EShLanguage stage, TStorageQualifier type) { assert(static_cast(stage) <= 0x0000ffff && static_cast(type) <= 0x0000ffff); return (stage << 16) | type; - } + }; protected: // Use for mark pre stage, to get more interface symbol information. @@ -242,7 +242,7 @@ struct TVarLivePair : std::pair { const_cast(first) = _Right.first; second = _Right.second; return (*this); - } + }; }; typedef std::vector TVarLiveVector; @@ -253,7 +253,7 @@ class TIoMapper { virtual ~TIoMapper() {} // grow the reflection stage by stage bool virtual addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*); - bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; } + bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; }; }; // I/O mapper for OpenGL diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 4cc6c2f488..9782475d29 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -487,7 +487,7 @@ class TShader { environment.target.version = version; } - void getStrings(const char* const* &s, int& n) { s = strings; n = numStrings; } + void getStrings(const char* const* &s, int& n) { s = strings; n = numStrings; }; #ifdef ENABLE_HLSL void setEnvTargetHlslFunctionality1() { environment.target.hlslFunctionality1 = true; } @@ -775,7 +775,7 @@ class TProgram { TProgram(); virtual ~TProgram(); void addShader(TShader* shader) { stages[shader->stage].push_back(shader); } - std::list& getShaders(EShLanguage stage) { return stages[stage]; } + std::list& getShaders(EShLanguage stage) { return stages[stage]; }; // Link Validation interface bool link(EShMessages); const char* getInfoLog(); From 622024277e1e016cb6f8e35e98d50251f3cca1cd Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 16 Oct 2019 11:46:37 -0400 Subject: [PATCH 2/2] Keep code style improvements --- SPIRV/GlslangToSpv.cpp | 8 ++++---- glslang/Include/Types.h | 4 ++-- glslang/MachineIndependent/ParseHelper.h | 2 +- glslang/MachineIndependent/iomapper.h | 12 ++++++------ glslang/Public/ShaderLang.h | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 2d50074ff0..f4e0fdbcfa 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -100,11 +100,11 @@ struct OpDecorations { spv::Decoration precision; #ifdef GLSLANG_WEB - void addNoContraction(spv::Builder&, spv::Id) const { }; - void addNonUniform(spv::Builder&, spv::Id) const { }; + void addNoContraction(spv::Builder&, spv::Id) const { } + void addNonUniform(spv::Builder&, spv::Id) const { } #else - void addNoContraction(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, noContraction); }; - void addNonUniform(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, nonUniform); }; + void addNoContraction(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, noContraction); } + void addNonUniform(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, nonUniform); } protected: spv::Decoration noContraction; spv::Decoration nonUniform; diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 59ead22d7b..ef933b4fc9 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -135,8 +135,8 @@ struct TSampler { // misnomer now; includes images, textures without sampler, bool isYuv() const { return yuv; } #endif void setCombined(bool c) { combined = c; } - void setBasicType(TBasicType t) { type = t; }; - TBasicType getBasicType() const { return type; }; + void setBasicType(TBasicType t) { type = t; } + TBasicType getBasicType() const { return type; } bool isShadow() const { return shadow; } bool isArrayed() const { return arrayed; } diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 5cee05e116..39363f1a2a 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -283,7 +283,7 @@ class TParseContext : public TParseContextBase { const TString* entryPoint = nullptr); virtual ~TParseContext(); - bool obeyPrecisionQualifiers() const { return precisionManager.respectingPrecisionQualifiers(); }; + bool obeyPrecisionQualifiers() const { return precisionManager.respectingPrecisionQualifiers(); } void setPrecisionDefaults(); void setLimits(const TBuiltInResource&) override; diff --git a/glslang/MachineIndependent/iomapper.h b/glslang/MachineIndependent/iomapper.h index 01afc5a21e..684e88d571 100644 --- a/glslang/MachineIndependent/iomapper.h +++ b/glslang/MachineIndependent/iomapper.h @@ -114,7 +114,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver { bool doAutoLocationMapping() const; TSlotSet::iterator findSlot(int set, int slot); bool checkEmpty(int set, int slot); - bool validateInOut(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; }; + bool validateInOut(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; } int reserveSlot(int set, int slot, int size = 1); int getFreeSlot(int set, int base, int size = 1); int resolveSet(EShLanguage /*stage*/, TVarEntryInfo& ent) override; @@ -125,7 +125,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver { void addStage(EShLanguage stage) override { if (stage < EShLangCount) stageMask[stage] = true; - }; + } uint32_t computeTypeLocationSize(const TType& type, EShLanguage stage); TSlotSetMap slots; @@ -191,7 +191,7 @@ struct TDefaultGlslIoResolver : public TDefaultIoResolverBase { typedef std::map TVarSlotMap; // typedef std::map TSlotMap; // TDefaultGlslIoResolver(const TIntermediate& intermediate); - bool validateBinding(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; }; + bool validateBinding(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; } TResourceType getResourceType(const glslang::TType& type) override; int resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) override; int resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) override; @@ -209,7 +209,7 @@ struct TDefaultGlslIoResolver : public TDefaultIoResolverBase { int buildStorageKey(EShLanguage stage, TStorageQualifier type) { assert(static_cast(stage) <= 0x0000ffff && static_cast(type) <= 0x0000ffff); return (stage << 16) | type; - }; + } protected: // Use for mark pre stage, to get more interface symbol information. @@ -242,7 +242,7 @@ struct TVarLivePair : std::pair { const_cast(first) = _Right.first; second = _Right.second; return (*this); - }; + } }; typedef std::vector TVarLiveVector; @@ -253,7 +253,7 @@ class TIoMapper { virtual ~TIoMapper() {} // grow the reflection stage by stage bool virtual addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*); - bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; }; + bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; } }; // I/O mapper for OpenGL diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 9782475d29..4cc6c2f488 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -487,7 +487,7 @@ class TShader { environment.target.version = version; } - void getStrings(const char* const* &s, int& n) { s = strings; n = numStrings; }; + void getStrings(const char* const* &s, int& n) { s = strings; n = numStrings; } #ifdef ENABLE_HLSL void setEnvTargetHlslFunctionality1() { environment.target.hlslFunctionality1 = true; } @@ -775,7 +775,7 @@ class TProgram { TProgram(); virtual ~TProgram(); void addShader(TShader* shader) { stages[shader->stage].push_back(shader); } - std::list& getShaders(EShLanguage stage) { return stages[stage]; }; + std::list& getShaders(EShLanguage stage) { return stages[stage]; } // Link Validation interface bool link(EShMessages); const char* getInfoLog();