Commit Graph

229 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith 2878e965af Basic: Add hashing support for FileEntryRef and DirectoryEntryRef
Allow hashing FileEntryRef and DirectoryEntryRef via `hash_value`, and
use that to implement `DenseMapInfo`. This hash should be equal whenever
the entry is the same (the name used to reference it is not relevant).

Also add `DirectoryEntryRef::isSameRef` to simplify the implementation
and facilitate testing.

Differential Revision: https://reviews.llvm.org/D92627
2020-12-08 18:10:53 -08:00
Duncan P. N. Exon Smith 94f537c6b2 Remove dead code added in ac49500cd0, NFC
This was a copy/paste bug; `M0` is never referenced later.
2020-11-30 14:50:46 -08:00
Duncan P. N. Exon Smith 1b042de5b2 FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef
Add `FileEntryRef::getDir`, which returns a `DirectoryEntryRef`. This
includes a few changes:

- Customize `OptionalStorage` so that `Optional<DirectoryEntryRef>` is
  pointer-sized (like the change made to `Optional<FileEntryRef>`).
  Factored out a common class, `FileMgr::MapEntryOptionalStorage`, to
  reduce the code duplication.
- Store an `Optional<DirectoryEntryRef>` in `FileEntryRef::MapValue`.
  This is set if and only if `MapValue` has a real `FileEntry`.
- Change `FileManager::getFileRef` and `getVirtualFileRef` to use
  `getDirectoryRef` and store it in the `StringMap` for `FileEntryRef`.

Differential Revision: https://reviews.llvm.org/D90484
2020-11-30 14:50:46 -08:00
Duncan P. N. Exon Smith ac49500cd0 Reapply "FileManager: Improve the FileEntryRef API and customize its OptionalStorage"
This reverts commit 940d0a310d,
effectively reapplying 84e8257937, after
working around the compile errors on the bots that I wasn't seeing
locally. I removed the `constexpr` from `OptionalStorage<FileEntryRef>`
that I had cargo-culted from the generic version, since `FileEntryRef`
isn't relevant in `constexpr` contexts anyway.

The original commit message follows:

Make a few changes to the `FileEntryRef` API in preparation for
propagating it enough to remove `FileEntry::getName()`.

- Allow `FileEntryRef` to degrade implicitly to `const FileEntry*`. This
  allows functions currently returning `const FileEntry *` to be updated
  to return `FileEntryRef` without requiring all callers to be updated
  in the same patch. This helps avoid both (a) massive patches where
  many fields and locals are updated simultaneously and (b) noisy
  incremental patches where the first patch adds `getFileEntry()` at
  call sites and the second patch removes it. (Once `FileEntryRef` is
  everywhere, we should remove this API.)
- Change `operator==` to compare the underlying `FileEntry*`, ignoring
  any difference in the spelling of the filename. There were 0 users of
  the existing function because it's not useful.  In case comparing the
  exact named reference becomes important, add/test `isSameRef`.
- Add `==` comparisons between `FileEntryRef` and `const FileEntry *`
  (compares the `FileEntry*`).
- Customize `OptionalStorage<FileEntryRef>` to be pointer-sized. Add
  a private constructor that initializes with `nullptr` and specialize
  `OptionalStorage` to use it. This unblocks updating fields in
  size-sensitive data structures that currently use `const FileEntry *`.
- Add `OptionalFileEntryRefDegradesToFileEntryPtr`, a wrapper around
  `Optional<FileEntryRef>` that degrades to `const FileEntry*`. This
  facilitates future incremental patches, like the same operator on
  `FileEntryRef`. (Once `FileEntryRef` is everywhere, we should remove
  this class.)
- Remove the unncessary `const` from the by-value return of
  `FileEntryRef::getName`.
- Delete the unused function `FileEntry::isOpenForTests`.

Note that there are still `FileEntry` APIs that aren't wrapped and I
plan to deal with these separately / incrementally, as they are needed.

Differential Revision: https://reviews.llvm.org/D89834
2020-10-30 15:06:01 -04:00
Duncan P. N. Exon Smith 940d0a310d Revert "FileManager: Improve the FileEntryRef API and customize its OptionalStorage" and follow-ups
This reverts commit 5530fb586f.
This reverts commit 010238a296.
This reverts commit 84e8257937.

