SlaterLatiao updated this revision to Diff 538197. SlaterLatiao added a comment.
- Emit include stack on all top-level diagnostics. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151575/new/ https://reviews.llvm.org/D151575 Files: clang/docs/ReleaseNotes.rst clang/lib/Frontend/DiagnosticRenderer.cpp clang/test/Misc/Inputs/include-stack-on-error-1.h clang/test/Misc/Inputs/include-stack-on-error-2.h clang/test/Misc/Inputs/include-stack-on-error-3.h clang/test/Misc/include-stack-on-error-1.cpp clang/test/Misc/include-stack-on-error-2.cpp
Index: clang/test/Misc/include-stack-on-error-2.cpp =================================================================== --- /dev/null +++ clang/test/Misc/include-stack-on-error-2.cpp @@ -0,0 +1,15 @@ +// Test duplicate include stacks that are not on a new error are skipped. +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=NOTESTACK + +#include "include-stack-on-error-1.h" +#include "include-stack-on-error-3.h" + +// NOTESTACK: In file included from +// NOTESTACK: error: no matching function for call to 'b1' +// This include should be skipped due to duplicate include location. +// NOTESTACK-NOT: In file included from +// NOTESTACK: note: candidate function not viable +// NOTESTACK: In file included from +// NOTESTACK: error: invalid operands to binary expression +// NOTESTACK: In file included from +// NOTESTACK: note: in instantiation of function template specialization Index: clang/test/Misc/include-stack-on-error-1.cpp =================================================================== --- /dev/null +++ clang/test/Misc/include-stack-on-error-1.cpp @@ -0,0 +1,24 @@ +// Test duplicate include stacks on a new error are not skipped. +// RUN: not %clang_cc1 -fsyntax-only -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=STACK +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=NOTESTACK + +#include "include-stack-on-error-1.h" +#include "include-stack-on-error-2.h" + +// STACK: In file included from +// STACK: error: no matching function for call to 'b1' +// STACK-NOT: In file included from +// STACK: note: candidate function not viable +// STACK: In file included from +// STACK: error: invalid operands to binary expression +// STACK-NOT: In file included from +// STACK: note: in instantiation of function template specialization + +// NOTESTACK: In file included from +// NOTESTACK: error: no matching function for call to 'b1' +// NOTESTACK: In file included from +// NOTESTACK: note: candidate function not viable +// NOTESTACK: In file included from +// NOTESTACK: error: invalid operands to binary expression +// NOTESTACK: In file included from +// NOTESTACK: note: in instantiation of function template specialization Index: clang/test/Misc/Inputs/include-stack-on-error-3.h =================================================================== --- /dev/null +++ clang/test/Misc/Inputs/include-stack-on-error-3.h @@ -0,0 +1,5 @@ +void b1(); +void c() { + b1(0); + b2("0", "0"); +} Index: clang/test/Misc/Inputs/include-stack-on-error-2.h =================================================================== --- /dev/null +++ clang/test/Misc/Inputs/include-stack-on-error-2.h @@ -0,0 +1,4 @@ +void c() { + b1(0); + b2("0", "0"); +} Index: clang/test/Misc/Inputs/include-stack-on-error-1.h =================================================================== --- /dev/null +++ clang/test/Misc/Inputs/include-stack-on-error-1.h @@ -0,0 +1,2 @@ +void b1(); +template <class T> void b2(T x, T y) { x + y; } Index: clang/lib/Frontend/DiagnosticRenderer.cpp =================================================================== --- clang/lib/Frontend/DiagnosticRenderer.cpp +++ clang/lib/Frontend/DiagnosticRenderer.cpp @@ -167,8 +167,8 @@ PLoc.isInvalid() ? FullSourceLoc() : FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager()); - // Skip redundant include stacks altogether. - if (LastIncludeLoc == IncludeLoc) + // Skip redundant include stacks altogether on non-top-level. + if (Level < DiagnosticsEngine::Warning && LastIncludeLoc == IncludeLoc) return; LastIncludeLoc = IncludeLoc; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -359,6 +359,9 @@ - The Fix-It emitted for unused labels used to expand to the next line, which caused visual oddities now that Clang shows more than one line of code snippet. This has been fixed and the Fix-It now only spans to the end of the ``:``. +- Clang now does not skip the include stack on top-level diagnostics when it's a + duplicate of the previous include stack. + (`#62001 <https://github.com/llvm/llvm-project/issues/62001>`_) Bug Fixes in This Version -------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits