summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/FileManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Reapply fixed "Honour 'use-external-names' in FileManager"Ben Langmuir2014-02-281-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
* Revert "Honour 'use-external-names' in FileManager"Ben Langmuir2014-02-271-1/+1
| | | | | | Revert r202442, which broke the buildbots. llvm-svn: 202443
* Honour 'use-external-names' in FileManagerBen Langmuir2014-02-271-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
* Reapply r202420 hopefully fixed for other STLsBen Langmuir2014-02-271-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
* Revert "Remove constructors from FileEntry that prevent owning resources"Ben Langmuir2014-02-271-12/+48
| | | | | | This reverts commit r202420, which broke the build. llvm-svn: 202421
* Remove constructors from FileEntry that prevent owning resourcesBen Langmuir2014-02-271-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
* Split FileEntry name vs. isValidBen Langmuir2014-02-271-2/+3
| | | | | | | This is a small bit of refactoring in preparation for FileEntry owning the storage for its own name. llvm-svn: 202412
* Fix gcc -Wparentheses warning.Patrik Hagglund2014-02-211-1/+1
| | | | llvm-svn: 201840
* Recommit virtual file systemBen Langmuir2014-02-201-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
* Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka2014-02-201-34/+52
| | | | | | | | | | assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
* Initial implementation of virtual file systemBen Langmuir2014-02-191-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
* Use llvm::sys::fs::UniqueID for windows and unix.Rafael Espindola2013-08-011-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
* Convert a use of stat with sys::fs::status.Rafael Espindola2013-07-291-3/+3
| | | | llvm-svn: 187364
* Fix handling of "clang c:foo"Rafael Espindola2013-07-291-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
* Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper2013-07-041-1/+1
| | | | | | avoid specifying the vector size unnecessarily. llvm-svn: 185610
* <limits.h> includes <linux/limits.h> on Linux, no need to special-case itDmitri Gribenko2013-01-261-3/+1
| | | | llvm-svn: 173578
* Since we're stuck with realpath for the header <-> module mapping,Douglas Gregor2013-01-261-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
* Extend stat query APIs to explicitly specify if the query is forArgyrios Kyrtzidis2012-12-111-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
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-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
* Basic: Windows doesn't define S_IFIFO.Daniel Dunbar2012-11-061-1/+4
| | | | llvm-svn: 167468
* Frontend: Add support for reading named pipes as the main file.Daniel Dunbar2012-11-051-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
* Fixes a segfault in Tooling when using pch's:Manuel Klimek2012-07-311-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
* Introduce a flag in SourceManager to treat non-system source filesArgyrios Kyrtzidis2012-07-111-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
* LLVM_ON_WIN32 case: use the proper key in the UniqueFiles map.Axel Naumann2012-07-111-1/+7
| | | | llvm-svn: 160041
* Improve r159256 following Chandler's comments:Axel Naumann2012-07-101-10/+9
| | | | | | Implement UniqueFileContainer::erase(), camelCase, add comment on future optimizations of the cache versus de-optimizations of invalidations. llvm-svn: 159997
* Fix for r159256 on Windows.Axel Naumann2012-06-271-0/+4
| | | | llvm-svn: 159262
* From Vassil Vassilev:Axel Naumann2012-06-271-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
* clang/lib/Basic/FileManager.cpp: Detect the root directory with PathV2. It ↵NAKAMURA Takumi2012-06-161-2/+4
| | | | | | should be better fix for PR10331, or, "clang X:\foo.c" fails. llvm-svn: 158596
* Documentation cleanup: delete doc comments from source files where they areJames Dennett2012-06-151-7/+0
| | | | | | broken duplicates of comments that are in the corresponding header files. llvm-svn: 158550
* [PCH] When validating that the files coming from PCH did not change, alsoArgyrios Kyrtzidis2012-05-031-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
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-5/+5
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-2/+2
| | | | llvm-svn: 149798
* remove unneeded config.h includesDylan Noblesmith2011-12-221-1/+1
| | | | llvm-svn: 147195
* Revert r132539 for now, "My testing shows that function stat has no problem ↵NAKAMURA Takumi2011-11-171-0/+6
| | | | | | | | with trailing separators. (tested on Windows and Darwin)." It caused PR10331. MSVCRT stat() cannot strip trailing '/'. (can '\') llvm-svn: 144884
* Use StringRef's case transformation methods.Benjamin Kramer2011-11-061-3/+2
| | | | llvm-svn: 143889
* For modules, use a hash of the compiler version, language options, andDouglas Gregor2011-09-131-12/+22
| | | | | | | | | target triple to separate modules built under different conditions. The hash is used to create a subdirectory in the module cache path where other invocations of the compiler (with the same version, language options, etc.) can find the precompiled modules. llvm-svn: 139662
* When an import statement fails to find a module in the module cache,Douglas Gregor2011-09-121-0/+4
| | | | | | | | | but there is a corresponding umbrella header in a framework, build the module on-the-fly so it can be immediately loaded at the import statement. This is very much proof-of-concept code, with details to be fleshed out over time. llvm-svn: 139558
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-13/+13
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* My testing shows that function stat has no problem with trailing separators. ↵Francois Pichet2011-06-031-4/+0
| | | | | | | | | | | (tested on Windows and Darwin). This fixes a bug on Windows: clang c:\test.cpp Here the call stat("c:") is not recognized as a directory (must be "c:\"). llvm-svn: 132539
* Add FileManager::getNoncachedStatValue, which will resolve relative paths ↵Anders Carlsson2011-03-181-0/+8
| | | | | | against the working directory specified in the file system options. llvm-svn: 127893
* Having FileManager::getFile always open the file, brought much consternation ↵Argyrios Kyrtzidis2011-03-161-1/+6
| | | | | | | | | | | and leaking of file descriptors. Add 'openFile' bool to FileManager::getFile to specify whether we want to have the file opened or not, have it false by default, and enable it only in HeaderSearch.cpp where the open+fstat optimization matters. Fixes rdar://9139899. llvm-svn: 127748
* Stop leaking file descriptors.Argyrios Kyrtzidis2011-03-151-14/+16
| | | | | | | | After the open+fstat optimization, files were already opened for FileManager::getBufferForFile() and we closed them after reading them. The problem was that when -working-directory was passed, the code path that actually reuses & closes the already opened file descriptor was not followed. llvm-svn: 127639
* Get rid of the static FileManager::FixupRelativePath.Anders Carlsson2011-03-141-8/+4
| | | | llvm-svn: 127573
* Check in the implementation as well...Anders Carlsson2011-03-071-3/+7
| | | | llvm-svn: 127144
* Convert FileManager::FixupRelativePath over to using PathV2.Anders Carlsson2011-03-061-8/+10
| | | | llvm-svn: 127133
* Uses llvm::sys::path instead of hand-rolled algorithm in FileManager.Zhanyong Wan2011-02-111-32/+11
| | | | | | Reviewed by dgregor. llvm-svn: 125407
* Improves Clang's virtual file handling.Zhanyong Wan2011-02-111-85/+146
| | | | | | | | | | | | | | | | | | | | | | | This patch contains: - making some of the existing comments more accurate in the presence of virtual files/directories. - renaming some private data members of FileManager to match their roles better. - creating 'DirectorEntry's for the parent directories of virtual files, such that we can tell whether two virtual files are from the same directory. This is useful for injecting virtual files whose directories don't exist in the real file system. - minor clean-ups and adding comments for class FileManager::UniqueDirContainer and FileManager::UniqueFileContainer. - adding statistics on virtual files to FileManager::PrintStats(). - adding unit tests to verify the existing and new behavior of FileManager. llvm-svn: 125384
* Implement two related optimizations that make de-serialization ofDouglas Gregor2011-02-101-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AST/PCH files more lazy: - Don't preload all of the file source-location entries when reading the AST file. Instead, load them lazily, when needed. - Only look up header-search information (whether a header was already #import'd, how many times it's been included, etc.) when it's needed by the preprocessor, rather than pre-populating it. Previously, we would pre-load all of the file source-location entries, which also populated the header-search information structure. This was a relatively minor performance issue, since we would end up stat()'ing all of the headers stored within a AST/PCH file when the AST/PCH file was loaded. In the normal PCH use case, the stat()s were cached, so the cost--of preloading ~860 source-location entries in the Cocoa.h case---was relatively low. However, the recent optimization that replaced stat+open with open+fstat turned this into a major problem, since the preloading of source-location entries would now end up opening those files. Worse, those files wouldn't be closed until the file manager was destroyed, so just opening a Cocoa.h PCH file would hold on to ~860 file descriptors, and it was easy to blow through the process's limit on the number of open file descriptors. By eliminating the preloading of these files, we neither open nor stat the headers stored in the PCH/AST file until they're actually needed for something. Concretely, we went from *** HeaderSearch Stats: 835 files tracked. 364 #import/#pragma once files. 823 included exactly once. 6 max times a file is included. 3 #include/#include_next/#import. 0 #includes skipped due to the multi-include optimization. 1 framework lookups. 0 subframework lookups. *** Source Manager Stats: 835 files mapped, 3 mem buffers mapped. 37460 SLocEntry's allocated, 11215575B of Sloc address space used. 62 bytes of files mapped, 0 files with line #'s computed. with a trivial program that uses a chained PCH including a Cocoa PCH to *** HeaderSearch Stats: 4 files tracked. 1 #import/#pragma once files. 3 included exactly once. 2 max times a file is included. 3 #include/#include_next/#import. 0 #includes skipped due to the multi-include optimization. 1 framework lookups. 0 subframework lookups. *** Source Manager Stats: 3 files mapped, 3 mem buffers mapped. 37460 SLocEntry's allocated, 11215575B of Sloc address space used. 62 bytes of files mapped, 0 files with line #'s computed. for the same program. llvm-svn: 125286
* Update for API change.Rafael Espindola2011-02-081-2/+2
| | | | llvm-svn: 125129
* Improve our uniquing of file entries when files are re-saved or areDouglas Gregor2011-02-051-21/+36
| | | | | | | | | | | | | | overridden via remapping. Thus, when we create a "virtual" file in the file manager, we still stat() the real file that lives behind it so that we can provide proper uniquing based on inodes. This helps keep the file manager much more consistent. To take advantage of this when reparsing files in libclang, we disable the use of the stat() cache when reparsing or performing code completion, since the stat() cache is very likely to be out of date in this use case. llvm-svn: 124971
OpenPOWER on IntegriCloud