[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

Taewook Oh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 11:45:06 PST 2017


twoh updated this revision to Diff 88584.
twoh added a comment.

Make it explicit that the test doesn't support windows. @eric_niebler, my original intention was avoiding use of platform-dependent path separator, but now made it explicit that the test is not for windows, it should be okay to use '/'. Thanks for the comments!


https://reviews.llvm.org/D30000

Files:
  lib/Lex/PPDirectives.cpp
  test/Lexer/case-insensitive-include-pr31836.sh


Index: test/Lexer/case-insensitive-include-pr31836.sh
===================================================================
--- /dev/null
+++ test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 -E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-SAME: /case-insensitive-include-pr31836.h
Index: lib/Lex/PPDirectives.cpp
===================================================================
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
       SmallString<128> Path;
       Path.reserve(Name.size()+2);
       Path.push_back(isAngled ? '<' : '"');
+      bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
       for (auto Component : Components) {
-        Path.append(Component);
+        if (isLeadingSeparator)
+          isLeadingSeparator = false;
+        else
+          Path.append(Component);
         // Append the separator the user used, or the close quote
         Path.push_back(
           Path.size() <= Filename.size() ? Filename[Path.size()-1] :


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30000.88584.patch
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170215/a48dd885/attachment.bin>


More information about the cfe-commits mailing list