[PATCH] D17983: Eliminate many benign instances of "potentially uninitialized local variable" warnings

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 07:49:40 PST 2016


I think we had a discussion about this before.

Clang has a few versions of this warning. One version is probably as
aggressive as the warning you are trying to quiet (-Wmaybe-uninitialized)
and we made a deliberate choice not to enable it for the project. I think
we should probably make the same choice here and not enable it.

Initializations we never expect to use (eg because we have a covered switch
that initializes in all cases, or some slightly complex control flow the
compiler can't see through) hinder our ability to find uses of those with
tools like msan.

We do enable clangs -Wsometimes-uninitialized which is more restrictive
(fewer false positives. At the cost of more false negatives).
On Mar 8, 2016 10:58 PM, "Alexander Riccio via cfe-commits" <
cfe-commits at lists.llvm.org> wrote:

> ariccio created this revision.
> ariccio added subscribers: llvm-commits, cfe-commits.
> Herald added a reviewer: tstellarAMD.
> Herald added subscribers: joker.eph, dsanders, arsenm, MatzeB.
>
> Currently, the "potentially uninitialized local variable" & "potentially
> uninitialized local pointer variable" warnings are turned off. At some
> point we should probably turn them back on, because they can find serious
> problems. This patch eliminates the most obviously benign offenders.
>
>
> This leaves about ~33 not-so-obviously benign offenders. which I'll
> include here for convenience:
>
>
>
> |Severity| Code | Description | Project | File | Line | Category | Source
> | Suppression |
>  --------   -----   ------------     -----      ----  -----   --------
>   ------     -------------
> |Warning|       C4703| potentially uninitialized local pointer variable
> 'ExprOffset' used | LLVMMipsAsmParser |
> c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |
> |Warning|       C4701| potentially uninitialized local variable 'Encoding'
> used | clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgdebuginfo.cpp
> | 573 |
> |Warning|       C4701| potentially uninitialized local variable 'result'
> used | clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgobjc.cpp |
> 2675 |
> |Warning|       C4701| potentially uninitialized local variable
> 'Nullability' used | clangParse |
> c:\llvm\llvm\tools\clang\lib\parse\parseobjc.cpp | 1202 |
> |Warning|       C4701| potentially uninitialized local variable
> 'RepresentationMethod' used | clangParse |
> c:\llvm\llvm\tools\clang\lib\parse\parsepragma.cpp | 1582 |
> |Warning|       C4701| potentially uninitialized local variable
> 'FirstOpKind' used | clangSema |
> c:\llvm\llvm\tools\clang\lib\sema\sematemplate.cpp | 4464 |
> |Warning|       C4701| potentially uninitialized local variable
> 'FnEntry8BitAbbrev' used | LLVMBitWriter |
> c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2353 |
> |Warning|       C4701| potentially uninitialized local variable
> 'FnEntry7BitAbbrev' used | LLVMBitWriter |
> c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2357 |
> |Warning|       C4701| potentially uninitialized local variable
> 'FnEntry6BitAbbrev' used | LLVMBitWriter |
> c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2355 |
> |Warning|       C4701| potentially uninitialized local variable 'OutIt'
> used | LLVMCodeGen | c:\llvm\llvm\lib\codegen\liveinterval.cpp | 876 |
> |Warning|       C4701| potentially uninitialized local variable 'mid' used
> | LLVMHexagonCodeGen |
> c:\llvm\build\lib\target\hexagon\hexagongeninstrinfo.inc | 9722 |
> |Warning|       C4701| potentially uninitialized local variable
> 'RealEightBitCounterArray' used | LLVMInstrumentation |
> c:\llvm\llvm\lib\transforms\instrumentation\sanitizercoverage.cpp | 294 |
> |Warning|       C4701| potentially uninitialized local variable 'LoOffset'
> used | LLVMMipsAsmParser |
> c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |
> |Warning|       C4701| potentially uninitialized local variable 'HiOffset'
> used | LLVMMipsAsmParser |
> c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2659 |
> |Warning|       C4701| potentially uninitialized local variable
> 'ExprOffset' used | LLVMMipsAsmParser |
> c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |
> |Warning|       C4701| potentially uninitialized local variable
> 'BranchTargetNoTraps' used | LLVMMipsAsmParser |
> c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 3072 |
> Warning|        C4701| potentially uninitialized local variable 'MatImm'
> used | LLVMPowerPCCodeGen |
> c:\llvm\llvm\lib\target\powerpc\ppciseldagtodag.cpp | 808 |
> |Warning|       C4701| potentially uninitialized local variable 'MaskEnd'
> used | LLVMPowerPCCodeGen |
> c:\llvm\llvm\lib\target\powerpc\ppciseldagtodag.cpp | 809 |
> |Warning|       C4701| potentially uninitialized local variable 'FirstLP'
> used | LLVMScalarOpts | c:\llvm\llvm\lib\transforms\scalar\loadcombine.cpp
> | 198 |
> |Warning|       C4701| potentially uninitialized local variable 'CC' used
> | LLVMSelectionDAG | c:\llvm\llvm\lib\codegen\selectiondag\dagcombiner.cpp
> | 13889 |
> |Warning|       C4701| potentially uninitialized local variable
> 'Operation' used | llvm-ar | c:\llvm\llvm\tools\llvm-ar\llvm-ar.cpp | 287 |
> |Warning|       C4701| potentially uninitialized local variable 'Kind'
> used | llvm-ar | c:\llvm\llvm\tools\llvm-ar\llvm-ar.cpp | 602 |
> |Warning|       C4701| potentially uninitialized local variable
> 'CurSegAddress' used | llvm-objdump |
> c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 8548 |
> |Warning|       C4701| potentially uninitialized local variable
> 'objc_class' used | llvm-objdump |
> c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 5435 |
> |Warning|       C4701| potentially uninitialized local variable 'r_type'
> used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1781 |
> |Warning|       C4701| potentially uninitialized local variable 'r_value'
> used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1783 |
> |Warning|       C4701| potentially uninitialized local variable
> 'pair_r_value' used | llvm-objdump |
> c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1784 |
> |Warning|       C4701| potentially uninitialized local variable 'r_value'
> used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1970 |
> |Warning|       C4701| potentially uninitialized local variable
> 'other_half' used | llvm-objdump |
> c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1940 |
> |Warning|       C4701| potentially uninitialized local variable
> 'pair_r_value' used | llvm-objdump |
> c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1980 |
> |Warning|       C4703| potentially uninitialized local pointer variable
> 'result' used | clangCodeGen |
> c:\llvm\llvm\tools\clang\lib\codegen\cgobjc.cpp | 2675 |
> |Warning|       C4703| potentially uninitialized local pointer variable
> 'OutIt' used | LLVMCodeGen | c:\llvm\llvm\lib\codegen\liveinterval.cpp |
> 876 |
> |Warning|       C4703| potentially uninitialized local pointer variable
> 'RealEightBitCounterArray' used | LLVMInstrumentation |
> c:\llvm\llvm\lib\transforms\instrumentation\sanitizercoverage.cpp | 294 |
>
>
>
> http://reviews.llvm.org/D17983
>
> Files:
>   llvm/lib/Analysis/CFLAliasAnalysis.cpp
>   llvm/lib/Analysis/DependenceAnalysis.cpp
>   llvm/lib/Analysis/InstructionSimplify.cpp
>   llvm/lib/AsmParser/LLParser.cpp
>   llvm/lib/Bitcode/Reader/BitcodeReader.cpp
>   llvm/lib/CodeGen/AtomicExpandPass.cpp
>   llvm/lib/CodeGen/LiveInterval.cpp
>   llvm/lib/CodeGen/MIRParser/MIRParser.cpp
>   llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
>   llvm/lib/IR/Core.cpp
>   llvm/lib/LTO/LTOCodeGenerator.cpp
>   llvm/lib/MC/MCAsmStreamer.cpp
>   llvm/lib/MC/MachObjectWriter.cpp
>   llvm/lib/Support/Windows/Path.inc
>   llvm/lib/Support/YAMLParser.cpp
>   llvm/lib/Target/AArch64/AArch64AdvSIMDScalarPass.cpp
>   llvm/lib/Target/AArch64/AArch64FastISel.cpp
>   llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
>   llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
>   llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
>   llvm/lib/Target/AMDGPU/R600InstrInfo.cpp
>   llvm/lib/Target/ARM/ARMFastISel.cpp
>   llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
>   llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
>   llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp
>   llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.cpp
>   llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
>   llvm/lib/Target/Mips/MipsAsmPrinter.cpp
>   llvm/lib/Target/TargetRecip.cpp
>   llvm/lib/Target/X86/X86FastISel.cpp
>   llvm/lib/Target/X86/X86FixupLEAs.cpp
>   llvm/lib/Target/X86/X86ISelLowering.cpp
>   llvm/lib/Target/X86/X86InstrInfo.cpp
>   llvm/lib/Target/X86/X86WinEHState.cpp
>   llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
>   llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>   llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
>   llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
>   llvm/lib/Transforms/Scalar/SROA.cpp
>   llvm/lib/Transforms/Utils/MemorySSA.cpp
>   llvm/tools/clang/include/clang/Sema/Lookup.h
>   llvm/tools/clang/lib/AST/ExprConstant.cpp
>   llvm/tools/clang/lib/AST/MicrosoftMangle.cpp
>   llvm/tools/clang/lib/CodeGen/CGClass.cpp
>   llvm/tools/clang/lib/CodeGen/CGCleanup.h
>   llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp
>   llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp
>   llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
>   llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp
>   llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp
>   llvm/tools/clang/lib/CodeGen/TargetInfo.cpp
>   llvm/tools/clang/lib/Driver/ToolChain.cpp
>   llvm/tools/clang/lib/Lex/Preprocessor.cpp
>   llvm/tools/clang/lib/Parse/ParseObjc.cpp
>   llvm/tools/clang/lib/Sema/SemaDecl.cpp
>   llvm/tools/clang/lib/Sema/SemaDeclAttr.cpp
>   llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
>   llvm/tools/clang/lib/Sema/SemaInit.cpp
>   llvm/tools/clang/lib/Sema/SemaLambda.cpp
>   llvm/tools/clang/lib/Sema/SemaLookup.cpp
>   llvm/tools/clang/lib/Sema/SemaStmtAttr.cpp
>   llvm/tools/clang/lib/Serialization/ASTReader.cpp
>   llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp
>   llvm/tools/clang/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
>   llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
>   llvm/tools/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160309/d637112c/attachment.html>


More information about the llvm-commits mailing list