Reland "[Clang][PP] Add the __FILE_NAME__ builtin macro"
authorKristina Brooks <notstina@gmail.com>
Thu, 16 May 2019 21:13:49 +0000 (21:13 +0000)
committerKristina Brooks <notstina@gmail.com>
Thu, 16 May 2019 21:13:49 +0000 (21:13 +0000)
commitbd9748424165c24280ec1b2ddbe4e7522b15dc96
tree2af4356cc6139c2b8ad7cd34ad1aa5a74e936c2a
parent708afb56c125ca4f7db7070e836860076c7eafbc
Reland "[Clang][PP] Add the __FILE_NAME__ builtin macro"

This relands commit rL360833 which caused issues on Win32
bots due to path handling/normalization differences. Now
this uses `sys::path::filename` which should handle
additional edge cases on Win32.

Original commit:

"[Clang][PP] Add the __FILE_NAME__ builtin macro"

This patch adds the __FILE_NAME__ macro that expands to the
last component of the path, similar to __FILE__ except with
a guarantee that only the last path component (without the
separator) will be rendered.

I intend to follow through with discussion of this with WG14
as a potential inclusion in the C standard or failing that,
try to discuss this with GCC developers since this extension
is desired by GCC and Clang users/developers alike.

Differential Revision: https://reviews.llvm.org/D61756

llvm-svn: 360938
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h [new file with mode: 0644]
clang/test/Preprocessor/Inputs/include-subdir/h [new file with mode: 0644]
clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h [new file with mode: 0644]
clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h [new file with mode: 0644]
clang/test/Preprocessor/file_name_macro.c [new file with mode: 0644]