diff options
author | Axel Naumann <Axel.Naumann@cern.ch> | 2011-01-27 10:55:51 +0000 |
---|---|---|
committer | Axel Naumann <Axel.Naumann@cern.ch> | 2011-01-27 10:55:51 +0000 |
commit | 63fbaeda29060b5ed93859b13d4c75371a2d2157 (patch) | |
tree | 9a90a61533ed2fc72a5fd193ebbd4fe86fc3d784 /clang/lib/Basic/FileManager.cpp | |
parent | 284c48fff6d7259389c6761d9b669ae5c6c7c36d (diff) | |
download | bcm5719-llvm-63fbaeda29060b5ed93859b13d4c75371a2d2157.tar.gz bcm5719-llvm-63fbaeda29060b5ed93859b13d4c75371a2d2157.zip |
TextDiagnosticPrinter.cpp: Show diagnostics as far as possible even with invalid PresomedLoc, instead of just silencing it.
FileManager.cpp: Allow virtual files in nonexistent directories.
FileManager.cpp: Close FileDescriptor for virtual files that correspond to actual files.
FileManager.cpp: Enable virtual files to be created even for files that were flagged as NON_EXISTENT_FILE, e.g. by a prior (unsuccessful) addFile().
ASTReader.cpp: Read a PCH even if the original source files cannot be found.
Add a test for reading a PCH of a file that has been removed and diagnostics referencing that file.
llvm-svn: 124374
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index bb37c999d10..cbe90bfdc16 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -350,18 +350,17 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size, FileEntries.GetOrCreateValue(Filename); // See if there is already an entry in the map. - if (NamedFileEnt.getValue()) - return NamedFileEnt.getValue() == NON_EXISTENT_FILE - ? 0 : NamedFileEnt.getValue(); + if (NamedFileEnt.getValue() && NamedFileEnt.getValue() != NON_EXISTENT_FILE) + return NamedFileEnt.getValue(); ++NumFileCacheMisses; // By default, initialize it to invalid. NamedFileEnt.setValue(NON_EXISTENT_FILE); + // We allow the directory to not exist. If it does exist we store it. + // const DirectoryEntry *DirInfo = getDirectoryFromFile(*this, Filename); - if (DirInfo == 0) // Directory doesn't exist, file can't exist. - return 0; FileEntry *UFE = new FileEntry(); VirtualFileEntries.push_back(UFE); @@ -381,8 +380,13 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size, // newly-created file entry. int FileDescriptor = -1; struct stat StatBuf; - if (getStatValue(InterndFileName, StatBuf, &FileDescriptor)) + if (getStatValue(InterndFileName, StatBuf, &FileDescriptor)) { + // If the stat process opened the file, close it to avoid a FD leak. + if (FileDescriptor != -1) + close(FileDescriptor); + return UFE; + } UFE->FD = FileDescriptor; llvm::SmallString<128> FilePath(UFE->Name); |