Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pr31836 on Windows too, and correctly handle repeated separators.
The approach in D30000 assumes that the '/' returned by path::begin() is the first element for absolute paths, but that's not true on Windows. Also, on Windows backslashes in include lines often end up escaped so that there are two of them. Having backslashes in include lines is undefined behavior in most cases and implementation-defined behavior in C++20, but since clang treats it as normal repeated path separators, the diagnostic should too. Unbreaks -Wnonportable-include-path for absolute paths on Windows, and unbreaks it on non-Windows in the case of absolute paths with repeated directory separators. This affects e.g. the `#include __FILE__` technique if the file passed to clang has the wrong case for the drive letter. Before: C:\src\llvm-project>bin\clang-cl.exe c:\src\llvm-project\test.cc c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file '"c\\srccllvm-projectctest.cc.'; specified path differs in case from file name on disk [-Wnonportable-include-path] ^ Now: C:\src\llvm-project> out\gn\bin\clang-cl c:\src\llvm-project\test.cc c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file '"C:\\src\\llvm-project\\test.cc"'; specified path differs in case from file name on disk [-Wnonportable-include-path] ^ Differential Revision: https://reviews.llvm.org/D79223
- Loading branch information
Showing
6 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters