diff options
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/HeaderMap.cpp | 10 | ||||
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 30 | ||||
-rw-r--r-- | lib/Lex/PTHLexer.cpp | 6 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 3 |
4 files changed, 31 insertions, 18 deletions
diff --git a/lib/Lex/HeaderMap.cpp b/lib/Lex/HeaderMap.cpp index 4010d613ac..5d9b218a7d 100644 --- a/lib/Lex/HeaderMap.cpp +++ b/lib/Lex/HeaderMap.cpp @@ -75,13 +75,14 @@ static inline unsigned HashHMapKey(llvm::StringRef Str) { /// map. If it doesn't look like a HeaderMap, it gives up and returns null. /// If it looks like a HeaderMap but is obviously corrupted, it puts a reason /// into the string error argument and returns null. -const HeaderMap *HeaderMap::Create(const FileEntry *FE) { +const HeaderMap *HeaderMap::Create(const FileEntry *FE, FileManager &FM, + const FileSystemOptions &FSOpts) { // If the file is too small to be a header map, ignore it. unsigned FileSize = FE->getSize(); if (FileSize <= sizeof(HMapHeader)) return 0; llvm::OwningPtr<const llvm::MemoryBuffer> FileBuffer( - llvm::MemoryBuffer::getFile(FE->getName(), 0, FE->getSize())); + FM.getBufferForFile(FE, FSOpts)); if (FileBuffer == 0) return 0; // Unreadable file? const char *FileStart = FileBuffer->getBufferStart(); @@ -200,7 +201,8 @@ void HeaderMap::dump() const { /// LookupFile - Check to see if the specified relative filename is located in /// this HeaderMap. If so, open it and return its FileEntry. const FileEntry *HeaderMap::LookupFile(llvm::StringRef Filename, - FileManager &FM) const { + FileManager &FM, + const FileSystemOptions &FileSystemOpts) const { const HMapHeader &Hdr = getHeader(); unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets); @@ -223,6 +225,6 @@ const FileEntry *HeaderMap::LookupFile(llvm::StringRef Filename, llvm::SmallString<1024> DestPath; DestPath += getString(B.Prefix); DestPath += getString(B.Suffix); - return FM.getFile(DestPath.begin(), DestPath.end()); + return FM.getFile(DestPath.begin(), DestPath.end(), FileSystemOpts); } } diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 4554ababf7..5a11652fc1 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -32,7 +32,8 @@ HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) { return ControllingMacro; } -HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) { +HeaderSearch::HeaderSearch(FileManager &FM, const FileSystemOptions &FSOpts) + : FileMgr(FM), FileSystemOpts(FSOpts), FrameworkMap(64) { SystemDirIdx = 0; NoCurDirSearch = false; @@ -83,7 +84,7 @@ const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) { return HeaderMaps[i].second; } - if (const HeaderMap *HM = HeaderMap::Create(FE)) { + if (const HeaderMap *HM = HeaderMap::Create(FE, FileMgr, FileSystemOpts)) { HeaderMaps.push_back(std::make_pair(FE, HM)); return HM; } @@ -118,14 +119,16 @@ const FileEntry *DirectoryLookup::LookupFile(llvm::StringRef Filename, TmpDir += getDir()->getName(); TmpDir.push_back('/'); TmpDir.append(Filename.begin(), Filename.end()); - return HS.getFileMgr().getFile(TmpDir.begin(), TmpDir.end()); + return HS.getFileMgr().getFile(TmpDir.begin(), TmpDir.end(), + HS.getFileSystemOpts()); } if (isFramework()) return DoFrameworkLookup(Filename, HS); assert(isHeaderMap() && "Unknown directory lookup"); - return getHeaderMap()->LookupFile(Filename, HS.getFileMgr()); + return getHeaderMap()->LookupFile(Filename, HS.getFileMgr(), + HS.getFileSystemOpts()); } @@ -134,6 +137,7 @@ const FileEntry *DirectoryLookup::LookupFile(llvm::StringRef Filename, const FileEntry *DirectoryLookup::DoFrameworkLookup(llvm::StringRef Filename, HeaderSearch &HS) const { FileManager &FileMgr = HS.getFileMgr(); + const FileSystemOptions &FileSystemOpts = HS.getFileSystemOpts(); // Framework names must have a '/' in the filename. size_t SlashPos = Filename.find('/'); @@ -184,7 +188,8 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(llvm::StringRef Filename, FrameworkName += "Headers/"; FrameworkName.append(Filename.begin()+SlashPos+1, Filename.end()); if (const FileEntry *FE = FileMgr.getFile(FrameworkName.begin(), - FrameworkName.end())) { + FrameworkName.end(), + FileSystemOpts)) { return FE; } @@ -192,7 +197,8 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(llvm::StringRef Filename, const char *Private = "Private"; FrameworkName.insert(FrameworkName.begin()+OrigSize, Private, Private+strlen(Private)); - return FileMgr.getFile(FrameworkName.begin(), FrameworkName.end()); + return FileMgr.getFile(FrameworkName.begin(), FrameworkName.end(), + FileSystemOpts); } @@ -219,7 +225,7 @@ const FileEntry *HeaderSearch::LookupFile(llvm::StringRef Filename, if (FromDir) return 0; // Otherwise, just return the file. - return FileMgr.getFile(Filename); + return FileMgr.getFile(Filename, FileSystemOpts); } // Step #0, unless disabled, check to see if the file is in the #includer's @@ -234,7 +240,7 @@ const FileEntry *HeaderSearch::LookupFile(llvm::StringRef Filename, TmpDir += CurFileEnt->getDir()->getName(); TmpDir.push_back('/'); TmpDir.append(Filename.begin(), Filename.end()); - if (const FileEntry *FE = FileMgr.getFile(TmpDir.str())) { + if (const FileEntry *FE = FileMgr.getFile(TmpDir.str(), FileSystemOpts)) { // Leave CurDir unset. // This file is a system header or C++ unfriendly if the old file is. // @@ -344,7 +350,8 @@ LookupSubframeworkHeader(llvm::StringRef Filename, // If the framework dir doesn't exist, we fail. const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.begin(), - FrameworkName.end()); + FrameworkName.end(), + FileSystemOpts); if (Dir == 0) return 0; // Otherwise, if it does, remember that this is the right direntry for this @@ -359,13 +366,14 @@ LookupSubframeworkHeader(llvm::StringRef Filename, HeadersFilename += "Headers/"; HeadersFilename.append(Filename.begin()+SlashPos+1, Filename.end()); if (!(FE = FileMgr.getFile(HeadersFilename.begin(), - HeadersFilename.end()))) { + HeadersFilename.end(), FileSystemOpts))) { // Check ".../Frameworks/HIToolbox.framework/PrivateHeaders/HIToolbox.h" HeadersFilename = FrameworkName; HeadersFilename += "PrivateHeaders/"; HeadersFilename.append(Filename.begin()+SlashPos+1, Filename.end()); - if (!(FE = FileMgr.getFile(HeadersFilename.begin(), HeadersFilename.end()))) + if (!(FE = FileMgr.getFile(HeadersFilename.begin(), HeadersFilename.end(), + FileSystemOpts))) return 0; } diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index 63b4823cf1..3d52159fa3 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -434,10 +434,12 @@ static void InvalidPTH(Diagnostic &Diags, const char *Msg) { Diags.Report(Diags.getCustomDiagID(Diagnostic::Error, Msg)); } -PTHManager* PTHManager::Create(const std::string& file, Diagnostic &Diags) { +PTHManager* PTHManager::Create(const std::string& file, FileManager &FileMgr, + const FileSystemOptions &FSOpts, + Diagnostic &Diags) { // Memory map the PTH file. llvm::OwningPtr<llvm::MemoryBuffer> - File(llvm::MemoryBuffer::getFile(file.c_str())); + File(FileMgr.getBufferForFile(file, FSOpts)); if (!File) { Diags.Report(diag::err_invalid_pth_file) << file; diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 1be22df6b1..ff18c3f324 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -53,7 +53,8 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts, IdentifierInfoLookup* IILookup, bool OwnsHeaders) : Diags(&diags), Features(opts), Target(target),FileMgr(Headers.getFileMgr()), - SourceMgr(SM), HeaderInfo(Headers), ExternalSource(0), + FileSystemOpts(Headers.getFileSystemOpts()), SourceMgr(SM), + HeaderInfo(Headers), ExternalSource(0), Identifiers(opts, IILookup), BuiltinInfo(Target), CodeComplete(0), CodeCompletionFile(0), SkipMainFilePreamble(0, true), CurPPLexer(0), CurDirLookup(0), Callbacks(0), MacroArgCache(0), Record(0), MIChainHead(0), |