From 9d65624bf6577ad597d80cf4dd9d9aa8d65dec61 Mon Sep 17 00:00:00 2001 From: Kristina Brooks Date: Thu, 16 May 2019 03:30:08 +0000 Subject: [PATCH] Revert r360833 until I can work out the issue with Win32 bots This reverts "r360833: [Clang][PP] Add the __FILE_NAME__ builtin macro." The tests are failing on Windows bots, reverting the patchset until I can work out why. llvm-svn: 360842 --- clang/include/clang/Lex/Preprocessor.h | 1 - clang/lib/Lex/PPMacroExpansion.cpp | 26 +---------- .../include-subdir/file_name_macro_include.h | 6 --- .../test/Preprocessor/Inputs/include-subdir/h | 1 - .../Inputs/include-subdir/subdir1/hdr1.h | 1 - .../Inputs/include-subdir/subdir1/hdr2.h | 1 - clang/test/Preprocessor/file_name_macro.c | 44 ------------------- 7 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 clang/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h delete mode 100644 clang/test/Preprocessor/Inputs/include-subdir/h delete mode 100644 clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h delete mode 100644 clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h delete mode 100644 clang/test/Preprocessor/file_name_macro.c diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 57c557d6a9cf..293fbafdab0d 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -147,7 +147,6 @@ class Preprocessor { IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ - IdentifierInfo *Ident__FILE_NAME__; // __FILE_NAME__ IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ IdentifierInfo *Ident__COUNTER__; // __COUNTER__ IdentifierInfo *Ident_Pragma, *Ident__pragma; // _Pragma, __pragma diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index bc25dcd8eadf..d698f0e6578c 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -363,7 +363,6 @@ void Preprocessor::RegisterBuiltinMacros() { } // Clang Extensions. - Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__"); Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature"); Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension"); Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin"); @@ -1475,8 +1474,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { // __LINE__ expands to a simple numeric value. OS << (PLoc.isValid()? PLoc.getLine() : 1); Tok.setKind(tok::numeric_constant); - } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ || - II == Ident__FILE_NAME__) { + } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) { // C99 6.10.8: "__FILE__: The presumed name of the current source file (a // character string literal)". This can be affected by #line. PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation()); @@ -1497,27 +1495,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { // Escape this filename. Turn '\' -> '\\' '"' -> '\"' SmallString<128> FN; if (PLoc.isValid()) { - // __FILE_NAME__ is a Clang-specific extension that expands to the - // the last part of __FILE__. - if (II == Ident__FILE_NAME__) { - // Try to get the last path component. - StringRef PLFileName = PLoc.getFilename(); - size_t LastSep = PLFileName.find_last_of('/'); -#ifdef _WIN32 - // On Windows targets, absolute paths can be normalized to use - // backslashes instead - handle this potential case here. - if (LastSep == StringRef::npos) - LastSep = PLFileName.find_last_of('\\'); -#endif - // Skip the separator and get the last part, otherwise fall back on - // returning the original full filename. - if (LastSep != StringRef::npos) - FN += PLFileName.substr(LastSep+1); - else - FN += PLFileName; - } else { - FN += PLoc.getFilename(); - } + FN += PLoc.getFilename(); Lexer::Stringify(FN); OS << '"' << FN << '"'; } diff --git a/clang/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h b/clang/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h deleted file mode 100644 index e974799b1f66..000000000000 --- a/clang/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h +++ /dev/null @@ -1,6 +0,0 @@ -3: __FILE_NAME__ -4: "file_name_macro_include.h" -#ifdef MS -// Should be the same even when included with backslash. -5: __FILE_NAME__ -#endif diff --git a/clang/test/Preprocessor/Inputs/include-subdir/h b/clang/test/Preprocessor/Inputs/include-subdir/h deleted file mode 100644 index b9839684e897..000000000000 --- a/clang/test/Preprocessor/Inputs/include-subdir/h +++ /dev/null @@ -1 +0,0 @@ -6: __FILE_NAME__ diff --git a/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h b/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h deleted file mode 100644 index f793be596c74..000000000000 --- a/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h +++ /dev/null @@ -1 +0,0 @@ -7: __FILE_NAME__ diff --git a/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h b/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h deleted file mode 100644 index 66860acc64d4..000000000000 --- a/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h +++ /dev/null @@ -1 +0,0 @@ -8: __FILE_NAME__ diff --git a/clang/test/Preprocessor/file_name_macro.c b/clang/test/Preprocessor/file_name_macro.c deleted file mode 100644 index 9dc9dc5684c5..000000000000 --- a/clang/test/Preprocessor/file_name_macro.c +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s -// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck -check-prefix=CHECK-MS -strict-whitespace %s -// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify - -#ifdef BADINC - -// Paranoia. - -__FILE_NAME__ -#include // expected-error {{file not found}} -__FILE_NAME__ - -#else - -// Reference. -1: "file_name_macro.c" - -// Ensure it expands correctly for this file. -2: __FILE_NAME__ - -// CHECK: {{^}}1: "file_name_macro.c" -// CHECK: {{^}}2: "file_name_macro.c" - -// Test if inclusion works right. -#ifdef MS -#include -// MS compatibility allows for mixed separators in paths. -#include -#include -#else -#include -#endif - -#include - -// CHECK: {{^}}3: "file_name_macro_include.h" -// CHECK: {{^}}4: "file_name_macro_include.h" -// CHECK-NOT: {{^}}5: "file_name_macro_include.h" -// CHECK-MS: {{^}}5: "file_name_macro_include.h" -// CHECK: {{^}}6: "h" -// CHECK-MS: {{^}}7: "hdr1.h" -// CHECK-MS: {{^}}8: "hdr2.h" - -#endif