[PATCH] D17741: adds __FILE_BASENAME__ builtin macro
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 29 18:25:58 PST 2016
thakis added a comment.
In http://reviews.llvm.org/D17741#364931, @weimingz wrote:
> In http://reviews.llvm.org/D17741#364756, @thakis wrote:
> > Instead of doing this, would it make sense to have a flag like -ffile-basename that changes what __FILE__ expands to?
> > I had wished I'd be able to have some control over __FILE__ (I'd like to say "make all __FILE__s relative to this given directory for my use case), and changing __FILE__ to something else in all the world's code isn't easy – so maybe having a flag that provides some control over __FILE__ instead of adding a separate macro would be a good idea.
> do you mean this?
> if source file is /a/b/c/d/foo.c and if -ffile-name-stem-remove=/a/b/c, then _FILE_ will be expanded to "d/foo.c" ?
Yes, something like that. Maybe it could look like `-f__file__-expansion=basename` (to make __FILE__ expand to just the basename, what you want), `-f__file__-expansion=relative-to:/a/b/c` to make it relative to a given path.
More information about the cfe-commits