<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 17, 2013 at 11:18 PM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com" target="_blank">kremenek@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kremenek<br>
Date: Mon Feb 18 01:18:28 2013<br>
New Revision: 175425<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=175425&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=175425&view=rev</a><br>
Log:<br>
Disable dead stores checker for template instantations.  Fixes <rdar://problem/13213575>.<br>
<br>
Modified:<br>
    cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp<br>
    cfe/trunk/test/Analysis/dead-stores.cpp<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=175425&r1=175424&r2=175425&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=175425&r1=175424&r2=175425&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp Mon Feb 18 01:18:28 2013<br>
@@ -419,6 +419,15 @@ class DeadStoresChecker : public Checker<br>
 public:<br>
   void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,<br>
                         BugReporter &BR) const {<br>
+<br>
+    // Don't do anything for template instantiations.<br>
+    // Proving that code in a template instantiation is "dead"<br>
+    // means proving that it is dead in all instantiations.<br>
+    // This same problem exists with -Wunreachable-code.<br></blockquote><div><br></div><div style>I believe last time we spoke about this we agreed that correctness can be attained by examining template patterns not specializations for unreachable code. Your concern was one of performance that I never did get around to providing numbers for (your concern was that examining all template patterns might be too expensive) - I'm not sure if you have the same concern for the Static Analyzer in this regard, or an easier way to verify the perf impact to thins you care about here.<br>
<br>(or perhaps the Static Analyzer already gets this right by examining template patterns elsewhere?)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))<br>
+      if (FD->isTemplateInstantiation())<br>
+        return;<br>
+<br>
     if (LiveVariables *L = mgr.getAnalysis<LiveVariables>(D)) {<br>
       CFG &cfg = *mgr.getCFG(D);<br>
       AnalysisDeclContext *AC = mgr.getAnalysisDeclContext(D);<br>
<br>
Modified: cfe/trunk/test/Analysis/dead-stores.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.cpp?rev=175425&r1=175424&r2=175425&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.cpp?rev=175425&r1=175424&r2=175425&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/Analysis/dead-stores.cpp (original)<br>
+++ cfe/trunk/test/Analysis/dead-stores.cpp Mon Feb 18 01:18:28 2013<br>
@@ -156,3 +156,21 @@ void testCXX11Using() {<br>
   Int value;<br>
   value = 1; // expected-warning {{never read}}<br>
 }<br>
+<br>
+//===----------------------------------------------------------------------===//<br>
+// Dead stores in template instantiations (do not warn).<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+template <bool f> int radar13213575_testit(int i) {<br>
+  int x = 5+i; // warning: Value stored to 'x' during its initialization is never read<br>
+  int y = 7;<br>
+  if (f)<br>
+    return x;<br>
+  else<br>
+    return y;<br>
+}<br>
+<br>
+int radar_13213575() {<br>
+  return radar13213575_testit<true>(5) + radar13213575_testit<false>(3);<br>
+}<br>
+<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>