[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location
Charalampos Mitrodimas via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 4 08:24:01 PDT 2023
charmitro updated this revision to Diff 528219.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151833/new/
https://reviews.llvm.org/D151833
Files:
clang/lib/Frontend/TextDiagnostic.cpp
clang/test/Frontend/absolute-paths-import.h
clang/test/Frontend/absolute-paths.c
Index: clang/test/Frontend/absolute-paths.c
===================================================================
--- clang/test/Frontend/absolute-paths.c
+++ clang/test/Frontend/absolute-paths.c
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -check-prefix=NORMAL -check-prefix=CHECK %s
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -check-prefix=ABSOLUTE -check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=NORMAL -check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=ABSOLUTE -check-prefix=CHECK %s
+
+#include "absolute-paths-import.h"
+// NORMAL: In file included from {{.*}}absolute-paths.c:4:
+// NORMAL-NOT: In file included from [[ROOT_ABSOLUTE]]:4:
+// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4:
#include "absolute-paths.h"
Index: clang/test/Frontend/absolute-paths-import.h
===================================================================
--- /dev/null
+++ clang/test/Frontend/absolute-paths-import.h
@@ -0,0 +1 @@
+#warning abc
Index: clang/lib/Frontend/TextDiagnostic.cpp
===================================================================
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -868,10 +868,11 @@
}
void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
- if (DiagOpts->ShowLocation && PLoc.isValid())
- OS << "In file included from " << PLoc.getFilename() << ':'
- << PLoc.getLine() << ":\n";
- else
+ if (DiagOpts->ShowLocation && PLoc.isValid()) {
+ OS << "In file included from ";
+ emitFilename(PLoc.getFilename(), Loc.getManager());
+ OS << ':' << PLoc.getLine() << ":\n";
+ } else
OS << "In included file:\n";
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151833.528219.patch
Type: text/x-patch
Size: 1999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230604/a5bbd6f5/attachment.bin>
More information about the cfe-commits
mailing list