Having trouble getting the bots compiling. Will try again later.
2020-10-30 14:06:55 -04:00
Duncan P. N. Exon Smith 84e8257937 FileManager: Improve the FileEntryRef API and customize its OptionalStorage
Make a few changes to the `FileEntryRef` API in preparation for
propagating it enough to remove `FileEntry::getName()`.

- Allow `FileEntryRef` to degrade implicitly to `const FileEntry*`. This
  allows functions currently returning `const FileEntry *` to be updated
  to return `FileEntryRef` without requiring all callers to be updated
  in the same patch. This helps avoid both (a) massive patches where
  many fields and locals are updated simultaneously and (b) noisy
  incremental patches where the first patch adds `getFileEntry()` at
  call sites and the second patch removes it. (Once `FileEntryRef` is
  everywhere, we should remove this API.)
- Change `operator==` to compare the underlying `FileEntry*`, ignoring
  any difference in the spelling of the filename. There were 0 users of
  the existing function because it's not useful.  In case comparing the
  exact named reference becomes important, add/test `isSameRef`.
- Add `==` comparisons between `FileEntryRef` and `const FileEntry *`
  (compares the `FileEntry*`).
- Customize `OptionalStorage<FileEntryRef>` to be pointer-sized. Add
  a private constructor that initializes with `nullptr` and specialize
  `OptionalStorage` to use it. This unblocks updating fields in
  size-sensitive data structures that currently use `const FileEntry *`.
- Add `OptionalFileEntryRefDegradesToFileEntryPtr`, a wrapper around
  `Optional<FileEntryRef>` that degrades to `const FileEntry*`. This
  facilitates future incremental patches, like the same operator on
  `FileEntryRef`. (Once `FileEntryRef` is everywhere, we should remove
  this class.)
- Remove the unncessary `const` from the by-value return of
  `FileEntryRef::getName`.
- Delete the unused function `FileEntry::isOpenForTests`.

Note that there are still `FileEntry` APIs that aren't wrapped and I
plan to deal with these separately / incrementally, as they are needed.

Differential Revision: https://reviews.llvm.org/D89834
2020-10-30 13:25:46 -04:00
Duncan P. N. Exon Smith 917acac960 FileManager: Shrink FileEntryRef to the size of a pointer
Shrink `FileEntryRef` to the size of a pointer, by having it directly
reference the `StringMapEntry` the same way that `DirectoryEntryRef`
does. This makes `FileEntryRef::FileEntryRef` private as a side effect
(`FileManager` is a friend!).

There are two helper types added within `FileEntryRef`:

- `FileEntryRef::MapValue` is the type stored in
  `FileManager::SeenFileEntries`. It's a replacement for
  `SeenFileEntryOrRedirect`, where the second pointer type has been
  changed from `StringRef*` to `MapEntry*` (see next bullet).
- `FileEntryRef::MapEntry` is the instantiation of `StringMapEntry<>`
  where `MapValue` is stored. This is what `FileEntryRef` has a pointer
  to, in order to grab the name in addition to the value.

Differential Revision: https://reviews.llvm.org/D89488
2020-10-27 14:55:41 -04:00
Benjamin Kramer dd7095f52b [clang][unittest] Don't hardcode the string "Assertion"
This depends on the libc implementation. Use the string from the
assertion message instead. Overly specific, but so is this entire test.
2020-10-26 18:10:56 +01:00
Duncan P. N. Exon Smith dbbc4f4e22 SourceManager: Encapsulate line number mapping into SrcMgr::LineOffsetMapping
Put the guts of `ComputeLineNumbers` into `LineOffsetMapping::get` and
`LineOffsetMapping::LineOffsetMapping`.  As a drive-by, store the number
of lines directly in the bump-ptr-allocated array.

