diff --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index b4e73c81e564..1cb122a536de 100644 --- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -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; diff --git a/clang/test/Coverage/html-multifile-diagnostics.c b/clang/test/Coverage/html-multifile-diagnostics.c index abd54ae83938..39cddc99ba6f 100644 --- a/clang/test/Coverage/html-multifile-diagnostics.c +++ b/clang/test/Coverage/html-multifile-diagnostics.c @@ -4,6 +4,8 @@ // REQUIRES: staticanalyzer +// CHECK: + // CHECK:

Annotated Source Code

// Make sure it's generated as multi-file HTML output