[analyzer] Fix filename in cross-file HTML report
authorMalcolm Parsons <malcolm.parsons@gmail.com>
Wed, 2 May 2018 14:26:12 +0000 (14:26 +0000)
committerMalcolm Parsons <malcolm.parsons@gmail.com>
Wed, 2 May 2018 14:26:12 +0000 (14:26 +0000)
Summary:
The filename is currently taken from the start of the path, while the
line and column are taken from the end of the path.
This didn't matter until cross-file path reporting was added.

Reviewers: george.karpenkov, dcoughlin, vlad.tsyrklevich

Reviewed By: george.karpenkov, vlad.tsyrklevich

Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D45611

llvm-svn: 331361

clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/test/Coverage/html-multifile-diagnostics.c

index b4e73c8..1cb122a 100644 (file)
@@ -321,7 +321,9 @@ std::string HTMLDiagnostics::GenerateHTML(const PathDiagnostic& D, Rewriter &R,
     return {};
 
   // Add CSS, header, and footer.
-  const FileEntry* Entry = SMgr.getFileEntryForID(FileIDs[0]);
+  FileID FID =
+      path.back()->getLocation().asLocation().getExpansionLoc().getFileID();
+  const FileEntry* Entry = SMgr.getFileEntryForID(FID);
   FinalizeHTML(D, R, SMgr, path, FileIDs[0], Entry, declName);
 
   std::string file;
index abd54ae..39cddc9 100644 (file)
@@ -4,6 +4,8 @@
 
 // REQUIRES: staticanalyzer
 
+// CHECK: <!-- FILENAME html-multifile-diagnostics.h -->
+
 // CHECK: <h3>Annotated Source Code</h3>
 
 // Make sure it's generated as multi-file HTML output