Differential Revision: https://reviews.llvm.org/D89913
2020-10-23 12:55:51 -04:00
Duncan P. N. Exon Smith 168db92465 SourceManager: Change SourceManager::isMainFile to take a FileEntry, NFC
`SourceManager::isMainFile` does not use the filename, so it doesn't
need the full `FileEntryRef`; in fact, it's misleading to take the name
because that makes it look relevant. Simplify the API, and in the
process remove some calls to `FileEntryRef::FileEntryRef` in the unit
tests (which were blocking making that private to `SourceManager`).

Differential Revision: https://reviews.llvm.org/D89507
2020-10-22 21:32:28 -04:00
Duncan P. N. Exon Smith 729d7d2328 FileManager: Test FileManager::getFileRef
Add a test demonstrating `getFileRef`'s behaviour, which isn't obvious
from code inspection when it's handling a redirected file.

Differential Revision: https://reviews.llvm.org/D89469
2020-10-20 13:40:23 -04:00
Yaxun (Sam) Liu 7e561b62d2 [NFC] Refactor DiagnosticBuilder and PartialDiagnostic
PartialDiagnostic misses some functions compared to DiagnosticBuilder.

This patch refactors DiagnosticBuilder and PartialDiagnostic, extracts
the common functionality so that the streaming << operators are
shared.

Differential Revision: https://reviews.llvm.org/D84362
2020-10-19 17:48:04 -04:00
Bevin Hansson 1a995a0af3 [ADT] Move FixedPoint.h from Clang to LLVM.
This patch moves FixedPointSemantics and APFixedPoint
from Clang to LLVM ADT.

This will make it easier to use the fixed-point
classes in LLVM for constructing an IR builder for
fixed-point and for reusing the APFixedPoint class
for constant evaluation purposes.

RFC: http://lists.llvm.org/pipermail/llvm-dev/2020-August/144025.html

Reviewed By: leonardchan, rjmccall

Differential Revision: https://reviews.llvm.org/D85312
2020-08-20 10:29:45 +02:00
Alex Lorenz 11d612ac99 [clang][Preprocessor] Replace the slow translateFile call by a new, faster isMainFile check
The commit 3c28a2dc6b introduced the check that checks if we're
trying to re-enter a main file when building a preamble. Unfortunately this slowed down the preamble
compilation by 80-90% in some test cases, as translateFile is really slow. This change checks
to see if the FileEntry is the main file without calling translateFile, but by using the new
isMainFile check instead. This speeds up preamble building by 1.5-2x for certain test cases that we have.

rdar://59361291

Differential Revision: https://reviews.llvm.org/D79834
2020-05-14 14:13:34 -07:00
Kadir Cetinkaya 411a254af3
[clang] Make sure argument expansion locations are correct in presence of predefined buffer
Summary:
Macro argument expansion logic relies on skipping file IDs that created
as a result of an include. Unfortunately it fails to do that for
predefined buffer since it doesn't have a valid insertion location.

As a result of that any file ID created for an include inside the
predefined buffers breaks the traversal logic in
SourceManager::computeMacroArgsCache.

To fix this issue we first record number of created FIDs for predefined
buffer, and then skip them explicitly in source manager.

Another solution would be to just give predefined buffers a valid source
location, but it is unclear where that should be..

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78649
2020-04-22 21:01:52 +02:00
Benjamin Kramer adcd026838 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Jan Korous f28972facc [clang] Fix out-of-bounds memory access in ComputeLineNumbers
Differential Revision: https://reviews.llvm.org/D72409
2020-01-10 11:22:41 -08:00
paulhoad 8fa5e98fd1 [clang-format] Remove duplciate code from Invalid BOM detection
Summary:
Review comments on {D68767} asked that this duplicated code in clang-format was moved to one central location that being SourceManager (where it had originally be copied from I assume)

Moved function into static function  ContentCache::getInvalidBOM(...)  - (closest class to where it was defined before)
Updated clang-format to call this static function

Added unit tests for said new function in BasicTests

Sorry not my normal code area so may have the wrong reviewers. (but your names were on the recent history)

Reviewers: bruno, arphaman, klimek, owenpan, mitchell-stellar, dexonsmith

Reviewed By: owenpan

Subscribers: cfe-commits

