[cfe-dev] Feature proposal: Compile Configuration Disclosure
James Widman
widman at gimpel.com
Wed Mar 3 18:40:01 PST 2010
On Mar 3, 2010, at 9:20 PM, James Widman wrote:
> On Mar 3, 2010, at 7:05 PM, Douglas Gregor wrote:
>
>>
>> On Mar 3, 2010, at 2:44 PM, James Widman wrote:
>>
>>> - The path name of the primary source file;
>>>
>>> - The working directory;
>>>
>>> - Environment variables;
>>
>> How would these affect translation ???
>
> Well, some compilers depend on environment variables.
Ack; forgot the other two bullets.
- The path name of the primary source file
Ho else would we know which .cpp file to parse?
Also, note that pre-defined macros, the #include search path (and generally, details about how the compiler is invoked) can vary from TU to TU. So in:
clang --disclose-config -DBAR -c x.cpp -o foo.o
... the file foo.o.config-disclosure would reveal not just that clang was once invoked with a predefined "#define BAR 1", but that this invocation was used on x.cpp. Now, when a tool processes x.cpp, it's guaranteed to start with the same set of predefined macros that clang started with. The set---er, sorry; the *sequence* of predefined macros may differ for y.cpp.
- The working directory
You could easily have more than one "x.cpp" in a directory tree. One might then suggest that x.cpp's full pathname be output instead. And that's fine, but:
- it could have an effect on how x.cpp is cited in diagnostics.
- in the process of forming the full pathname, you first have to get the working directory anyway.
Also,-I options typically include things like -I. and -I../asdf.
James Widman
--
Gimpel Software
http://gimpel.com
More information about the cfe-dev
mailing list