]> granicus.if.org Git - clang/commitdiff
[analyzer] Show full analyzer invocation for reproducibility in HTML reports
authorGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 23 Jan 2018 19:28:52 +0000 (19:28 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 23 Jan 2018 19:28:52 +0000 (19:28 +0000)
Analyzing problems which appear in scan-build results can be very
difficult, as after the launch no exact invocation is stored, and it's
super-hard to launch the debugger.
With this patch, the exact analyzer invocation appears in the footer,
and can be copied to debug/check reproducibility/etc.

rdar://35980230

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323245 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
lib/Frontend/CompilerInvocation.cpp
lib/Rewrite/HTMLRewrite.cpp
lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

index ce50cc582d1e00389140abd881875f85a8be9bba..2f28addb96ecd8ca69e482dd9076a992eb68adb9 100644 (file)
@@ -139,6 +139,10 @@ public:
   AnalysisPurgeMode AnalysisPurgeOpt;
   
   std::string AnalyzeSpecificFunction;
+
+  /// Store full compiler invocation for reproducible instructions in the
+  /// generated report.
+  std::string FullCompilerInvocation;
   
   /// \brief The maximum number of times the analyzer visits a block.
   unsigned maxBlockVisitOnPath;
index 74db7f89cf1116874ab20ae3cc54d89d5b75b12f..b107f65adf177457461467547785f108fbced8d6 100644 (file)
@@ -305,6 +305,14 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
     }
   }
 
+  llvm::raw_string_ostream os(Opts.FullCompilerInvocation);
+  for (unsigned i=0; i<Args.getNumInputArgStrings(); i++) {
+    if (i != 0)
+      os << " ";
+    os << Args.getArgString(i);
+  }
+  os.flush();
+
   return Success;
 }
 
index 9d0ed2b46ab6a597e4da583365355069d4cc4547..3a086537b4a95ba7aee9dd2c43663fe4623ec8d5 100644 (file)
@@ -387,6 +387,26 @@ td.rowname {
   color:#444444;
   padding-right:2ex;
 }
+
+/* Hidden text. */
+input.spoilerhider + label {
+  cursor: pointer;
+  text-decoration: underline;
+  display: block;
+}
+input.spoilerhider {
+ display: none;
+}
+input.spoilerhider ~ .spoiler {
+  overflow: hidden;
+  margin: 10px auto 0;
+  height: 0;
+  opacity: 0;
+}
+input.spoilerhider:checked + label + .spoiler{
+  height: auto;
+  opacity: 1;
+}
 </style>
 </head>
 <body>)<<<";
index acddcefc88f30217972bceac1b99db5c4df52839..12f6b130130a806e8edda9979eb921c8fbd38246 100644 (file)
@@ -406,6 +406,12 @@ void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
 <h3>Annotated Source Code</h3>
 <p>Press <a href="#" onclick="toggleHelp(); return false;">'?'</a>
    to see keyboard shortcuts</p>
+<input type="checkbox" class="spoilerhider" id="showinvocation" />
+<label for="showinvocation" >Show analyzer invocation</label>
+<div class="spoiler">clang -cc1 )<<<";
+    os << html::EscapeText(AnalyzerOpts.FullCompilerInvocation);
+    os << R"<<<(
+</div>
 <div id='tooltiphint' hidden="true">
   <p>Keyboard shortcuts: </p>
   <ul>
@@ -416,7 +422,6 @@ void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
   <a href="#" onclick="toggleHelp(); return false;">Close</a>
 </div>
 )<<<";
-
     R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
   }