summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/FileManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix build bot after r340598.Eric Liu2018-08-241-8/+12
| | | | | | | Revert to the original behavior: only calculate real file path when file is opened and avoid using InterndPath for real path calculation. llvm-svn: 340602
* [FileManager] Do not call 'real_path' in getFile().Eric Liu2018-08-241-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This partially rolls back the change in D48903: https://github.com/llvm-mirror/clang/commit/89aa7f45a1f728144935289d4ce69d8522999de0#diff-0025af005307891b5429b6a834823d5eR318 `real_path` can be very expensive on real file systems, and calling it on each opened file can slow down the compilation. This also slows down deserialized ASTs for which real paths need to be recalculated for each input files again. For clangd code completion latency (using preamble): Before {F7039629} After {F7039630} Reviewers: ilya-biryukov, simark Reviewed By: ilya-biryukov Subscribers: kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51159 llvm-svn: 340598
* [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the ↵Simon Marchi2018-08-061-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | requested name Summary: InMemoryFileSystem::status behaves differently than RealFileSystem::status. The Name contained in the Status returned by RealFileSystem::status will be the path as requested by the caller, whereas InMemoryFileSystem::status returns the normalized path. For example, when requested the status for "../src/first.h", RealFileSystem returns a Status with "../src/first.h" as the Name. InMemoryFileSystem returns "/absolute/path/to/src/first.h". The reason for this change is that I want to make a unit test in the clangd testsuite (where we use an InMemoryFileSystem) to reproduce a bug I get with the clangd program (where a RealFileSystem is used). This difference in behavior "hides" the bug in the unit test version. An indirect impact of this change is that a -Wnonportable-include-path warning is now emitted in test PCH/case-insensitive-include.c. This is because the real path of the included file (with the wrong case) was not available previously, whereas it is now. Reviewers: malaperle, ilya-biryukov, bkramer Reviewed By: ilya-biryukov Subscribers: eric_niebler, malaperle, omtcyfz, hokein, bkramer, ilya-biryukov, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D48903 llvm-svn: 339063
* Remove trailing spaceFangrui Song2018-07-301-8/+8
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Revert r338057 "[VirtualFileSystem] InMemoryFileSystem::status: Return a ↵Reid Kleckner2018-07-261-5/+3
| | | | | | | | Status with the requested name" This broke clang/test/PCH/case-insensitive-include.c on Windows. llvm-svn: 338084
* [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the ↵Simon Marchi2018-07-261-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | requested name Summary: InMemoryFileSystem::status behaves differently than RealFileSystem::status. The Name contained in the Status returned by RealFileSystem::status will be the path as requested by the caller, whereas InMemoryFileSystem::status returns the normalized path. For example, when requested the status for "../src/first.h", RealFileSystem returns a Status with "../src/first.h" as the Name. InMemoryFileSystem returns "/absolute/path/to/src/first.h". The reason for this change is that I want to make a unit test in the clangd testsuite (where we use an InMemoryFileSystem) to reproduce a bug I get with the clangd program (where a RealFileSystem is used). This difference in behavior "hides" the bug in the unit test version. Reviewers: malaperle, ilya-biryukov, bkramer Subscribers: cfe-commits, ioeric, ilya-biryukov, bkramer, hokein, omtcyfz Differential Revision: https://reviews.llvm.org/D48903 llvm-svn: 338057
* Revert "[VFS] Cleanups to VFS interfaces."Jordan Rupprecht2018-07-241-1/+1
| | | | | | This reverts commit r337834 due to test failures. llvm-svn: 337850
* [VFS] Cleanups to VFS interfaces.Sam McCall2018-07-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: - add comments clarifying semantics - Status::copyWithNewName(Status, Name) --> instance method - Status::copyWithNewName(fs::file_status, Name) --> constructor (it's not a copy) - File::getName() -> getRealPath(), reflecting its actual behavior/function and stop returning status().getName() in the base class (callers can do this fallback if they want to, it complicates the contracts). This is mostly NFC, but the behavior of File::getName() affects FileManager's FileEntry::tryGetRealPathName(), which now fails in more cases: - non-real file cases - real-file cases where the underlying vfs::File was opened in a way that doesn't call realpath(). (In these cases we don't know a distinct real name, so in principle it seems OK) Reviewers: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49724 llvm-svn: 337834
* Revert "[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with ↵Eric Liu2018-07-111-5/+3
| | | | | | | | | | the requested name" This reverts commit r336807. This breaks users of ClangTool::mapVirtualFile. Will try to investigate a fix. See also the discussion on https://reviews.llvm.org/D48903 llvm-svn: 336831
* [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the ↵Simon Marchi2018-07-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | requested name Summary: InMemoryFileSystem::status behaves differently than RealFileSystem::status. The Name contained in the Status returned by RealFileSystem::status will be the path as requested by the caller, whereas InMemoryFileSystem::status returns the normalized path. For example, when requested the status for "../src/first.h", RealFileSystem returns a Status with "../src/first.h" as the Name. InMemoryFileSystem returns "/absolute/path/to/src/first.h". The reason for this change is that I want to make a unit test in the clangd testsuite (where we use an InMemoryFileSystem) to reproduce a bug I get with the clangd program (where a RealFileSystem is used). This difference in behavior "hides" the bug in the unit test version. In general, I guess it's good if InMemoryFileSystem works as much as possible like RealFileSystem. Doing so made the FileEntry::RealPathName value (assigned in FileManager::getFile) wrong when using the InMemoryFileSystem. That's because it assumes that vfs::File::getName will always return the real path. I changed to to use FileSystem::getRealPath instead. Subscribers: ilya-biryukov, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D48903 llvm-svn: 336807
* [Frontend] Honor UserFilesAreVolatile flag getting file buffer in ASTUnitIvan Donchevskii2018-06-061-3/+3
| | | | | | | | | Do not memory map the main file if the flag UserFilesAreVolatile is set to true in ASTUnit when calling FileSystem::getBufferForFile. Differential Revision: https://reviews.llvm.org/D47460 llvm-svn: 334070
* Add vfs::FileSystem::getRealPathEric Liu2018-05-171-16/+2
| | | | | | | | | | | | | | Summary: And change `FileManager::getCanonicalName` to use getRealPath. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46942 llvm-svn: 332590
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Revert r329698 (and r329702).Nico Weber2018-04-271-2/+16
| | | | | | | | | Speculative. ClangMoveTests started failing on http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9958 after this change. I can't reproduce on my machine, let's see if it was due to this change. llvm-svn: 331077
* s/LLVM_ON_WIN32/_WIN32/, clangNico Weber2018-04-271-1/+1
| | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. llvm-svn: 331069
* Attempt to fix Windows build after r329698.Nico Weber2018-04-101-1/+1
| | | | llvm-svn: 329702
* Use llvm::sys::fs::real_path() in clang.Nico Weber2018-04-101-16/+2
| | | | | | | No expected behavior change. https://reviews.llvm.org/D45165 llvm-svn: 329698
* Use VFS operations in FileManager::makeAbsolutePath.Ilya Biryukov2017-08-021-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
* FileManager: mark virtual file entries as valid entriesErik Verbruggen2017-03-281-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
* Apply clang-tidy's performance-unnecessary-value-param to parts of clang.Benjamin Kramer2017-03-211-3/+3
| | | | | | No functionality change intended. llvm-svn: 298443
* Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)Mehdi Amini2016-10-111-6/+6
| | | | llvm-svn: 283856
* Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini2016-10-101-1/+1
| | | | llvm-svn: 283815
* Fix build broken after llvm/ADT/DenseMap.h replacement of climits with limits.Eugene Zelenko2016-08-131-1/+6
| | | | llvm-svn: 278586
* [NFC] Header cleanupMehdi Amini2016-07-181-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
* Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2016-06-131-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
* Revert r272562 for build bot failure (clang-x86-win2008-selfhost)Taewook Oh2016-06-131-3/+0
| | | | llvm-svn: 272572
* Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2016-06-131-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
* Revert commit r271708Taewook Oh2016-06-041-3/+0
| | | | llvm-svn: 271761
* Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2016-06-031-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
* [FileManager] Don't crash if reading from stdin and stat(".") failsDavid Majnemer2016-04-121-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
* Remove the egregious PCHContainer layering hack that doesn't seem to be ↵Benjamin Kramer2016-02-011-5/+0
| | | | | | necessary anymore. llvm-svn: 259355
* unique_ptrify some collections in FileManagerDavid Blaikie2015-12-091-16/+10
| | | | llvm-svn: 255129
* [Basic] Rangify two for loops. NFC.Vedant Kumar2015-12-091-4/+4
| | | | llvm-svn: 255091
* [modules] Refactor handling of -fmodules-embed-*. Track this properly ratherRichard Smith2015-11-261-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
* Moving FileManager::removeDotPaths to llvm::sys::path::remove_dotsMike Aizatsky2015-11-091-34/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D14394 llvm-svn: 252501
* Roll-back r250822.Angel Garcia Gomez2015-10-201-2/+2
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-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
* [FileManager] Use StringRef::copy to store canonical paths.Benjamin Kramer2015-08-041-9/+3
| | | | | | No functional change intended. llvm-svn: 243970
* [modules] Fix issue where building a module from a relative path when ↵Argyrios Kyrtzidis2015-07-311-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
* Add a comment explaining differing Windows behavior.Sean Silva2015-07-301-1/+7
| | | | llvm-svn: 243625
* Attempt to make clang-x64-ninja-win7 happy.Sean Silva2015-07-301-6/+8
| | | | | | | It looks like we were somehow relying somewhere on removing 'foo/./bar' but *not* 'foo/../foo/bar'. Currently investigating. llvm-svn: 243600
* Avoid failure to canonicalize '..'.Sean Silva2015-07-301-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
* Make the clang module container format selectable from the command line.Adrian Prantl2015-07-171-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
* Revert r241770 and add Basic to the dependencies of clang-check instead.Adrian Prantl2015-07-091-0/+3
| | | | | | PR24067. llvm-svn: 241782
* Move the definition of ~PCHContainerOperations from Basic into Frontend.Adrian Prantl2015-07-091-3/+0
| | | | | | Fixes PR24067. llvm-svn: 241770
* Revert "Revert r241620 and follow-up commits" and move the initializationAdrian Prantl2015-07-081-0/+3
| | | | | | of the llvm targets from clang/CodeGen into ClangCheck.cpp and CIndex.cpp. llvm-svn: 241653
* Revert r241620 and follow-up commits while investigating linux buildbot ↵Adrian Prantl2015-07-071-3/+0
| | | | | | failures. llvm-svn: 241642
* Wrap clang modules and pch files in an object file container.Adrian Prantl2015-07-071-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
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-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
* [modules] When constructing paths relative to a module, strip out /./ directoryRichard Smith2014-12-111-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
OpenPOWER on IntegriCloud