diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp --- a/clang/lib/Frontend/DiagnosticRenderer.cpp +++ b/clang/lib/Frontend/DiagnosticRenderer.cpp @@ -167,12 +167,8 @@ PLoc.isInvalid() ? FullSourceLoc() : FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager()); - // Reset `LastIncludeLoc` on a new error so that the include stacks are - // not skipped. - if (Level == DiagnosticsEngine::Error) - LastIncludeLoc = SourceLocation(); - // Skip redundant include stacks altogether. - if (LastIncludeLoc == IncludeLoc) + // Skip redundant include stacks altogether on non-top-level. + if (Level != DiagnosticsEngine::Error && LastIncludeLoc == IncludeLoc) return; LastIncludeLoc = IncludeLoc;