summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/FileManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Revert 124754 and 124760 as they made clang unusable in the presence of symbolicRafael Espindola2011-02-031-84/+0
| | | | | | links. llvm-svn: 124776
* Improve the performance of filename canonicalization by avoidingDouglas Gregor2011-02-031-1/+8
| | | | | | redundant searches in the string. No functionality change. llvm-svn: 124760
* Canonicalize path names in the file manager before performing a lookupDouglas Gregor2011-02-021-0/+77
| | | | | | | | | | | | | | | on that name. Canonicalization eliminates silliness such as "." and "foo/.." that breaks the uniquing of files in the presence of virtual files or files whose inode numbers have changed during parsing/re-parsing. c-index-test isn't able to create this crazy situation, so I've resorted to testing outside of the Clang tree. Fixes <rdar://problem/8928220>. Note that this hackery will go away once we have a real virtual file system on which we can layer FileManager; the virtual-files hack is showing cracks. llvm-svn: 124754
* TextDiagnosticPrinter.cpp: Show diagnostics as far as possible even with ↵Axel Naumann2011-01-271-6/+10
| | | | | | | | | | | | | | 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
* Replace all uses of PathV1::makeAbsolute with PathV2::fs::make_absolute.Michael J. Spencer2010-12-211-3/+4
| | | | llvm-svn: 122340
* Replace all uses of PathV1::isAbsolute with PathV2::is_{absolute,relative}.Michael J. Spencer2010-12-171-4/+5
| | | | llvm-svn: 122087
* MemoryBuffer API update.Michael J. Spencer2010-12-161-19/+18
| | | | llvm-svn: 121956
* Use error_code instead of std::string* for MemoryBuffer.Michael J. Spencer2010-12-091-8/+27
| | | | llvm-svn: 121378
* attempt to fix a buildbot failure, apparently apache fails to build.Chris Lattner2010-12-021-1/+1
| | | | llvm-svn: 120688
* Merge System into Support.Michael J. Spencer2010-11-291-1/+1
| | | | llvm-svn: 120297
* The final result of all this refactoring: instead of doing stat immediatelyChris Lattner2010-11-231-3/+16
| | | | | | | | | | | | | followed by an open for every source file we open, probe the file system with 'open' and then do an fstat when it succeeds. open+fstat is faster than stat+open because the kernel only has to perform the string->inode mapping once. Presumably it gets faster the deeper in your filesystem a lookup happens. For -Eonly on cocoa.h, this reduces system time from 0.042s to 0.039s on my machine, a 7.7% speedup. llvm-svn: 120066
* hopefully resolve the windows buildbot issue (retch)Chris Lattner2010-11-231-0/+8
| | | | llvm-svn: 120061
* change the 'is directory' indicator to be a null-or-notChris Lattner2010-11-231-14/+19
| | | | | | | | | pointer that is passed down through the APIs, and make FileSystemStatCache::get be the one that filters out directory lookups that hit files. This also paves the way to have stat queries be able to return opened files. llvm-svn: 120060
* pull "is directory" handling into FileManager::getStatValueChris Lattner2010-11-231-29/+36
| | | | | | | which simplifies clients and is important for future directions. Add a FD member to FileEntry which isn't used but will be shortly. llvm-svn: 120056
* tidy up code, add a comment about dir caching.Chris Lattner2010-11-231-20/+16
| | | | llvm-svn: 120048
* factor the "cache miss" handling code out of FM into a static Chris Lattner2010-11-231-21/+6
| | | | | | method in FileSystemStatCache. llvm-svn: 120037
* r120013 dropped passing in the precomputed file size to Chris Lattner2010-11-231-2/+3
| | | | | | | MemoryBuffer::getFile, causing us to pick up a fstat for every file. Restore the optimization. llvm-svn: 120032
* rework the stat cache, pulling it out of FileManager.h intoChris Lattner2010-11-231-35/+39
| | | | | | | its own header and giving it some more structure. No functionality change. llvm-svn: 120030
* tidy up. Split FileManager::getBufferForFile intoChris Lattner2010-11-231-6/+14
| | | | | | | | | | two copies, since they are fundamentally different operations and the StringRef one should go away (it shouldn't be part of FileManager at least). Remove some dead arguments. llvm-svn: 120013
* now the FileManager has a FileSystemOpts ivar, stop threadingChris Lattner2010-11-231-15/+8
| | | | | | | | | FileSystemOpts through a ton of apis, simplifying a lot of code. This also fixes a latent bug in ASTUnit where it would invoke methods on FileManager without creating one in some code paths in cindextext. llvm-svn: 120010
* give FileManager a 'FileSystemOptions' ivar, which will be usedChris Lattner2010-11-231-7/+7
| | | | | | | to simplify a bunch of code in it. It should ultimately get inlined into FileManager. llvm-svn: 120007
* Partially revert Doug's PCH validation patch (r98585).Chris Lattner2010-11-231-5/+3
| | | | | | | | | | | | | | | | | | | | | | This patch completely defeated the "passing in a prestat'd size to MemoryBuffer" optimization, leading to an extra fstat call for every buffer opened, in order to find out if the datestamp and size of the file on disk matches what is in the stat cache. I fully admit that I don't completely understand what is going on here: why punish code when a stat cache isn't in use? what is the point of a stat cache if you have to turn around and stat stuff to validate it? To resolve both these issues, just drop the modtime check and check the file size, which is the important thing anyway. This should also resolve PR6812, because presumably windows is stable when it comes to file sizes. If the modtime is actually important, we should get it and keep it on the first stat. This eliminates 833 fstat syscalls when processing Cocoa.h, speeding up system time on -Eonly Cocoa.h from 0.041 to 0.038s. llvm-svn: 120001
* stringref'ize APIChris Lattner2010-11-231-18/+16
| | | | llvm-svn: 119997
* avoid creating sys::Path instances when -fworking-directory isn't being used.Chris Lattner2010-11-231-1/+8
| | | | llvm-svn: 119995
* Filename.rfind("/\\") won't give us the position of the last directory ↵Benjamin Kramer2010-11-211-11/+11
| | | | | | seperator. llvm-svn: 119939
* change the various getFile routines to use StringRef as their implementation ↵Chris Lattner2010-11-211-37/+32
| | | | | | form. llvm-svn: 119934
* Implement -working-directory.Argyrios Kyrtzidis2010-11-031-11/+49
| | | | | | | | | | | | | | | | | | | When -working-directory is passed in command line, file paths are resolved relative to the specified directory. This helps both when using libclang (where we can't require the user to actually change the working directory) and to help reproduce test cases when the reproduction work comes along. --FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains the working directory value if set). --FileSystemOptions are passed around to various interfaces that perform file operations. --Opening & reading the content of files should be done only through FileManager. This is useful in general since file operations will be abstracted in the future for the reproduction mechanism. FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same FileManager but with different FileSystemOptions. Addresses rdar://8583824. llvm-svn: 118203
* fix PR7953 - Windows filename are case insensitive:Chris Lattner2010-08-231-0/+4
| | | | | | | | | | | | | | | | #pragma once wasn't working on win32 if the header file was included using a different case. I tracked down the problem to the fact that clang::FileManager was caching files using case sensitive string (UniqueFiles) on Windows. I changed FileManager to cache filename in lower case only. Doesn't affect UNIX because UNIX uses Inode to uniquely identify files. unix doesn't use this codepath. Analysis and patch by Francois Pichet! llvm-svn: 111866
* When remapping a virtual file, also make an entry for the file withDouglas Gregor2010-07-261-0/+12
| | | | | | | its absolute path on disk. Also, introduce a fun test for the precompiled preamble, which almost works... llvm-svn: 109470
* Pass StringRefs by value.Benjamin Kramer2010-07-141-2/+2
| | | | llvm-svn: 108375
* Removing trailing directory separator, to make stat workJohn Thompson2009-12-181-0/+5
| | | | llvm-svn: 91684
* FileManager: Do not cache failed stats, it is easy to construct commonDaniel Dunbar2009-12-111-10/+9
| | | | | | | | | | | | | | | | | | inconsistent situations if we do, and they are not important for PCH performance (which currently only needs the stats to construct the initial FileManager entries). - No test case, sorry, the machinations are too involved. This occurs when, for example, the build makes a PCH file and has a header map or a -I for a directory that does not yet exist. It is possible we will cache the negative stat on that directory, and then in the build we will never find header files inside that dir. For PCH we don't need these stats anyway for performance, so this also makes PCH files smaller w/ no loss. I hope to eventually eliminate the stat cache entirely. llvm-svn: 91082
OpenPOWER on IntegriCloud