Tags: #clang, #clang-format, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D68914
2019-10-24 20:24:44 +01:00
Duncan P. N. Exon Smith e1b7f22b34 ASTReader: Bypass overridden files when reading PCHs
If contents of a file that is part of a PCM are overridden when reading
it, but weren't overridden when the PCM was being built, the ASTReader
will emit an error.  Now it creates a separate FileEntry for recovery,
bypassing the overridden content instead of discarding it.  The
pre-existing testcase clang/test/PCH/remap-file-from-pch.cpp confirms
that the new recovery method works correctly.

This resolves a long-standing FIXME to avoid hypothetically invalidating
another precompiled module that's already using the overridden contents.

This also removes ContentCache-related API that would be unsafe to use
across `CompilerInstance`s in an implicit modules build.  This helps to
unblock us sinking it from SourceManager into FileManager in the future,
which would allow us to delete `InMemoryModuleCache`.

https://reviews.llvm.org/D66710

llvm-svn: 370546
2019-08-30 22:59:25 +00:00
Jonas Devlieghere 2b3d49b610 [Clang] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368942
2019-08-14 23:04:18 +00:00
Harlan Haskins e86fffcd44 Fix Windows branch of FileManagerTest changes
llvm-svn: 367622
2019-08-01 21:58:56 +00:00
Harlan Haskins 5341f79a90 Fix use-after-move in ClangBasicTests
llvm-svn: 367620
2019-08-01 21:50:16 +00:00
Harlan Haskins 8d323d1506 [clang] Adopt new FileManager error-returning APIs
Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods.

Signed-off-by: Harlan Haskins <harlan@apple.com>
llvm-svn: 367616
2019-08-01 21:31:56 +00:00
Harlan Haskins 461f0722dd [clang] Adopt llvm::ErrorOr in FileManager methods
Previously, the FileManager would use NULL returns to signify whether a file existed, but that doesn’t cover permissions issues or anything else that might occur while trying to stat or read a file. Instead, convert getFile and getDirectory into returning llvm::ErrorOr

Signed-off-by: Harlan Haskins <harlan@apple.com>
llvm-svn: 367615
2019-08-01 21:31:49 +00:00
Tom Stellard 2e97d2aa1b cmake: Add CLANG_LINK_CLANG_DYLIB option
Summary:
Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against
libclang_shared.so instead of the individual component libraries.

Reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru

Subscribers: arphaman, cfe-commits, llvm-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63503

llvm-svn: 365092
2019-07-03 22:45:55 +00:00
Harlan Haskins d8f776af6e [FileSystemStatCache] Update test for new FileSystemStatCache API
Summary: Update this test to return std::error_code instead of LookupResult.

Reviewers: arphaman

Subscribers: dexonsmith, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D60786

llvm-svn: 358511
2019-04-16 18:00:43 +00:00
Duncan P. N. Exon Smith 8bef5cd49a Modules: Rename MemoryBufferCache to InMemoryModuleCache
Change MemoryBufferCache to InMemoryModuleCache, moving it from Basic to
Serialization.  Another patch will start using it to manage module build
more explicitly, but this is split out because it's mostly mechanical.

Because of the move to Serialization we can no longer abuse the
Preprocessor to forward it to the ASTReader.  Besides the rename and
file move, that means Preprocessor::Preprocessor has one fewer parameter
and ASTReader::ASTReader has one more.

llvm-svn: 355777
2019-03-09 17:33:56 +00:00
Ivan Donchevskii 878271b294 [libclang] Fix CXTranslationUnit_KeepGoing
Since
  commit 56f548bbbb7e4387a69708f70724d00e9e076153
  [modules] Round-trip -Werror flag through explicit module build.
the behavior of CXTranslationUnit_KeepGoing changed:
Unresolved #includes are fatal errors again. As a consequence, some
templates are not instantiated and lead to confusing errors.

Revert to the old behavior: With CXTranslationUnit_KeepGoing fatal
errors are mapped to errors.

Patch by Nikolai Kosjar.

Differential Revision: https://reviews.llvm.org/D58501

llvm-svn: 355586
2019-03-07 10:13:50 +00:00
Harlan Haskins 06f64d53ae Replace clang::FileData with llvm::vfs::Status
Summary:
FileData was only ever used as a container for the values in
llvm::vfs::Status, so they might as well be consolidated.

