skan created this revision. skan added reviewers: xiangzhangllvm, LuoYuanke, craig.topper. Herald added a project: clang. Herald added a subscriber: cfe-commits.
clang behaves differently with gcc when compiling a file with -H option, gcc will omit the "./", but clang will not. I fix it to make clang more compatible with gcc. Repository: rC Clang https://reviews.llvm.org/D62115 Files: lib/Frontend/HeaderIncludeGen.cpp test/Driver/clang_H_opt.c test/Driver/clang_H_opt.h Index: test/Driver/clang_H_opt.h =================================================================== --- /dev/null +++ test/Driver/clang_H_opt.h @@ -0,0 +1,2 @@ +// This header file is included by clang_H_opt.c It can not be deleted, +// otherwise Clang will complain when compiling the clang_H_opt.c. Index: test/Driver/clang_H_opt.c =================================================================== --- /dev/null +++ test/Driver/clang_H_opt.c @@ -0,0 +1,6 @@ +// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s + +#include"clang_H_opt.h" +// CHECK: . +// CHECK-NOT: ./ +// CHECK-SAME: clang_H_opt.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)
Index: test/Driver/clang_H_opt.h =================================================================== --- /dev/null +++ test/Driver/clang_H_opt.h @@ -0,0 +1,2 @@ +// This header file is included by clang_H_opt.c It can not be deleted, +// otherwise Clang will complain when compiling the clang_H_opt.c. Index: test/Driver/clang_H_opt.c =================================================================== --- /dev/null +++ test/Driver/clang_H_opt.c @@ -0,0 +1,6 @@ +// RUN: %clang -H -fsyntax-only %s 2>&1 | FileCheck %s + +#include"clang_H_opt.h" +// CHECK: . +// CHECK-NOT: ./ +// CHECK-SAME: clang_H_opt.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)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits