]> granicus.if.org Git - clang/commitdiff
Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters
authorTaewook Oh <twoh@fb.com>
Tue, 21 Feb 2017 22:30:55 +0000 (22:30 +0000)
committerTaewook Oh <twoh@fb.com>
Tue, 21 Feb 2017 22:30:55 +0000 (22:30 +0000)
Summary: This is a patch for PR31836. As the bug replaces the path separators in the included file name with the characters following them, the test script makes sure that there's no "Ccase-insensitive-include-pr31836.h" in the warning message.

Reviewers: rsmith, eric_niebler

Reviewed By: eric_niebler

Subscribers: karies, cfe-commits

Differential Revision: https://reviews.llvm.org/D30000

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295779 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPDirectives.cpp
test/Lexer/case-insensitive-include-pr31836.sh [new file with mode: 0644]

index 811f7ff9542ba526d2e388a14c0f5178049fda3a..8a56ddf2369912365aab620ebd47ca11adac84c3 100644 (file)
@@ -1976,8 +1976,12 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
       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] :
diff --git a/test/Lexer/case-insensitive-include-pr31836.sh b/test/Lexer/case-insensitive-include-pr31836.sh
new file mode 100644 (file)
index 0000000..a419f26
--- /dev/null
@@ -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