<div dir="ltr">I'm getting lots of warnings like so:<div><br></div><div><div>In file included from ..\..\tools\win\static_initializers\static_initializers.cc:5:</div><div>C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]</div><div>#include "windows.h"</div><div>         ^~~~~~~~~~~</div><div>         "Windows.h"</div></div><div><br></div><div>dia2.h is a system include, and we include it in the search path via -imsvc. Normally warnings aren't emitted for system headers. Do you know why this is happening here?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: twoh<br>
Date: Fri Jun  3 13:52:51 2016<br>
New Revision: 271708<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271708&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271708&view=rev</a><br>
Log:<br>
Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D19843" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19843</a><br>
Corresponding LLVM change: <a href="http://reviews.llvm.org/D19842" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19842</a><br>
<br>
Patch by Eric Niebler<br>
<br>
<br>
Added:<br>
    cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h<br>
    cfe/trunk/test/Lexer/case-insensitive-include-ms.c<br>
    cfe/trunk/test/Lexer/case-insensitive-include.c<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td<br>
    cfe/trunk/include/clang/Basic/FileManager.h<br>
    cfe/trunk/include/clang/Basic/VirtualFileSystem.h<br>
    cfe/trunk/include/clang/Lex/DirectoryLookup.h<br>
    cfe/trunk/include/clang/Lex/HeaderSearch.h<br>
    cfe/trunk/lib/Basic/FileManager.cpp<br>
    cfe/trunk/lib/Basic/VirtualFileSystem.cpp<br>
    cfe/trunk/lib/Lex/HeaderSearch.cpp<br>
    cfe/trunk/lib/Lex/PPDirectives.cpp<br>
    cfe/trunk/test/PCH/case-insensitive-include.c<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51 2016<br>
@@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq<br>
 def AmbiguousMacro : DiagGroup<"ambiguous-macro">;<br>
 def KeywordAsMacro : DiagGroup<"keyword-macro">;<br>
 def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;<br>
+def NonportableIncludePath : DiagGroup<"nonportable-include-path">;<br>
<br>
 // Just silence warnings about -Wstrict-aliasing for now.<br>
 def : DiagGroup<"strict-aliasing=0">;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3 13:52:51 2016<br>
@@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n<br>
   "whitespace required after macro name">;<br>
 def warn_missing_whitespace_after_macro_name : Warning<<br>
   "whitespace recommended after macro name">;<br>
+def pp_nonportable_path : Warning<<br>
+  "non-portable path to file '%0'; specified path differs in case from file"<br>
+  " name on disk">,<br>
+  InGroup<NonportableIncludePath>;<br>
<br>
 def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,<br>
   InGroup<DiagGroup<"pragma-once-outside-header">>;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/FileManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/FileManager.h (original)<br>
+++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016<br>
@@ -52,6 +52,7 @@ public:<br>
 /// descriptor for the file.<br>
 class FileEntry {<br>
   const char *Name;           // Name of the file.<br>
+  std::string RealPathName;   // Real path to the file; could be empty.<br>
   off_t Size;                 // File size in bytes.<br>
   time_t ModTime;             // Modification time of file.<br>
   const DirectoryEntry *Dir;  // Directory file lives in.<br>
@@ -82,6 +83,7 @@ public:<br>
   }<br>
<br>
   const char *getName() const { return Name; }<br>
+  StringRef tryGetRealPathName() const { return RealPathName; }<br>
   bool isValid() const { return IsValid; }<br>
   off_t getSize() const { return Size; }<br>
   unsigned getUID() const { return UID; }<br>
<br>
Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)<br>
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3 13:52:51 2016<br>
@@ -91,6 +91,13 @@ public:<br>
   virtual ~File();<br>
   /// \brief Get the status of the file.<br>
   virtual llvm::ErrorOr<Status> status() = 0;<br>
