diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-08 07:49:23 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-08 07:49:23 +0000 |
commit | 10fe93d57c11f068aa4d78eb4ca7f60329818306 (patch) | |
tree | ed141b76b02d035abedebdec00c1b60c69f39fd5 /lib/Lex/HeaderSearch.cpp | |
parent | 09556fd1fb576144e2beda023bf3386f2292243b (diff) |
Revert r110440, the fix for PR4897. Chris claims to have a better way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110544 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index dfd99cec5b..4554ababf7 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -203,14 +203,14 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(llvm::StringRef Filename, /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file, /// return null on failure. isAngled indicates whether the file reference is -/// for system #include's or not (i.e. using <> instead of ""). RelSearchDir, -/// if non-empty, indicates where the #including file is, in case a relative -/// search is needed. +/// for system #include's or not (i.e. using <> instead of ""). CurFileEnt, if +/// non-null, indicates where the #including file is, in case a relative search +/// is needed. const FileEntry *HeaderSearch::LookupFile(llvm::StringRef Filename, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, - const llvm::sys::Path &RelPath) { + const FileEntry *CurFileEnt) { // If 'Filename' is absolute, check to see if it exists and no searching. if (llvm::sys::Path::isAbsolute(Filename.begin(), Filename.size())) { CurDir = 0; @@ -223,29 +223,25 @@ const FileEntry *HeaderSearch::LookupFile(llvm::StringRef Filename, } // Step #0, unless disabled, check to see if the file is in the #includer's - // directory. This has to be based on RelPath, not CurDir, because - // RelPath could be a #include of a subdirectory (#include "foo/bar.h") and + // directory. This has to be based on CurFileEnt, not CurDir, because + // CurFileEnt could be a #include of a subdirectory (#include "foo/bar.h") and // a subsequent include of "baz.h" should resolve to "whatever/foo/baz.h". // This search is not done for <> headers. - if (!RelPath.isEmpty() && !isAngled && !NoCurDirSearch) { - - // Default SrcMgr::CharacteristicKind - unsigned DirInfo = SrcMgr::C_User; - llvm::sys::Path TmpPath(RelPath); - - // Update DirInfo if needed and remove filename from path if - // treating actual file (the non-stdin case) - if (!TmpPath.isDirectory()) { - const FileEntry *MainFile = FileMgr.getFile(TmpPath.c_str()); - DirInfo = getFileInfo(MainFile).DirInfo; - TmpPath.eraseComponent(); - } - - // Formulate path to try - TmpPath.appendComponent(Filename); - llvm::StringRef RelSearchFilename(TmpPath.c_str()); - if (const FileEntry *FE = FileMgr.getFile(RelSearchFilename)) { + if (CurFileEnt && !isAngled && !NoCurDirSearch) { + llvm::SmallString<1024> TmpDir; + // Concatenate the requested file onto the directory. + // FIXME: Portability. Filename concatenation should be in sys::Path. + TmpDir += CurFileEnt->getDir()->getName(); + TmpDir.push_back('/'); + TmpDir.append(Filename.begin(), Filename.end()); + if (const FileEntry *FE = FileMgr.getFile(TmpDir.str())) { // Leave CurDir unset. + // This file is a system header or C++ unfriendly if the old file is. + // + // Note that the temporary 'DirInfo' is required here, as either call to + // getFileInfo could resize the vector and we don't want to rely on order + // of evaluation. + unsigned DirInfo = getFileInfo(CurFileEnt).DirInfo; getFileInfo(FE).DirInfo = DirInfo; return FE; } |