<p dir="ltr">I think we had a discussion about this before.</p>
<p dir="ltr">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.</p>
<p dir="ltr">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.</p>
<p dir="ltr">We do enable clangs -Wsometimes-uninitialized which is more restrictive (fewer false positives. At the cost of more false negatives).</p>
<div class="gmail_quote">On Mar 8, 2016 10:58 PM, "Alexander Riccio via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ariccio created this revision.<br>
ariccio added subscribers: llvm-commits, cfe-commits.<br>
Herald added a reviewer: tstellarAMD.<br>
Herald added subscribers: joker.eph, dsanders, arsenm, MatzeB.<br>
<br>
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.<br>
<br>
<br>
This leaves about ~33 not-so-obviously benign offenders. which I'll include here for convenience:<br>
<br>
<br>
<br>
|Severity| Code | Description | Project | File | Line | Category | Source | Suppression |<br>
-------- ----- ------------ ----- ---- ----- -------- ------ -------------<br>
|Warning| C4703| potentially uninitialized local pointer variable 'ExprOffset' used | LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |<br>
|Warning| C4701| potentially uninitialized local variable 'Encoding' used | clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgdebuginfo.cpp | 573 |<br>
|Warning| C4701| potentially uninitialized local variable 'result' used | clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgobjc.cpp | 2675 |<br>
|Warning| C4701| potentially uninitialized local variable 'Nullability' used | clangParse | c:\llvm\llvm\tools\clang\lib\parse\parseobjc.cpp | 1202 |<br>
|Warning| C4701| potentially uninitialized local variable 'RepresentationMethod' used | clangParse | c:\llvm\llvm\tools\clang\lib\parse\parsepragma.cpp | 1582 |<br>
|Warning| C4701| potentially uninitialized local variable 'FirstOpKind' used | clangSema | c:\llvm\llvm\tools\clang\lib\sema\sematemplate.cpp | 4464 |<br>
|Warning| C4701| potentially uninitialized local variable 'FnEntry8BitAbbrev' used | LLVMBitWriter | c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2353 |<br>
|Warning| C4701| potentially uninitialized local variable 'FnEntry7BitAbbrev' used | LLVMBitWriter | c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2357 |<br>
|Warning| C4701| potentially uninitialized local variable 'FnEntry6BitAbbrev' used | LLVMBitWriter | c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2355 |<br>
|Warning| C4701| potentially uninitialized local variable 'OutIt' used | LLVMCodeGen | c:\llvm\llvm\lib\codegen\liveinterval.cpp | 876 |<br>
|Warning| C4701| potentially uninitialized local variable 'mid' used | LLVMHexagonCodeGen | c:\llvm\build\lib\target\hexagon\hexagongeninstrinfo.inc | 9722 |<br>
|Warning| C4701| potentially uninitialized local variable 'RealEightBitCounterArray' used | LLVMInstrumentation | c:\llvm\llvm\lib\transforms\instrumentation\sanitizercoverage.cpp | 294 |<br>
|Warning| C4701| potentially uninitialized local variable 'LoOffset' used | LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |<br>
|Warning| C4701| potentially uninitialized local variable 'HiOffset' used | LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2659 |<br>
|Warning| C4701| potentially uninitialized local variable 'ExprOffset' used | LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |<br>
|Warning| C4701| potentially uninitialized local variable 'BranchTargetNoTraps' used | LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 3072 |<br>
Warning| C4701| potentially uninitialized local variable 'MatImm' used | LLVMPowerPCCodeGen | c:\llvm\llvm\lib\target\powerpc\ppciseldagtodag.cpp | 808 |<br>
|Warning| C4701| potentially uninitialized local variable 'MaskEnd' used | LLVMPowerPCCodeGen | c:\llvm\llvm\lib\target\powerpc\ppciseldagtodag.cpp | 809 |<br>
|Warning| C4701| potentially uninitialized local variable 'FirstLP' used | LLVMScalarOpts | c:\llvm\llvm\lib\transforms\scalar\loadcombine.cpp | 198 |<br>
|Warning| C4701| potentially uninitialized local variable 'CC' used | LLVMSelectionDAG | c:\llvm\llvm\lib\codegen\selectiondag\dagcombiner.cpp | 13889 |<br>
|Warning| C4701| potentially uninitialized local variable 'Operation' used | llvm-ar | c:\llvm\llvm\tools\llvm-ar\llvm-ar.cpp | 287 |<br>
|Warning| C4701| potentially uninitialized local variable 'Kind' used | llvm-ar | c:\llvm\llvm\tools\llvm-ar\llvm-ar.cpp | 602 |<br>
|Warning| C4701| potentially uninitialized local variable 'CurSegAddress' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 8548 |<br>
|Warning| C4701| potentially uninitialized local variable 'objc_class' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 5435 |<br>
|Warning| C4701| potentially uninitialized local variable 'r_type' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1781 |<br>
|Warning| C4701| potentially uninitialized local variable 'r_value' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1783 |<br>
|Warning| C4701| potentially uninitialized local variable 'pair_r_value' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1784 |<br>
|Warning| C4701| potentially uninitialized local variable 'r_value' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1970 |<br>
|Warning| C4701| potentially uninitialized local variable 'other_half' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1940 |<br>
|Warning| C4701| potentially uninitialized local variable 'pair_r_value' used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1980 |<br>
|Warning| C4703| potentially uninitialized local pointer variable 'result' used | clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgobjc.cpp | 2675 |<br>
|Warning| C4703| potentially uninitialized local pointer variable 'OutIt' used | LLVMCodeGen | c:\llvm\llvm\lib\codegen\liveinterval.cpp | 876 |<br>
|Warning| C4703| potentially uninitialized local pointer variable 'RealEightBitCounterArray' used | LLVMInstrumentation | c:\llvm\llvm\lib\transforms\instrumentation\sanitizercoverage.cpp | 294 |<br>
<br>
<br>
<br>
<a href="http://reviews.llvm.org/D17983" rel="noreferrer" target="_blank">http://reviews.llvm.org/D17983</a><br>
<br>
Files:<br>
llvm/lib/Analysis/CFLAliasAnalysis.cpp<br>
llvm/lib/Analysis/DependenceAnalysis.cpp<br>
llvm/lib/Analysis/InstructionSimplify.cpp<br>
llvm/lib/AsmParser/LLParser.cpp<br>
llvm/lib/Bitcode/Reader/BitcodeReader.cpp<br>
llvm/lib/CodeGen/AtomicExpandPass.cpp<br>
llvm/lib/CodeGen/LiveInterval.cpp<br>
llvm/lib/CodeGen/MIRParser/MIRParser.cpp<br>
llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp<br>
llvm/lib/IR/Core.cpp<br>
llvm/lib/LTO/LTOCodeGenerator.cpp<br>
llvm/lib/MC/MCAsmStreamer.cpp<br>
llvm/lib/MC/MachObjectWriter.cpp<br>
llvm/lib/Support/Windows/Path.inc<br>
llvm/lib/Support/YAMLParser.cpp<br>
llvm/lib/Target/AArch64/AArch64AdvSIMDScalarPass.cpp<br>
llvm/lib/Target/AArch64/AArch64FastISel.cpp<br>
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp<br>
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp<br>
llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp<br>
llvm/lib/Target/AMDGPU/R600InstrInfo.cpp<br>
llvm/lib/Target/ARM/ARMFastISel.cpp<br>
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp<br>
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp<br>
llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp<br>
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.cpp<br>
llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp<br>
llvm/lib/Target/Mips/MipsAsmPrinter.cpp<br>
llvm/lib/Target/TargetRecip.cpp<br>
llvm/lib/Target/X86/X86FastISel.cpp<br>
llvm/lib/Target/X86/X86FixupLEAs.cpp<br>
llvm/lib/Target/X86/X86ISelLowering.cpp<br>
llvm/lib/Target/X86/X86InstrInfo.cpp<br>
llvm/lib/Target/X86/X86WinEHState.cpp<br>
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp<br>
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp<br>
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp<br>
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp<br>
llvm/lib/Transforms/Scalar/SROA.cpp<br>
llvm/lib/Transforms/Utils/MemorySSA.cpp<br>
llvm/tools/clang/include/clang/Sema/Lookup.h<br>
llvm/tools/clang/lib/AST/ExprConstant.cpp<br>
llvm/tools/clang/lib/AST/MicrosoftMangle.cpp<br>
llvm/tools/clang/lib/CodeGen/CGClass.cpp<br>
llvm/tools/clang/lib/CodeGen/CGCleanup.h<br>
llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp<br>
llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp<br>
llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp<br>
llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp<br>
llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp<br>
llvm/tools/clang/lib/CodeGen/TargetInfo.cpp<br>
llvm/tools/clang/lib/Driver/ToolChain.cpp<br>
llvm/tools/clang/lib/Lex/Preprocessor.cpp<br>
llvm/tools/clang/lib/Parse/ParseObjc.cpp<br>
llvm/tools/clang/lib/Sema/SemaDecl.cpp<br>
llvm/tools/clang/lib/Sema/SemaDeclAttr.cpp<br>
llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp<br>
llvm/tools/clang/lib/Sema/SemaInit.cpp<br>
llvm/tools/clang/lib/Sema/SemaLambda.cpp<br>
llvm/tools/clang/lib/Sema/SemaLookup.cpp<br>
llvm/tools/clang/lib/Sema/SemaStmtAttr.cpp<br>
llvm/tools/clang/lib/Serialization/ASTReader.cpp<br>
llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp<br>
llvm/tools/clang/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp<br>
llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp<br>
llvm/tools/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp<br>
<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div>