+  /// \brief Get the name of the file<br>
+  virtual llvm::ErrorOr<StringRef> getName() {<br>
+    if (auto Status = status())<br>
+      return Status->getName();<br>
+    else<br>
+      return Status.getError();<br>
+  }<br>
   /// \brief Get the contents of the file as a \p MemoryBuffer.<br>
   virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>><br>
   getBuffer(const Twine &Name, int64_t FileSize = -1,<br>
<br>
Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h (original)<br>
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h Fri Jun  3 13:52:51 2016<br>
@@ -151,6 +151,9 @@ public:<br>
   ///<br>
   /// \param HS The header search instance to search with.<br>
   ///<br>
+  /// \param IncludeLoc the source location of the #include or #import<br>
+  /// directive.<br>
+  ///<br>
   /// \param SearchPath If not NULL, will be set to the search path relative<br>
   /// to which the file was found.<br>
   ///<br>
@@ -172,6 +175,7 @@ public:<br>
   /// a framework include ("Foo.h" -> "Foo/Foo.h"), set the new name to this<br>
   /// vector and point Filename to it.<br>
   const FileEntry *LookupFile(StringRef &Filename, HeaderSearch &HS,<br>
+                              SourceLocation IncludeLoc,<br>
                               SmallVectorImpl<char> *SearchPath,<br>
                               SmallVectorImpl<char> *RelativePath,<br>
                               Module *RequestingModule,<br>
<br>
Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)<br>
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Fri Jun  3 13:52:51 2016<br>
@@ -580,8 +580,9 @@ private:<br>
   /// \brief Look up the file with the specified name and determine its owning<br>
   /// module.<br>
   const FileEntry *<br>
-  getFileAndSuggestModule(StringRef FileName, const DirectoryEntry *Dir,<br>
-                          bool IsSystemHeaderDir, Module *RequestingModule,<br>
+  getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc,<br>
+                          const DirectoryEntry *Dir, bool IsSystemHeaderDir,<br>
+                          Module *RequestingModule,<br>
                           ModuleMap::KnownHeader *SuggestedModule);<br>
<br>
 public:<br>
<br>
Modified: cfe/trunk/lib/Basic/FileManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/FileManager.cpp (original)<br>
+++ cfe/trunk/lib/Basic/FileManager.cpp Fri Jun  3 13:52:51 2016<br>
@@ -312,6 +312,9 @@ const FileEntry *FileManager::getFile(St<br>
   UFE.InPCH = Data.InPCH;<br>
   UFE.File = std::move(F);<br>
   UFE.IsValid = true;<br>
+  if (UFE.File)<br>
+    if (auto RealPathName = UFE.File->getName())<br>
+      UFE.RealPathName = RealPathName->str();<br>
   return &UFE;<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)<br>
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Jun  3 13:52:51 2016<br>
@@ -140,16 +140,19 @@ namespace {<br>
 class RealFile : public File {<br>
   int FD;<br>
   Status S;<br>
+  std::string RealName;<br>
   friend class RealFileSystem;<br>
-  RealFile(int FD, StringRef NewName)<br>
+  RealFile(int FD, StringRef NewName, StringRef NewRealPathName)<br>
       : FD(FD), S(NewName, {}, {}, {}, {}, {},<br>
-                  llvm::sys::fs::file_type::status_error, {}) {<br>
+                  llvm::sys::fs::file_type::status_error, {}),<br>
+        RealName(NewRealPathName.str()) {<br>
     assert(FD >= 0 && "Invalid or inactive file descriptor");<br>
   }<br>
<br>
 public:<br>
   ~RealFile() override;<br>
   ErrorOr<Status> status() override;<br>
+  ErrorOr<StringRef> getName() override;<br>
   ErrorOr<std::unique_ptr<MemoryBuffer>> getBuffer(const Twine &Name,<br>
                                                    int64_t FileSize,<br>
                                                    bool RequiresNullTerminator,<br>
@@ -170,6 +173,10 @@ ErrorOr<Status> RealFile::status() {<br>
   return S;<br>
 }<br>
<br>
+ErrorOr<StringRef> RealFile::getName() {<br>
+  return RealName.empty() ? S.getName() : StringRef(RealName);<br>
+}<br>
+<br>
 ErrorOr<std::unique_ptr<MemoryBuffer>><br>
 RealFile::getBuffer(const Twine &Name, int64_t FileSize,<br>
                     bool RequiresNullTerminator, bool IsVolatile) {<br>
@@ -207,9 +214,10 @@ ErrorOr<Status> RealFileSystem::status(c<br>
 ErrorOr<std::unique_ptr<File>><br>
 RealFileSystem::openFileForRead(const Twine &Name) {<br>
   int FD;<br>
-  if (std::error_code EC = sys::fs::openFileForRead(Name, FD))<br>
+  SmallString<256> RealName;<br>
+  if (std::error_code EC = sys::fs::openFileForRead(Name, FD, &RealName))<br>
     return EC;<br>
-  return std::unique_ptr<File>(new RealFile(FD, Name.str()));<br>
+  return std::unique_ptr<File>(new RealFile(FD, Name.str(), RealName.str()));<br>
 }<br>
<br>
 llvm::ErrorOr<std::string> RealFileSystem::getCurrentWorkingDirectory() const {<br>
<br>
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)<br>
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Jun  3 13:52:51 2016<br>
@@ -250,8 +250,9 @@ const char *DirectoryLookup::getName() c<br>
 }<br>
<br>
 const FileEntry *HeaderSearch::getFileAndSuggestModule(<br>
-    StringRef FileName, const DirectoryEntry *Dir, bool IsSystemHeaderDir,<br>
-    Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) {<br>
+    StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,<br>
+    bool IsSystemHeaderDir, Module *RequestingModule,<br>
+    ModuleMap::KnownHeader *SuggestedModule) {<br>
   // If we have a module map that might map this header, load it and<br>
   // check whether we'll have a suggestion for a module.<br>
   const FileEntry *File = getFileMgr().getFile(FileName, /*OpenFile=*/true);<br>
@@ -272,6 +273,7 @@ const FileEntry *HeaderSearch::getFileAn<br>
 const FileEntry *DirectoryLookup::LookupFile(<br>
     StringRef &Filename,<br>
     HeaderSearch &HS,<br>
+    SourceLocation IncludeLoc,<br>
     SmallVectorImpl<char> *SearchPath,<br>
     SmallVectorImpl<char> *RelativePath,<br>
     Module *RequestingModule,<br>
@@ -297,7 +299,7 @@ const FileEntry *DirectoryLookup::Lookup<br>
       RelativePath->append(Filename.begin(), Filename.end());<br>
     }<br>
<br>
-    return HS.getFileAndSuggestModule(TmpDir, getDir(),<br>
+    return HS.getFileAndSuggestModule(TmpDir, IncludeLoc, getDir(),<br>
                                       isSystemHeaderDirectory(),<br>
                                       RequestingModule, SuggestedModule);<br>
   }<br>
@@ -585,7 +587,7 @@ const FileEntry *HeaderSearch::LookupFil<br>
       RelativePath->append(Filename.begin(), Filename.end());<br>
     }<br>
     // Otherwise, just return the file.<br>
-    return getFileAndSuggestModule(Filename, nullptr,<br>
+    return getFileAndSuggestModule(Filename, IncludeLoc, nullptr,<br>
                                    /*IsSystemHeaderDir*/false,<br>
                                    RequestingModule, SuggestedModule);<br>
   }<br>
@@ -622,7 +624,7 @@ const FileEntry *HeaderSearch::LookupFil<br>
           Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User :<br>
           BuildSystemModule;<br>
       if (const FileEntry *FE = getFileAndSuggestModule(<br>
-              TmpDir, IncluderAndDir.second, IncluderIsSystemHeader,<br>
+              TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader,<br>
               RequestingModule, SuggestedModule)) {<br>
         if (!Includer) {<br>
           assert(First && "only first includer can have no file");<br>
@@ -713,7 +715,7 @@ const FileEntry *HeaderSearch::LookupFil<br>
     bool InUserSpecifiedSystemFramework = false;<br>
     bool HasBeenMapped = false;<br>
     const FileEntry *FE = SearchDirs[i].LookupFile(<br>
-        Filename, *this, SearchPath, RelativePath, RequestingModule,<br>
+        Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,<br>
         SuggestedModule, InUserSpecifiedSystemFramework, HasBeenMapped,<br>
         MappedName);<br>
     if (HasBeenMapped) {<br>
<br>
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Jun  3 13:52:51 2016<br>
@@ -24,6 +24,9 @@<br>
 #include "clang/Lex/ModuleLoader.h"<br>
 #include "clang/Lex/Pragma.h"<br>
 #include "llvm/ADT/APInt.h"<br>
+#include "llvm/ADT/STLExtras.h"<br>
+#include "llvm/ADT/StringExtras.h"<br>
+#include "llvm/ADT/iterator_range.h"<br>
 #include "llvm/Support/ErrorHandling.h"<br>
 #include "llvm/Support/Path.h"<br>
 #include "llvm/Support/SaveAndRestore.h"<br>
@@ -1556,6 +1559,41 @@ static void diagnoseAutoModuleImport(<br>
                                       ("@import " + PathString + ";").str());<br>
 }<br>
<br>
+namespace {<br>
+  // Given a vector of path components and a string containing the real<br>
+  // path to the file, build a properly-cased replacement in the vector,<br>
+  // and return true if the replacement should be suggested.<br>
+  bool TrySimplifyPath(SmallVectorImpl<StringRef> &Components,<br>
+                       StringRef RealPathName) {<br>
+    auto RealPathComponentIter = llvm::sys::path::rbegin(RealPathName);<br>
+    auto RealPathComponentEnd = llvm::sys::path::rend(RealPathName);<br>
+    int Cnt = 0;<br>
+    bool SuggestReplacement = false;<br>
+    // Below is a best-effort to handle ".." in paths. It is admittedly<br>
+    // not 100% correct in the presence of symlinks.<br>
+    for(auto &Component : llvm::reverse(Components)) {<br>
+      if ("." == Component) {<br>
+      } else if (".." == Component) {<br>
+        ++Cnt;<br>
+      } else if (Cnt) {<br>
+        --Cnt;<br>
+      } else if (RealPathComponentIter != RealPathComponentEnd) {<br>
+        if (Component != *RealPathComponentIter) {<br>
+          // If these path components differ by more than just case, then we<br>
+          // may be looking at symlinked paths. Bail on this diagnostic to avoid<br>
+          // noisy false positives.<br>
+          SuggestReplacement = RealPathComponentIter->equals_lower(Component);<br>
+          if (!SuggestReplacement)<br>
+            break;<br>
+          Component = *RealPathComponentIter;<br>
+        }<br>
+        ++RealPathComponentIter;<br>
+      }<br>
+    }<br>
+    return SuggestReplacement;<br>
+  }<br>
+}<br>
+<br>
 /// HandleIncludeDirective - The "\#include" tokens have just been read, read<br>
 /// the file to be included from the lexer, then include it!  This is a common<br>
 /// routine with functionality shared between \#include, \#include_next and<br>
@@ -1720,6 +1758,35 @@ void Preprocessor::HandleIncludeDirectiv<br>
     }<br>
   }<br>
<br>
+  // Issue a diagnostic if the name of the file on disk has a different case<br>
+  // than the one we're about to open.<br>
+  const bool CheckIncludePathPortability =<br>
+    File && !File->tryGetRealPathName().empty();<br>
+<br>
+  if (CheckIncludePathPortability) {<br>
+    StringRef Name = LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename;<br>
+    StringRef RealPathName = File->tryGetRealPathName();<br>
+    SmallVector<StringRef, 16> Components(llvm::sys::path::begin(Name),<br>
+                                          llvm::sys::path::end(Name));<br>
+<br>
+    if (TrySimplifyPath(Components, RealPathName)) {<br>
+      SmallString<128> Path;<br>
+      Path.reserve(Name.size()+2);<br>
+      Path.push_back(isAngled ? '<' : '"');<br>
+      for (auto Component : Components) {<br>
+        Path.append(Component);<br>
+        // Append the separator the user used, or the close quote<br>
+        Path.push_back(<br>
+          Path.size() <= Filename.size() ? Filename[Path.size()-1] :<br>
+            (isAngled ? '>' : '"'));<br>
+      }<br>
+      auto Replacement = Path.str().str();<br>
+      SourceRange Range(FilenameTok.getLocation(), CharEnd);<br>
+      Diag(FilenameTok, diag::pp_nonportable_path) << Replacement <<<br>
+        FixItHint::CreateReplacement(Range, Replacement);<br>
+    }<br>
+  }<br>
+<br>
   // Should we enter the source file? Set to false if either the source file is<br>
   // known to have no effect beyond its effect on module visibility -- that is,<br>
   // if it's got an include guard that is already defined or is a modular header<br>
<br>
Added: cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h?rev=271708&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h?rev=271708&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h (added)<br>
+++ cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h Fri Jun  3 13:52:51 2016<br>
@@ -0,0 +1,5 @@<br>
+#pragma once<br>
+<br>
+struct S {<br>
+  int x;<br>
+};<br>
<br>
Added: cfe/trunk/test/Lexer/case-insensitive-include-ms.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/case-insensitive-include-ms.c?rev=271708&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/case-insensitive-include-ms.c?rev=271708&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/case-insensitive-include-ms.c (added)<br>
+++ cfe/trunk/test/Lexer/case-insensitive-include-ms.c Fri Jun  3 13:52:51 2016<br>
@@ -0,0 +1,18 @@<br>
+// REQUIRES: case-insensitive-filesystem<br>
+<br>
+// RUN: mkdir -p %T/apath<br>
+// RUN: cp %S/Inputs/case-insensitive-include.h %T<br>
+// RUN: cd %T<br>
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s -include %s -I %T -verify<br>
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -fdiagnostics-parseable-fixits %s -include %s -I %T 2>&1 | FileCheck %s<br>
+<br>
+#include "..\Output\.\case-insensitive-include.h"<br>
+#include "..\Output\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""<br>
+#include "..\output\.\case-insensitive-include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""<br>
+<br>
+#include "apath\..\.\case-insensitive-include.h"<br>
+#include "apath\..\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath\\..\\.\\case-insensitive-include.h\""<br>
+#include "APath\..\.\case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(<br>
<br>
Added: cfe/trunk/test/Lexer/case-insensitive-include.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/case-insensitive-include.c?rev=271708&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/case-insensitive-include.c?rev=271708&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/case-insensitive-include.c (added)<br>
+++ cfe/trunk/test/Lexer/case-insensitive-include.c Fri Jun  3 13:52:51 2016<br>
@@ -0,0 +1,27 @@<br>
+// REQUIRES: case-insensitive-filesystem<br>
+<br>
+// RUN: mkdir -p %T/apath<br>
+// RUN: cp %S/Inputs/case-insensitive-include.h %T<br>
+// RUN: cd %T<br>
+// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify<br>
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -include %s -I %T 2>&1 | FileCheck %s<br>
+<br>
+#include "case-insensitive-include.h"<br>
+#include "Case-Insensitive-Include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:38}:"\"case-insensitive-include.h\""<br>
+<br>
+#include "../Output/./case-insensitive-include.h"<br>
+#include "../Output/./Case-Insensitive-Include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"../Output/./case-insensitive-include.h\""<br>
+#include "../output/./case-insensitive-include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"../Output/./case-insensitive-include.h\""<br>
+<br>
+#include "apath/.././case-insensitive-include.h"<br>
+#include "apath/.././Case-Insensitive-Include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath/.././case-insensitive-include.h\""<br>
+#include "APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(<br>
+<br>
+#include "../Output/./apath/.././case-insensitive-include.h"<br>
+#include "../Output/./APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(<br>
+#include "../output/./apath/.././case-insensitive-include.h" // expected-warning {{non-portable path}}<br>
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:61}:"\"../Output/./apath/.././case-insensitive-include.h\""<br>
<br>
Modified: cfe/trunk/test/PCH/case-insensitive-include.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/case-insensitive-include.c?rev=271708&r1=271707&r2=271708&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/case-insensitive-include.c?rev=271708&r1=271707&r2=271708&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/PCH/case-insensitive-include.c (original)<br>
+++ cfe/trunk/test/PCH/case-insensitive-include.c Fri Jun  3 13:52:51 2016<br>
@@ -2,7 +2,7 @@<br>
<br>
 // Test this without pch.<br>
 // RUN: cp %S/Inputs/case-insensitive-include.h %T<br>
-// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify<br>
+// RUN: %clang_cc1 -Wno-nonportable-include-path -fsyntax-only %s -include %s -I %T -verify<br>
<br>
 // Test with pch.<br>
 // RUN: %clang_cc1 -emit-pch -o %t.pch %s -I %T<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>