[all-commits] [llvm/llvm-project] b9d50b: Fix pr31836 on Windows too, and correctly handle r...
Nico Weber via All-commits
all-commits at lists.llvm.org
Fri May 1 11:17:37 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: b9d50bdff211eb806dce5bc42167a6b9c0cac6e6
https://github.com/llvm/llvm-project/commit/b9d50bdff211eb806dce5bc42167a6b9c0cac6e6
Author: Nico Weber <thakis at chromium.org>
Date: 2020-05-01 (Fri, 01 May 2020)
Changed paths:
M clang/lib/Lex/PPDirectives.cpp
M clang/test/Lexer/case-insensitive-include-ms.c
M clang/test/Lexer/case-insensitive-include-pr31836.sh
M clang/test/Lexer/case-insensitive-include.c
M llvm/include/llvm/Support/Path.h
M llvm/unittests/Support/Path.cpp
Log Message:
-----------
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
More information about the All-commits
mailing list