<div dir="ltr">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)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 7, 2020 at 2:56 AM Simon Pilgrim via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Simon Pilgrim<br>
Date: 2020-01-07T10:55:37Z<br>
New Revision: bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/bd1dc6a3eb801b0b6eadb569557a8bba6f7a4b9c.diff</a><br>
<br>
LOG: Fix "use of uninitialized variable" static analyzer warnings. NFCI.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp<br>
index 645bcad9ee69..e5f7968d9326 100644<br>
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp<br>
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp<br>
@@ -1780,7 +1780,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {<br>
     IRBuilder<> IRB(I.getNextNode());<br>
     Type *ShadowTy = getShadowTy(&I);<br>
     Value *Addr = I.getPointerOperand();<br>
-    Value *ShadowPtr, *OriginPtr;<br>
+    Value *ShadowPtr = nullptr, *OriginPtr = nullptr;<br>
     const Align Alignment = assumeAligned(I.getAlignment());<br>
     if (PropagateShadow) {<br>
       std::tie(ShadowPtr, OriginPtr) =<br>
@@ -2476,7 +2476,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {<br>
     Value *Addr = I.getArgOperand(0);<br>
<br>
     Type *ShadowTy = getShadowTy(&I);<br>
-    Value *ShadowPtr, *OriginPtr;<br>
+    Value *ShadowPtr = nullptr, *OriginPtr = nullptr;<br>
     if (PropagateShadow) {<br>
       // We don't know the pointer alignment (could be unaligned SSE load!).<br>
       // Have to assume to worst case.<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>