diff options
author | Erik Verbruggen <erikjv@me.com> | 2017-03-28 09:18:05 +0000 |
---|---|---|
committer | Erik Verbruggen <erikjv@me.com> | 2017-03-28 09:18:05 +0000 |
commit | dfffaf579f2b4bc9184c23f271a57e1fa1ed6f01 (patch) | |
tree | 5865fa8c81175dd5b6a800b3e112d163d0ba42f0 /clang/lib/Basic/FileManager.cpp | |
parent | ba04f4e925befe95d93895db3641064d82cf77a4 (diff) | |
download | llvm-dfffaf579f2b4bc9184c23f271a57e1fa1ed6f01.zip llvm-dfffaf579f2b4bc9184c23f271a57e1fa1ed6f01.tar.gz llvm-dfffaf579f2b4bc9184c23f271a57e1fa1ed6f01.tar.bz2 |
FileManager: mark virtual file entries as valid entries
The getVirtualFile method would create entries for e.g. libclang's
CXUnsavedFile but not mark them as valid. The effect is that a lookup
through getFile where the file name is not exactly matching the virtual
file (e.g. through mixing slashes and backslashes on Windows) would
result in a normal file "lookup", and re-using the file entry found
by using the UniqueID, and overwrite the file entry fields. Because the
lookup involves opening the file, and moving it into the file entry, the
file is now open. The SourceManager keys its buffers on the UniqueID
(which is still the same), so it will find an already loaded buffer.
Because only the loading a buffer from disk will close the file, the
FileEntry will hold on to an open file for as long as the FileManager
is around. As the FileManager will only get destroyed at a reparse,
you can't safe to the "leaked" and locked file on Windows.
llvm-svn: 298905
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 646c191..0c10b5f 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -386,6 +386,7 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size, UFE->ModTime = ModificationTime; UFE->Dir = DirInfo; UFE->UID = NextFileUID++; + UFE->IsValid = true; UFE->File.reset(); return UFE; } |