[clang] [clang][lex] Fix non-portability diagnostics with absolute path (PR #74782)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 11 11:15:01 PST 2023
================
@@ -2466,15 +2466,21 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
// The drive letter is optional for absolute paths on Windows, but
// clang currently cannot process absolute paths in #include lines that
// don't have a drive.
- // If the first entry in Components is a directory separator,
- // then the code at the bottom of this loop that keeps the original
- // directory separator style copies it. If the second entry is
- // a directory separator (the C:\ case), then that separator already
- // got copied when the C: was processed and we want to skip that entry.
- if (!(Component.size() == 1 && IsSep(Component[0])))
+ if (Component.size() == 1 && IsSep(Component[0])) {
+ // Note: Path always contains at least '<' or '"'.
+ if (Path.size() == 1) {
----------------
jansvoboda11 wrote:
I find the code easier to think about with `if (Path.size() == 1) { x } else { y }` compared to `if (Path.size() != 1) { y; continue; } x` to be honest:
* The `Path.size() == 1` condition is more specific than `Path.size() != 1`.
* To think about the path to `x`, you don't have to do double negation and notice the early `continue`.
https://github.com/llvm/llvm-project/pull/74782
More information about the cfe-commits
mailing list