llvm-project/clang/lib/Lex
Nico Weber b9d50bdff2 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
2020-05-01 14:17:01 -04:00
..
CMakeLists.txt
DependencyDirectivesSourceMinimizer.cpp Avoid including FileSystem.h from MemoryBuffer.h 2020-02-29 12:30:23 -08:00
HeaderMap.cpp FileManager: Use llvm::Expected in new getFileRef API 2019-08-26 18:29:51 +00:00
HeaderSearch.cpp Improve diagnostics for missing import / #include of module. 2020-04-28 18:41:14 -07:00
Lexer.cpp Rename warning identifiers from cxx2a to cxx20; NFC. 2020-04-22 14:31:13 -04:00
LiteralSupport.cpp C++2a -> C++20 in some identifiers; NFC. 2020-04-21 15:37:19 -04:00
MacroArgs.cpp
MacroInfo.cpp
ModuleMap.cpp Improve diagnostics for missing import / #include of module. 2020-04-28 18:41:14 -07:00
PPCaching.cpp
PPCallbacks.cpp Avoid including FileManager.h from SourceManager.h 2020-03-11 13:53:12 -07:00
PPConditionalDirectiveRecord.cpp
PPDirectives.cpp Fix pr31836 on Windows too, and correctly handle repeated separators. 2020-05-01 14:17:01 -04:00
PPExpressions.cpp
PPLexerChange.cpp [clang] Make sure argument expansion locations are correct in presence of predefined buffer 2020-04-22 21:01:52 +02:00
PPMacroExpansion.cpp Fix tests on Windows after D49466 2019-11-26 16:15:39 -08:00
Pragma.cpp PragmaNamespace::Handlers: Use unique_ptr to simplify memory management 2020-04-28 22:31:15 -07:00
PreprocessingRecord.cpp
Preprocessor.cpp Make -fno-char8_t disable the char8_t keyword, even in C++20. 2020-04-28 23:49:35 -07:00
PreprocessorLexer.cpp
ScratchBuffer.cpp
TokenConcatenation.cpp C++2a -> C++20 in some identifiers; NFC. 2020-04-21 15:37:19 -04:00
TokenLexer.cpp
UnicodeCharSets.h clang: Fix typo in comment 2019-08-21 15:41:29 +00:00