aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-08-02Use VFS operations in FileManager::makeAbsolutePath.Ilya Biryukov1-1/+1
Summary: It used to call into llvm::sys::fs::make_absolute. Reviewers: akyrtzi, erikjv, bkramer, krasimir, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36155 llvm-svn: 309795
2017-03-28FileManager: mark virtual file entries as valid entriesErik Verbruggen1-0/+1
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
2017-03-21Apply clang-tidy's performance-unnecessary-value-param to parts of clang.Benjamin Kramer1-3/+3
No functionality change intended. llvm-svn: 298443
2016-10-11Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)Mehdi Amini1-6/+6
llvm-svn: 283856
2016-10-10Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini1-1/+1
llvm-svn: 283815
2016-08-13Fix build broken after llvm/ADT/DenseMap.h replacement of climits with limits.Eugene Zelenko1-1/+6
llvm-svn: 278586
2016-07-18[NFC] Header cleanupMehdi Amini1-3/+0
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-06-13Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh1-0/+3
non-portable #include and #import paths. Differential Revision: http://reviews.llvm.org/D19843 Corresponding LLVM change: http://reviews.llvm.org/D19842 Re-commit of r272562 after addressing clang-x86-win2008-selfhost failure. llvm-svn: 272584
2016-06-13Revert r272562 for build bot failure (clang-x86-win2008-selfhost)Taewook Oh1-3/+0
llvm-svn: 272572
2016-06-13Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh1-0/+3
non-portable #include and #import paths. Differential Revision: http://reviews.llvm.org/D19843 Corresponding LLVM change: http://reviews.llvm.org/D19842 Re-commit after addressing issues with of generating too many warnings for Windows and asan test failures. Patch by Eric Niebler llvm-svn: 272562
2016-06-04Revert commit r271708Taewook Oh1-3/+0
llvm-svn: 271761
2016-06-03Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh1-0/+3
non-portable #include and #import paths. Differential Revision: http://reviews.llvm.org/D19843 Corresponding LLVM change: http://reviews.llvm.org/D19842 Patch by Eric Niebler llvm-svn: 271708
2016-04-12[FileManager] Don't crash if reading from stdin and stat(".") failsDavid Majnemer1-1/+1
addAncestorsAsVirtualDirs("<stdin>") quickly returns without doing work because "<stdin>" has no parent_path. This violates the expectation that a subsequent call to getDirectoryFromFile("<stdin>") would succeed. Instead, it fails because it uses the "." if the file has no path component. Fix this by keeping the behavior between addAncestorsAsVirtualDirs and getDirectoryFromFile symmetric. llvm-svn: 266089
2016-02-01Remove the egregious PCHContainer layering hack that doesn't seem to be ↵Benjamin Kramer1-5/+0
necessary anymore. llvm-svn: 259355
2015-12-09unique_ptrify some collections in FileManagerDavid Blaikie1-16/+10
llvm-svn: 255129
2015-12-09[Basic] Rangify two for loops. NFC.Vedant Kumar1-4/+4
llvm-svn: 255091
2015-11-26[modules] Refactor handling of -fmodules-embed-*. Track this properly ratherRichard Smith1-1/+1
than reusing the "overridden buffer" mechanism. This will allow us to make embedded files and overridden files behave differently in future. llvm-svn: 254121
2015-11-09Moving FileManager::removeDotPaths to llvm::sys::path::remove_dotsMike Aizatsky1-34/+1
Differential Revision: http://reviews.llvm.org/D14394 llvm-svn: 252501
2015-10-20Roll-back r250822.Angel Garcia Gomez1-2/+2
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-2/+2
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-08-04[FileManager] Use StringRef::copy to store canonical paths.Benjamin Kramer1-9/+3
No functional change intended. llvm-svn: 243970
2015-07-31[modules] Fix issue where building a module from a relative path when ↵Argyrios Kyrtzidis1-2/+14
-working-directory option is set, results in error. The error was "module '<name>' was built in directory '<path>' but now resides in directory '<path>' rdar://21330027 llvm-svn: 243718
2015-07-30Add a comment explaining differing Windows behavior.Sean Silva1-1/+7
llvm-svn: 243625
2015-07-30Attempt to make clang-x64-ninja-win7 happy.Sean Silva1-6/+8
It looks like we were somehow relying somewhere on removing 'foo/./bar' but *not* 'foo/../foo/bar'. Currently investigating. llvm-svn: 243600
2015-07-30Avoid failure to canonicalize '..'.Sean Silva1-8/+11
Also fix completely broken and untested code which was hiding the primary bug. The !LLVM_ON_UNIX branch of the ifdef was actually a no-op. I ran into this in the wild. It was causing failures in our SDK build. Ideally we'd have a perfect llvm::sys::fs::canonical, but at least this is a step in the right direction, and fixes an obviously broken case. In some sense the test case I've added here is an integration test. We should have these routines thoroughly unit tested in llvm::sys::fs. llvm-svn: 243597
2015-07-17Make the clang module container format selectable from the command line.Adrian Prantl1-1/+3
- introduces a new cc1 option -fmodule-format=[raw,obj] with 'raw' being the default - supports arbitrary module container formats that libclang is agnostic to - adds the format to the module hash to avoid collisions - splits the old PCHContainerOperations into PCHContainerWriter and a PCHContainerReader. Thanks to Richard Smith for reviewing this patch! llvm-svn: 242499
2015-07-09Revert r241770 and add Basic to the dependencies of clang-check instead.Adrian Prantl1-0/+3
PR24067. llvm-svn: 241782
2015-07-09Move the definition of ~PCHContainerOperations from Basic into Frontend.Adrian Prantl1-3/+0
Fixes PR24067. llvm-svn: 241770
2015-07-08Revert "Revert r241620 and follow-up commits" and move the initializationAdrian Prantl1-0/+3
of the llvm targets from clang/CodeGen into ClangCheck.cpp and CIndex.cpp. llvm-svn: 241653
2015-07-07Revert r241620 and follow-up commits while investigating linux buildbot ↵Adrian Prantl1-3/+0
failures. llvm-svn: 241642
2015-07-07Wrap clang modules and pch files in an object file container.Adrian Prantl1-0/+3
This patch adds ObjectFilePCHContainerOperations uses the LLVM backend to put the contents of a PCH into a __clangast section inside a COFF, ELF, or Mach-O object file container. This is done to facilitate module debugging by makeing it possible to store the debug info for the types defined by a module alongside the AST. rdar://problem/20091852 llvm-svn: 241620
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-1/+1
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
2014-12-11[modules] When constructing paths relative to a module, strip out /./ directoryRichard Smith1-4/+39
components. These sometimes get synthetically added, and we don't want -Ifoo and -I./foo to be treated fundamentally differently here. llvm-svn: 224055
2014-11-19Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie1-34/+35
llvm-svn: 222306
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-36/+16
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-09-08Make FileEntry::getName() valid across calls to FileManager::getFile()Ben Langmuir1-2/+15
Because we may change the name of a FileEntry inside getFile, the name returned by FileEntry::getName() could be destroyed. This was causing a use-after-free when searching the HeaderFileInfo on-disk hashtable for a module or pch. llvm-svn: 217385
2014-08-26Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola1-10/+10
llvm-svn: 216476
2014-08-13Default getFile() to use the last accessed name in the FileEntry.Manuel Klimek1-0/+7
With modules we start accessing headers for the first time while reading the module map, which often has very different paths from the include scanning logic. Using the name by which the file was accessed gets us one step closer to the right solution, which is using a FileName abstraction that decouples the name by which a file was accessed from the FileEntry. llvm-svn: 215541
2014-08-11unique_ptr-ify FileSystemStatCache::setNextStatCacheDavid Blaikie1-6/+6
And in the process, discover that FileManager::removeStatCache had a double-delete when removing an element from the middle of the list (at the beginning or the end of the list, there was no problem) and add a unit test to exercise the code path (which successfully crashed when run (with modifications to match the old API) without this patch applied) llvm-svn: 215388
2014-08-10unique_ptr-ify FileSystemStatCache::takeNextStatCacheDavid Blaikie1-1/+1
llvm-svn: 215318
2014-07-19Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ↵David Blaikie1-1/+1
".reset()" It's also possible to just write "= nullptr", but there's some question of whether that's as readable, so I leave it up to authors to pick which they prefer for now. If we want to discuss standardizing on one or the other, we can do that at some point in the future. llvm-svn: 213439
2014-07-08Improve memory ownership of vfs::Files in the FileSystemStatCache by using ↵David Blaikie1-7/+3
std::unique_ptr Spotted after a memory leak (due to the complexities of manual memory management) was fixed in 212466. llvm-svn: 212541
2014-07-07Remove unused sys/stat.h includesAlp Toker1-3/+0
The facility was abstracted to LLVM in r187364. llvm-svn: 212441
2014-06-20Avoid invalidating successfully loaded module filesBen Langmuir1-2/+5
Successfully loaded module files may be referenced in other ModuleManagers, so don't invalidate them. Two related things are fixed: 1) I thought the last module in the manager was always the one that failed, but it isn't. So check explicitly against the list of vetted modules from ReadASTCore. 2) We now keep the file descriptor of pcm file open, which avoids the possibility of having two different pcms for the same module loaded when building in parallel with headers being modified during a build. <rdar://problem/16835846> llvm-svn: 211330
2014-06-12Include system_error directly.Rafael Espindola1-1/+1
llvm-svn: 210802
2014-06-12Replace llvm::error_code with std::error_code.Rafael Espindola1-2/+2
llvm-svn: 210780
2014-05-23Stopgap fix for finding module for a file mapped in the VFSBen Langmuir1-0/+10
If we lookup a path using its 'real' path first, we need to ensure that when we run header search we still use the VFS-mapped path or we will not be able to find the corresponding module for the header. The real problem is that we tie the name of a file to its underlying FileEntry, which is uniqued by inode, so we only ever get the first name it is looked up by. This doesn't work with modules, which rely on a specific file system structure. I'm hoping to have time to write up a proposal for fixing this more permanently soon, but as a stopgap this patch updates the name of the file's directory if it comes from a VFS mapping. llvm-svn: 209534
2014-05-08[C++11] Use 'nullptr'.Craig Topper1-18/+18
llvm-svn: 208280
2014-05-05[Basic/FileManager] Propagate whether a file 'IsVolatile' to the file ↵Argyrios Kyrtzidis1-3/+6
opening functions. Needs llvm r208007. llvm-svn: 208008
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-2/+2
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279