SlaterLatiao updated this revision to Diff 526717.
SlaterLatiao added a comment.
- Added release note.
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,6 +167,10 @@
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)
return;
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -307,6 +307,9 @@
(`#62850: <https://github.com/llvm/llvm-project/issues/62850>`_).
- Clang now warns when any predefined macro is undefined or redefined, instead
of only some of them.
+- Clang now does not skip the include stack on an error 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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits