[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

Craig, Ben via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 4 06:36:00 PST 2016


On 3/4/2016 6:23 AM, Joerg Sonnenberger via cfe-commits wrote:
> On Thu, Mar 03, 2016 at 04:50:11PM -0800, Nico Weber via cfe-commits wrote:
>> On Thu, Mar 3, 2016 at 4:28 PM, Joerg Sonnenberger via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>>
>>> On Thu, Mar 03, 2016 at 02:09:17PM -0800, Nico Weber via cfe-commits wrote:
>>>> On Thu, Mar 3, 2016 at 1:50 PM, Joerg Sonnenberger via cfe-commits <
>>>> cfe-commits at lists.llvm.org> wrote:
>>>>
>>>>> On Thu, Mar 03, 2016 at 07:39:04PM +0000, Weiming Zhao via cfe-commits
>>>>> wrote:
>>>>>> Change the option name to -ffile-macro-prefix-to-remove
>>>>> This still sounds to me like a solution for a very restricted part of a
>>>>> much more generic problem...
>>>>>
>>>> What do you mean?
>>> Storing only the base name of file names is a strict subset of __FILE__
>>> transformations. As mentioned in the linked GCC PR, other uses are
>>> creating build location independent output for larger software projects
>>> etc. For that, reducing to the base name is not an option as it removes
>>> too much information.
>>>
>> But ffile-macro-prefix-to-remove has a general prefix arg, which you can
>> set to your build dir. This isn't just a "get me the basename" flag (?)
> It doesn't help to make sure that path names are always using /usr/src
> or src/ and build/ without requiring those to be part of the build
> layout. Another instance not handled is symlink trees for controlling
> access, where you still want to use the original path etc.
>
This isn't changing the defaults.  In addition, you could have a mix of 
files in the same binary, some with ffile-macro-prefix-to-remove set, 
and some without.  In cases where the user wants to be explicit about 
full name vs. base name in the source, this patch also provides 
__CLANG_FILE_BASENAME__.

There doesn't seem to be one approach to improve all of the existing use 
cases.  This patch provides two independent tools that can be used to 
improve many of the use cases.

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160304/2a4c73b2/attachment.html>


More information about the cfe-commits mailing list