aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
AgeCommit message (Collapse)AuthorFilesLines
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
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-6/+6
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
2014-02-28Reapply fixed "Honour 'use-external-names' in FileManager"Ben Langmuir1-1/+1
Was r202442 There were two issues with the original patch that have now been fixed. 1. We were memset'ing over a FileEntry in a test case. After adding a std::string to FileEntry, this still happened to not break for me. 2. I didn't pass the FileManager into the new compiler instance in compileModule. This was hidden in some cases by the fact I didn't clear the module cache in the test. Also, I changed the copy constructor for FileEntry, which was memcpy'ing in a (now) unsafe way. llvm-svn: 202539
2014-02-27Revert "Honour 'use-external-names' in FileManager"Ben Langmuir1-1/+1
Revert r202442, which broke the buildbots. llvm-svn: 202443
2014-02-27Honour 'use-external-names' in FileManagerBen Langmuir1-1/+1
Pass through the externally-visible names that we got from the VFS down to FileManager, and test that this is the name showing up in __FILE__, diagnostics, and debug information. llvm-svn: 202442
2014-02-27Reapply r202420 hopefully fixed for other STLsBen Langmuir1-48/+12
Keep the copy constructor around, and add a FIXME that we should really remove it as soon as we have C++11 std::map's emplace function. llvm-svn: 202439
2014-02-27Revert "Remove constructors from FileEntry that prevent owning resources"Ben Langmuir1-12/+48
This reverts commit r202420, which broke the build. llvm-svn: 202421
2014-02-27Remove constructors from FileEntry that prevent owning resourcesBen Langmuir1-48/+12
This cleans up some constructors that would not be safe once FileEntry owns the storage for its name. These were already suspect, since they wouldn't work if the FileEntry had an open file descriptor. The only user for these constructors was in UniqueFileContainer, which wasn't a very useful abstraction anyway. So it and UniqueDirContainer have been replaced with std::map<UniqueID, *>. This change should not affect anything outside the FileManager. llvm-svn: 202420
2014-02-27Split FileEntry name vs. isValidBen Langmuir1-2/+3
This is a small bit of refactoring in preparation for FileEntry owning the storage for its own name. llvm-svn: 202412
2014-02-21Fix gcc -Wparentheses warning.Patrik Hagglund1-1/+1
llvm-svn: 201840
2014-02-20Recommit virtual file systemBen Langmuir1-52/+34
Previously reverted in r201755 due to causing an assertion failure. I've removed the offending assertion, and taught the CompilerInstance to create a default virtual file system inside createFileManager. In the future, we should be able to reach into the CompilerInvocation to customize this behaviour without breaking clients that don't care. llvm-svn: 201818
2014-02-20Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka1-34/+52
assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
2014-02-19Initial implementation of virtual file systemBen Langmuir1-52/+34
This adds the minimum virtual file system support to start migrating FileManager onto the VFS. Originally discussed here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html Differential Revision: http://llvm-reviews.chandlerc.com/D2745 llvm-svn: 201618
2013-08-01Use llvm::sys::fs::UniqueID for windows and unix.Rafael Espindola1-104/+27
This unifies the unix and windows versions of FileManager::UniqueDirContainer and FileManager::UniqueFileContainer by using UniqueID. We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we want to be able to construct fake ones, and file_status has different members on unix and windows. What the patch does is: * Record only the information that clang is actually using. * Use llvm::sys::fs::status instead of stat and fstat. * Use llvm::sys::fs::UniqueID * Delete the old windows versions of UniqueDirContainer and UniqueFileContainer since the "unix" one now works on windows too. llvm-svn: 187619
2013-07-29Convert a use of stat with sys::fs::status.Rafael Espindola1-3/+3
llvm-svn: 187364
2013-07-29Fix handling of "clang c:foo"Rafael Espindola1-0/+10
On windows, c:foo is a valid file path, but stat fails on just "c:". This causes a problem for clang since its file manager wants to cache data about the parent directory. There are refactorings to be done in here, but this gives clang the correct behavior and testing first. Patch by Yunzhong Gao! llvm-svn: 187359
2013-07-04Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper1-1/+1
avoid specifying the vector size unnecessarily. llvm-svn: 185610
2013-01-26<limits.h> includes <linux/limits.h> on Linux, no need to special-case itDmitri Gribenko1-3/+1
llvm-svn: 173578
2013-01-26Since we're stuck with realpath for the header <-> module mapping,Douglas Gregor1-0/+28
factor the realpath calls into FileManager::getCanonicalName() so we can cache the results of this epically slow operation. 5% speedup on my modules test, and realpath drops out of the profile. llvm-svn: 173542
2012-12-11Extend stat query APIs to explicitly specify if the query is forArgyrios Kyrtzidis1-12/+8
a file or directory, allowing just a stat call if a file descriptor is not needed. Doing just 'stat' is faster than 'open/fstat/close'. This has the effect of cutting down system time for validating the input files of a PCH. llvm-svn: 169831
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-2/+2
uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
2012-11-06Basic: Windows doesn't define S_IFIFO.Daniel Dunbar1-1/+4
llvm-svn: 167468
2012-11-05Frontend: Add support for reading named pipes as the main file.Daniel Dunbar1-0/+4
- The whole {File,Source}Manager is built around wanting to pre-determine the size of files, so we can't fit this in naturally. Instead, we handle it like we do STDIN, where we just replace the main file contents upfront. llvm-svn: 167419
2012-07-31Fixes a segfault in Tooling when using pch's:Manuel Klimek1-0/+4
Clear the FileManager's stat cache in between running translation units, as the stat cache loaded from a pch is only valid for one compiler invocation. llvm-svn: 161047
2012-07-11Introduce a flag in SourceManager to treat non-system source filesArgyrios Kyrtzidis1-5/+11
as "volatile", meaning there's a high enough chance that they may change while we are trying to use them. This flag is only enabled by libclang. Currently "volatile" source files will be stat'ed immediately before opening them, because the file size stat info may not be accurate since when we got it (e.g. from the PCH). This avoids crashes when trying to reference mmap'ed memory from a file whose size is not what we expect. Note that there's still a window for a racing issue to occur but the window for it should be way smaller than before. We can consider later on to avoid mmap completely on such files. rdar://11612916 llvm-svn: 160074
2012-07-11LLVM_ON_WIN32 case: use the proper key in the UniqueFiles map.Axel Naumann1-1/+7
llvm-svn: 160041
2012-07-10Improve r159256 following Chandler's comments:Axel Naumann1-10/+9
Implement UniqueFileContainer::erase(), camelCase, add comment on future optimizations of the cache versus de-optimizations of invalidations. llvm-svn: 159997
2012-06-27Fix for r159256 on Windows.Axel Naumann1-0/+4
llvm-svn: 159262
2012-06-27From Vassil Vassilev:Axel Naumann1-0/+13
add interface for removing a FileEntry from the cache. Forces a re-read the contents from disk, e.g. because a tool (like cling) wants to pick up a modified file. llvm-svn: 159256
2012-06-16clang/lib/Basic/FileManager.cpp: Detect the root directory with PathV2. It ↵NAKAMURA Takumi1-2/+4
should be better fix for PR10331, or, "clang X:\foo.c" fails. llvm-svn: 158596
2012-06-15Documentation cleanup: delete doc comments from source files where they areJames Dennett1-7/+0
broken duplicates of comments that are in the corresponding header files. llvm-svn: 158550
2012-05-03[PCH] When validating that the files coming from PCH did not change, alsoArgyrios Kyrtzidis1-0/+6
validate that we didn't override the contents of any of such files. If this is detected, emit a diagnostic error and recover gracefully by using the contents of the original file that the PCH was built from. Part of rdar://11305263 llvm-svn: 156107