[llvm] bd1dc6a - Fix "use of uninitialized variable" static analyzer warnings. NFCI.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 19:27:23 PDT 2020


Why couldn't the static analyzer figure this one out? Please don't add the
extra unneeded initialization here (somewhat ironically, this is literally
in part of the implementation of MSan, which would be able to detect the
use of uninitialized if it did happen, so long as these sort of extra
initializations aren't added to the code)

On Tue, Jan 7, 2020 at 2:56 AM Simon Pilgrim via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

>
> Author: Simon Pilgrim
> Date: 2020-01-07T10:55:37Z
> New Revision: bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c
>
> URL:
> https://github.com/llvm/llvm-project/commit/bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c
> DIFF:
> https://github.com/llvm/llvm-project/commit/bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c.diff
>
> LOG: Fix "use of uninitialized variable" static analyzer warnings. NFCI.
>
> Added:
>
>
> Modified:
>     llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
> b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
> index 645bcad9ee69..e5f7968d9326 100644
> --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
> +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
> @@ -1780,7 +1780,7 @@ struct MemorySanitizerVisitor : public
> InstVisitor<MemorySanitizerVisitor> {
>      IRBuilder<> IRB(I.getNextNode());
>      Type *ShadowTy = getShadowTy(&I);
>      Value *Addr = I.getPointerOperand();
> -    Value *ShadowPtr, *OriginPtr;
> +    Value *ShadowPtr = nullptr, *OriginPtr = nullptr;
>      const Align Alignment = assumeAligned(I.getAlignment());
>      if (PropagateShadow) {
>        std::tie(ShadowPtr, OriginPtr) =
> @@ -2476,7 +2476,7 @@ struct MemorySanitizerVisitor : public
> InstVisitor<MemorySanitizerVisitor> {
>      Value *Addr = I.getArgOperand(0);
>
>      Type *ShadowTy = getShadowTy(&I);
> -    Value *ShadowPtr, *OriginPtr;
> +    Value *ShadowPtr = nullptr, *OriginPtr = nullptr;
>      if (PropagateShadow) {
>        // We don't know the pointer alignment (could be unaligned SSE
> load!).
>        // Have to assume to worst case.
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200326/b372ebcf/attachment-0001.html>


More information about the llvm-commits mailing list