The `InPCH` member was also always set to false, and unused.

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58924

llvm-svn: 355368
2019-03-05 02:27:12 +00:00
Jan Korous 1dbc72185a [clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows
llvm-svn: 354296
2019-02-18 23:12:29 +00:00
Jan Korous cd8607db2d Reland "[clang][FileManager] fillRealPathName even if we aren't opening the file"
This reverts commit e2bb3121fd.
+ fixed test for Windows

llvm-svn: 354291
2019-02-18 22:33:40 +00:00
Reid Kleckner e2bb3121fd Revert r354075 "[clang][FileManager] fillRealPathName even if we aren't opening the file"
The new test doesn't pass on Windows.

llvm-svn: 354169
2019-02-15 20:48:12 +00:00
Jan Korous 85eb363d56 [clang][FileManager] fillRealPathName even if we aren't opening the file
The pathname wasn't previously filled when the getFile() method was called with openFile = false.
We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused the problem.

This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All

rdar://47536127

Differential Revision: https://reviews.llvm.org/D58213

llvm-svn: 354075
2019-02-14 23:02:35 +00:00
Sam McCall fa36120682 [FileManager] Revert r347205 to avoid PCH file-descriptor leak.
Summary:
r347205 fixed a bug in FileManager: first calling
getFile(shouldOpen=false) and then getFile(shouldOpen=true) results in
the file not being open.

Unfortunately, some code was (inadvertently?) relying on this bug: when
building with a PCH, the file entries are obtained first by passing
shouldOpen=false, and then later shouldOpen=true, without any intention
of reading them. After r347205, they do get unneccesarily opened.
Aside from extra operations, this means they need to be closed. Normally
files are closed when their contents are read. As these files are never
read, they stay open until clang exits. On platforms with a low
open-files limit (e.g. Mac), this can lead to spurious file-not-found
errors when building large projects with PCH enabled, e.g.
  https://bugs.chromium.org/p/chromium/issues/detail?id=924225

Fixing the callsites to pass shouldOpen=false when the file won't be
read is not quite trivial (that info isn't available at the direct
callsite), and passing shouldOpen=false is a performance regression (it
results in open+fstat pairs being replaced by stat+open).

So an ideal fix is going to be a little risky and we need some fix soon
(especially for the llvm 8 branch).
The problem addressed by r347205 is rare and has only been observed in
clangd. It was present in llvm-7, so we can live with it for now.

Reviewers: bkramer, thakis

Subscribers: ilya-biryukov, ioeric, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57165

llvm-svn: 352079
2019-01-24 18:55:24 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Alex Lorenz d92b1ae1d7 Remove stat cache chaining as it's no longer needed after PTH support has been
removed

Stat cache chaining was implemented for a StatListener in the PTH writer so that
it could write out the stat information to PTH. r348266 removed support for PTH,
and it doesn't seem like there are other uses of stat cache chaining. We can
remove the chaining support.

Differential Revision: https://reviews.llvm.org/D55455

llvm-svn: 349942
2018-12-21 19:33:09 +00:00
Stella Stamenova 0ef54dbd64 [tests] Fix the FileManagerTest getVirtualFile test on Windows
Summary: The test passes on Windows only when it is executed on the C: drive. If the build and tests run on a different drive, the test is currently failing.

Reviewers: kadircet, asmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55451

llvm-svn: 348665
2018-12-07 23:50:05 +00:00
Matthew Voss 601d311326 Expect mixed path separators in FileManagerTest when resolving paths on Win32
llvm-svn: 348028
2018-11-30 19:52:50 +00:00
Kadir Cetinkaya 853ec89249 [clang] Fix rL348006 for windows
llvm-svn: 348015
2018-11-30 18:36:31 +00:00
Kadir Cetinkaya e9870c0c91 [clang] Fill RealPathName for virtual files.
Summary:
Absolute path information for virtual files were missing even if we
have already stat'd the files. This patch puts that information for virtual
files that can succesffully be stat'd.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55054

llvm-svn: 348006
2018-11-30 17:10:11 +00:00
Matthew Voss 25e44e7c33 Ensure FileManagerTest expects "\\" as path separator on Windows platforms
llvm-svn: 347284
2018-11-20 03:30:28 +00:00
Sam McCall e84385fef8 [FileManager] getFile(open=true) after getFile(open=false) should open the file.
Summary:
Old behavior is to just return the cached entry regardless of opened-ness.
That feels buggy (though I guess nobody ever actually needed this).

This came up in the context of clangd+clang-tidy integration: we're
going to getFile(open=false) to replay preprocessor actions obscured by
the preamble, but the compilation may subsequently getFile(open=true)
for non-preamble includes.

Reviewers: ilya-biryukov

Subscribers: ioeric, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54691

llvm-svn: 347205
2018-11-19 13:37:46 +00:00
Jonas Devlieghere fc51490baf Lift VFS from clang to llvm (NFC)
This patch moves the virtual file system form clang to llvm so it can be
used by more projects.

Concretely the patch:
 - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support.
 - Moves the corresponding unit test from clang to llvm.
 - Moves the vfs namespace from clang::vfs to llvm::vfs.
 - Formats the lines affected by this change, mostly this is the result of
   the added llvm namespace.

RFC on the mailing list:
http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html

Differential revision: https://reviews.llvm.org/D52783

llvm-svn: 344140
2018-10-10 13:27:25 +00:00
Sam McCall 3922377544 [Basic] Update clang tests (really testing sys::fs) that broke with r343460
llvm-svn: 343488
2018-10-01 16:07:03 +00:00
Fangrui Song 55fab260ca llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.

Reviewers: rsmith, #clang, dblaikie

Reviewed By: rsmith, #clang

Subscribers: mgrang, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52576

llvm-svn: 343147
2018-09-26 22:16:28 +00:00
Sam McCall 0ae00567ba [VFS] vfs::directory_iterator yields path and file type instead of full Status
Summary:
Most callers I can find are using only `getName()`. Type is used by the
recursive iterator.

Now we don't have to call stat() on every listed file (on most platforms).
Exceptions are e.g. Solaris where readdir() doesn't include type information.
On those platforms we'll still stat() - see D51918.

The result is significantly faster (stat() can be slow).
My motivation: this may allow us to improve clang IO on large TUs with long
include search paths. Caching readdir() results may allow us to skip many stat()
and open() operations on nonexistent files.

Reviewers: bkramer

Subscribers: fedor.sergeev, cfe-commits

Differential Revision: https://reviews.llvm.org/D51921

llvm-svn: 342232
2018-09-14 12:47:38 +00:00
Ilya Biryukov d5554c512d Adding HardLink Support to VirtualFileSystem.
Summary:
Added support of creating a hardlink from one file to another file.
After a hardlink is added between two files, both file will have the same:
  1. UniqueID (inode)
  2. Size
  3. Buffer

This will bring replay of compilation closer to the actual compilation. There are instances where clang checks for the UniqueID of the file/header to be loaded which leads to a different behavior during replay as all files have different UniqueIDs.

Patch by Utkarsh Saxena!

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D51359

llvm-svn: 341366
2018-09-04 14:15:53 +00:00
Stephen Kelly b8e0886006 Add dump() method for SourceRange
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50662

llvm-svn: 341140
2018-08-30 23:10:52 +00:00
Craig Topper 576ac05bbc [VFS] Remove superfluous semicolon from unittest.
llvm-svn: 339296
2018-08-08 22:31:14 +00:00
Volodymyr Sapsai 3b2f6a4b29 [VFS] Emit an error when entry at root level uses a relative path.
Entries with only a filename prevent us from building a file system tree and
cause the assertion

> Assertion failed: (NewParentE && "Parent entry must exist"), function uniqueOverlayTree, file clang/lib/Basic/VirtualFileSystem.cpp, line 1303.

Entries with a relative path are simply not discoverable during header search.

rdar://problem/28990865

Reviewers: bruno, benlangmuir

Reviewed By: bruno

Subscribers: dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D49518

llvm-svn: 339164
2018-08-07 19:05:41 +00:00