[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.
Kan Shengchen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 7 19:09:03 PDT 2019
skan updated this revision to Diff 203664.
skan added a comment.
make macro more compact
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62115/new/
https://reviews.llvm.org/D62115
Files:
lib/Frontend/HeaderIncludeGen.cpp
test/Frontend/clang_H_opt.c
Index: test/Frontend/clang_H_opt.c
===================================================================
--- /dev/null
+++ test/Frontend/clang_H_opt.c
@@ -0,0 +1,41 @@
+// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "../Index/Inputs/empty.h"
+#include "Inputs/empty.h"
+#include "./Inputs/empty.h"
+#include "././Inputs/empty.h"
+#include "./Inputs/empty.h"
+// CHECK: .
+// CHECK-SAME: ../Index/Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ./Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ././Inputs/empty.h
+// CHECK: .
+// CHECK-SAME: ./Inputs/empty.h
+
+#if defined(_WIN32) || defined(_WIN64)
+#include "..\Index\Inputs\empty.h"
+#include "Inputs\empty.h"
+#include ".\Inputs\empty.h"
+#include ".\.\Inputs\empty.h"
+#include ".\Inputs\empty.h"
+#else
+#include "../Index/Inputs/empty.h"
+#include "Inputs/empty.h"
+#include "./Inputs/empty.h"
+#include "././Inputs/empty.h"
+#include "./Inputs/empty.h"
+#endif
+// CHECK: .
+// CHECK-SAME: ..{{\/|\\\\}}Index{{\/|\\\\}}Inputs{{\/|\\\\}}empty.h
+// CHECK: .
+// CHECK-SAME: Inputs{{\/|\\\\}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|\\\\}}Inputs{{\/|\\\\}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|\\\\}}.{{\/|\\\\}}Inputs{{\/|\\\\}}empty.h
+// CHECK: .
+// CHECK-SAME: .{{\/|\\\\}}Inputs{{\/|\\\\}}empty.h
Index: lib/Frontend/HeaderIncludeGen.cpp
===================================================================
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -51,6 +51,10 @@
static void PrintHeaderInfo(raw_ostream *OutputFile, StringRef Filename,
bool ShowDepth, unsigned CurrentIncludeDepth,
bool MSStyle) {
+ // Simplify Filename that starts with "./"
+ if (Filename.startswith("./"))
+ Filename = Filename.substr(2);
+
// Write to a temporary string to avoid unnecessary flushing on errs().
SmallString<512> Pathname(Filename);
if (!MSStyle)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62115.203664.patch
Type: text/x-patch
Size: 1969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190608/e9087a52/attachment-0001.bin>
More information about the cfe-commits
mailing list