Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Reduce or eliminate warnings on GCC and Clang #206

Open

Description

@pow2clk

By my count, GCC produces 10126 warnings when building dxc. Clang produces 2335. (Clang has a tendency to consolidate when a long series of warnings are related) This overwhelming volume of warnings makes it difficult to recognize new warnings that might signal subtle bugs, slows the build, and brushes against the storage limits of the automated build system. The biggest !/$ were already eliminated as a precursor to enabling GCC builds, but there are still way too many.

This issue will serve to unite a few changes to fix various instances of specific warnings grouped into changes by type in hopes of making what would otherwise be a staggering monolithic change into comprehensible and reviewable pieces.

Activity

  1. antiagainst commented on May 26, 2018

    @antiagainst

    Agreed. I'm using Clang 6.0.0 locally and collected the following statistics:

    For warning categories:

    583 [-Wgnu-zero-variadic-macro-arguments]
    170 [-Wgnu-anonymous-struct]
    143 [-Wmissing-braces]
    133 [-Wswitch]
    121 [-Wunused-value]
    101 [-Wcast-qual]
     82 [-Wunused-function]
     78 [-Wunused-private-field]
     78 [-Winconsistent-missing-override]
     69 [-Wmismatched-tags]
     69 [-Wmacro-redefined]
     47 [-Wunused-variable]
     34 [-Wcovered-switch-default]
     28 [-Wunused-const-variable]
     24 [-Wreorder]
     18 [-Wlogical-op-parentheses]
     11 [-Wsign-compare]
      8 [-Wdangling-else]
      6 [-Wunused-lambda-capture]
      5 [-Wundefined-internal]
      4 [-Wunneeded-internal-declaration]
      4 [-Wundefined-bool-conversion]
      4 [-Wmissing-field-initializers]
      3 [-Wpragma-once-outside-header]
      3 [-Wextra-tokens]
      3 [-Wenum-compare-switch]
      3 [-Wbraced-scalar-init]
      2 [-Wparentheses]
      2 [-Wformat-pedantic]
      2 [-Wdelete-incomplete]
      2 [-Wchar-subscripts]
      1 [-Wtautological-undefined-compare]
      1 [-Wsometimes-uninitialized]
      1 [-Wsentinel]
      1 [-Wformat-security]
    

    For files triggering warnings:

    721 ../include/dxc/Support/Global.h
    255 ../include/llvm/Support/WinTypes.h
    151 ../lib/HLSL/DxilOperations.cpp
     86 ../tools/clang/lib/Sema/SemaHLSL.cpp
     68 ../tools/clang/include/clang/Sema/Sema.h
     56 ../include/dxc/HLSL/DxilPipelineStateValidation.h
     54 ../lib/HLSL/DxilRootSignature.cpp
     36 ../include/dxc/Support/dxcapi.impl.h
     18 ../tools/clang/lib/SPIRV/SPIRVEmitter.cpp
     18 ../tools/clang/include/clang/Frontend/CompilerInstance.h
     18 ../include/llvm/Support/WinFunctions.h
     16 ../tools/clang/lib/CodeGen/CGHLSLMS.cpp
     15 ../lib/HLSL/DxilValidation.cpp
     14 ../lib/DxcSupport/FileIOHelper.cpp
     11 ../tools/clang/tools/dxcompiler/dxcdisassembler.cpp
     11 ../tools/clang/lib/SPIRV/TypeTranslator.cpp
     10 ../tools/clang/lib/AST/ASTContextHLSL.cpp
      8 ../tools/clang/lib/SPIRV/DeclResultIdMapper.cpp
      8 ../tools/clang/lib/Sema/SemaChecking.cpp
      8 ../lib/Support/APFloat.cpp
      8 ../lib/HLSL/HLSignatureLower.cpp
      7 ../tools/clang/lib/Sema/SemaDeclObjC.cpp
      7 ../tools/clang/lib/Frontend/ASTUnit.cpp
      7 ../lib/HLSL/HLMatrixLowerPass.cpp
      6 ../tools/clang/tools/dxcompiler/dxclibrary.cpp
      6 ../tools/clang/tools/dxc/dxc.cpp
      6 ../lib/HLSL/DxilModule.cpp
      6 ../lib/HLSL/DxilGenerationPass.cpp
      6 ../lib/HLSL/DxcOptimizer.cpp
      5 ../tools/clang/tools/dxcompiler/dxcompilerobj.cpp
      5 ../tools/clang/lib/CodeGen/CGDebugInfo.cpp
      5 ../tools/clang/lib/CodeGen/CGCall.cpp
      5 ../lib/HLSL/DxilDebugInstrumentation.cpp
      4 ../tools/clang/tools/dxcompiler/dxcfilesystem.cpp
      4 ../tools/clang/lib/SPIRV/ModuleBuilder.cpp
      4 ../tools/clang/lib/SPIRV/GlPerVertex.cpp
      4 ../tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
      4 ../tools/clang/lib/CodeGen/CGExprCXX.cpp
      4 ../tools/clang/lib/AST/HlslTypes.cpp
      4 ../tools/clang/lib/AST/ExprConstant.cpp
      4 ../lib/IR/AutoUpgrade.cpp
      4 ../lib/HLSL/HLOperations.cpp
      4 ../lib/HLSL/HLOperationLower.cpp
      4 ../lib/HLSL/HLModule.cpp
      4 ../lib/HLSL/DxilMetadataHelper.cpp
      4 ../lib/HLSL/DxilContainerAssembler.cpp
      3 ../tools/clang/tools/libclang/dxcrewriteunused.cpp
      3 ../tools/clang/tools/libclang/CIndex.cpp
      3 ../tools/clang/tools/dxcompiler/dxcvalidator.cpp
      3 ../tools/clang/tools/dxcompiler/dxcontainerbuilder.cpp
      3 ../tools/clang/tools/dxcompiler/dxcassembler.cpp
      3 ../tools/clang/lib/Sema/SemaOverload.cpp
      3 ../tools/clang/lib/Sema/SemaAccess.cpp
      3 ../tools/clang/lib/CodeGen/CodeGenModule.cpp
      3 tools/clang/include/clang/AST/StmtNodes.inc
      3 ../lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp
      3 ../lib/Transforms/IPO/PassManagerBuilder.cpp
      3 ../lib/IR/LegacyPassManager.cpp
      3 ../lib/IR/Function.cpp
      3 ../lib/IR/DiagnosticInfo.cpp
      3 ../lib/HLSL/DxilTypeSystem.cpp
      3 ../lib/HLSL/DxilShaderAccessTracking.cpp
      2 ../tools/clang/lib/Parse/HLSLRootSignature.cpp
      2 ../tools/clang/lib/CodeGen/CGStmtOpenMP.cpp
      2 ../tools/clang/lib/CodeGen/CGExprScalar.cpp
      2 ../tools/clang/lib/CodeGen/CGExprAgg.cpp
      2 ../tools/clang/lib/Basic/Targets.cpp
      2 ../tools/clang/lib/AST/MicrosoftMangle.cpp
      2 ../tools/clang/lib/AST/Decl.cpp
      2 ../tools/clang/lib/AST/ASTContext.cpp
      2 tools/clang/include/clang/AST/DeclNodes.inc
      2 ../lib/Transforms/InstCombine/InstCombineCalls.cpp
      2 ../lib/Support/CommandLine.cpp
      2 ../lib/HLSL/PauseResumePasses.cpp
      2 ../lib/HLSL/ComputeViewIdState.cpp
      2 ../lib/DxcSupport/dxcapi.use.cpp
      2 ../include/llvm/ADT/PointerUnion.h
      2 ../include/dxc/HLSL/DxilModule.h
      1 ../tools/clang/tools/libclang/CXCursor.cpp
      1 ../tools/clang/tools/dxcompiler/dxillib.cpp
      1 ../tools/clang/tools/dxcompiler/dxcutil.cpp
      1 ../tools/clang/lib/SPIRV/GlPerVertex.h
      1 ../tools/clang/lib/SPIRV/FeatureManager.cpp
      1 ../tools/clang/lib/SPIRV/DeclResultIdMapper.h
      1 ../tools/clang/lib/Sema/SemaType.cpp
      1 ../tools/clang/lib/Sema/SemaTemplateVariadic.cpp
      1 ../tools/clang/lib/Sema/SemaTemplateDeduction.cpp
      1 ../tools/clang/lib/Sema/SemaOpenMP.cpp
      1 ../tools/clang/lib/Sema/SemaExprObjC.cpp
      1 ../tools/clang/lib/Sema/SemaExpr.cpp
      1 ../tools/clang/lib/Sema/SemaExceptionSpec.cpp
      1 ../tools/clang/lib/Sema/DeclSpec.cpp
      1 ../tools/clang/lib/Parse/ParseTemplate.cpp
      1 ../tools/clang/lib/Parse/ParseStmtAsm.cpp
      1 ../tools/clang/lib/Parse/ParseDecl.cpp
      1 ../tools/clang/lib/Parse/HLSLRootSignature.h
      1 ../tools/clang/lib/Lex/TokenLexer.cpp
      1 ../tools/clang/lib/Frontend/FrontendActions.cpp
      1 ../tools/clang/lib/Frontend/FrontendAction.cpp
      1 ../tools/clang/lib/Frontend/CompilerInvocation.cpp
      1 ../tools/clang/lib/Frontend/CompilerInstance.cpp
      1 ../tools/clang/lib/CodeGen/TargetInfo.cpp
      1 ../tools/clang/lib/CodeGen/CGStmt.cpp
      1 ../tools/clang/lib/CodeGen/CGLoopInfo.cpp
      1 ../tools/clang/lib/CodeGen/CGExpr.cpp
      1 ../tools/clang/lib/CodeGen/CGExprConstant.cpp
      1 ../tools/clang/lib/CodeGen/CGExprComplex.cpp
      1 ../tools/clang/lib/CodeGen/CGDecl.cpp
      1 ../tools/clang/lib/CodeGen/CGCleanup.cpp
      1 ../tools/clang/lib/CodeGen/CGClass.cpp
      1 ../tools/clang/lib/CodeGen/BackendUtil.cpp
      1 ../tools/clang/lib/AST/TypePrinter.cpp
      1 ../tools/clang/lib/AST/ItaniumMangle.cpp
      1 ../tools/clang/lib/AST/Expr.cpp
      1 ../lib/Transforms/Utils/SimplifyCFG.cpp
      1 ../lib/Target/TargetMachine.cpp
      1 ../lib/Support/Timer.cpp
      1 ../lib/Support/GraphWriter.cpp
      1 ../lib/ProfileData/CoverageMappingReader.cpp
      1 ../lib/IR/Verifier.cpp
      1 ../lib/HLSL/ReducibilityAnalysis.cpp
      1 ../lib/HLSL/HLOperationLowerExtension.cpp
      1 ../lib/HLSL/DxilSignatureElement.cpp
      1 ../lib/HLSL/DxilSignature.cpp
      1 ../lib/HLSL/DxilOutputColorBecomesConstant.cpp
      1 ../lib/HLSL/DxilConvergent.cpp
      1 ../lib/HLSL/DxilAddPixelHitInstrumentation.cpp
      1 ../lib/Analysis/ConstantFolding.cpp
      1 ../include/dxc/HLSL/DxilSigPoint.inl
    
  2. pow2clk commented on May 27, 2018

    @pow2clk
    Author

    Sorry for letting these build up, but now you know what I've been doing this week. The great part about these changes is that they are pretty non-invasive. No one depends on any other. They don't even touch code very near each other and are therefore unlikely to cause merge conflicts. So they can be reviewed or submitted in any order and likely without a strict time constraint. So if you feel bored, pick one at random and give it a spin!

    Just a heads up. More are on the way. 😰

  3. 90 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions