[PATCH] Fix for include file resolution on Windows

Sharif Elcott sharifelcottclangllvm at mailinator.com
Wed Jan 7 15:44:31 PST 2015


Fix for failure to resolve include files on Windows when the files in question are virtual, i.e. created with mapVirtualFile(). The files are searched for in a hash which is keyed on the file's normalized path as a string. Searches for a file in that hash will fail unless the search path is in the exact same textual form.

http://reviews.llvm.org/D6871

Files:
  lib/Lex/HeaderSearch.cpp
  lib/Lex/PPDirectives.cpp

Index: lib/Lex/HeaderSearch.cpp
===================================================================
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -613,10 +613,8 @@
       const FileEntry *Includer = IncluderAndDir.first;

       // Concatenate the requested file onto the directory.
-      // FIXME: Portability.  Filename concatenation should be in sys::Path.
       TmpDir = IncluderAndDir.second->getName();
-      TmpDir.push_back('/');
-      TmpDir.append(Filename.begin(), Filename.end());
+      llvm::sys::path::append(TmpDir, Filename);

       // FIXME: We don't cache the result of getFileInfo across the call to
       // getFileAndSuggestModule, because it's a reference to an element of
Index: lib/Lex/PPDirectives.cpp
===================================================================
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1553,9 +1553,7 @@
   SmallString<128> NormalizedPath;
   if (LangOpts.MSVCCompat) {
     NormalizedPath = Filename.str();
-#ifndef LLVM_ON_WIN32
     llvm::sys::path::native(NormalizedPath);
-#endif
   }
   const FileEntry *File = LookupFile(
       FilenameLoc, LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename,

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6871.17877.patch
Type: text/x-patch
Size: 1199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150107/c5731c2e/attachment.bin>


More information about the cfe-commits mailing list