[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

Alan Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 14 10:52:13 PDT 2022


ayzhao added a subscriber: rsmith.
ayzhao added a comment.

In D122766#3451775 <https://reviews.llvm.org/D122766#3451775>, @hans wrote:

> In D122766#3450298 <https://reviews.llvm.org/D122766#3450298>, @ayzhao wrote:
>
>> So, the general consensus seems to be that we should use backslashes when targeting Windows.
>>
>> I implemented using only backslashes for Windows; however, clang/test/SemaCXX/destructor.cpp <https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCXX/destructor.cpp> fails when running on Linux with the following error (among other errors, but the one below is the most important).
>>
>>   ...
>>   error: 'error' diagnostics seen but not expected:
>>     Line 32: '<REDACTED_PATH_TO_LLVM_CHECKOUT_WITH_BACKSLASHES>\\clang\\test\\SemaCXX\\destructor.cpp' file not found
>>   ...
>>
>> The reason for this is that the test has Clang target windows <https://github.com/llvm/llvm-project/blob/77d2c815f50b20d18f1207e4f442e2cf8eb8cec0/clang/test/SemaCXX/destructor.cpp#L2> and the test also has the statement #include __FILE__ <https://github.com/llvm/llvm-project/blob/77d2c815f50b20d18f1207e4f442e2cf8eb8cec0/clang/test/SemaCXX/destructor.cpp#L32>.
>
> That seems like an unusual use case of `__FILE__`. I wonder if we could just change the test to `#include "destructor.cpp"` instead and not worry about the case of `#include __FILE__` in cross-builds targeting Windows.

This line was introduced in D37235 <https://reviews.llvm.org/D37235> (coincidentally written by @thakis), and in that review, @rsmith made a comment on this exact line that said

> Do we guarantee that `__FILE__` names a path that can be used to include the current file? In other tests, we add `-include %s` to the `RUN:` line to model this situation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122766/new/

https://reviews.llvm.org/D122766



More information about the llvm-commits mailing list