aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderSearch.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-01-11[clang][lex] Keep references to `DirectoryLookup` objects up-to-dateJan Svoboda1-53/+60
The elements of `SearchPath::SearchDirs` are being referenced to by their indices. This proved to be error-prone: `HeaderSearch::SearchDirToHSEntry` was accidentally not being updated in `HeaderSearch::AddSearchPath()`. This patch fixes that by referencing `SearchPath::SearchDirs` elements by their address instead, which is stable thanks to the bump-ptr-allocation strategy. Reviewed By: ahoppen Differential Revision: https://reviews.llvm.org/D116750
2022-01-10[clang][HeaderSearch] Support framework includes in suggestPath...David Goldman1-26/+71
Clang will now search through the framework includes to identify the framework include path to a file, and then suggest a framework style include spelling for the file. Differential Revision: https://reviews.llvm.org/D115183
2022-01-06[clang][lex] NFC: Move some HeaderSearch functions to .cpp fileJan Svoboda1-0/+24
2022-01-05[clang][lex] NFC: Simplify loopJan Svoboda1-5/+3
2021-11-18[clang][lex] Refactor check for the first file includeJan Svoboda1-1/+6
This patch refactors the code that checks whether a file has just been included for the first time. The `HeaderSearch::FirstTimeLexingFile` function is removed and the information is threaded to the original call site from `HeaderSearch::ShouldEnterIncludeFile`. This will make it possible to avoid tracking the number of includes in a follow up patch. Depends on D114092. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D114093
2021-10-21[clang] Use StringRef::contains (NFC)Kazu Hirata1-1/+1
2021-10-15[clang] Capture Framework when HeaderSearch is resolved via headermapCyndy Ishida1-5/+5
When building frameworks, headermaps responsible for mapping angle-included headers to their source file location are passed via `-I` and not `-index-header-map`. Also, `-index-header-map` is only used for indexing purposes and not during most builds. This patch holds on to the framework's name in HeaderFileInfo as this is retrieveable for cases outside of IndexHeaderMaps and still represents the framework that is being built. resolves: rdar://84046893 Reviewed By: jansvoboda11 Differential Revision: https://reviews.llvm.org/D111468
2021-10-12[clang][lex] Remark on search path usageJan Svoboda1-10/+53
For dependency scanning, it would be useful to collect header search paths (provided on command-line via `-I` and friends) that were actually used during preprocessing. This patch adds that feature to `HeaderSearch` along with a new remark that reports such paths as they get used. Previous version of this patch tried to use the existing `LookupFileCache` to report used paths via `HitIdx`. That doesn't work for `ComputeUserEntryUsage` (which is intended to be called *after* preprocessing), because it indexes used search paths by the file name. This means the values get overwritten when the code contains `#include_next`. Note that `HeaderSearch` doesn't use `HeaderSearchOptions::UserEntries` directly. Instead, `InitHeaderSearch` pre-processes them (adds platform-specific paths, removes duplicates, removes paths that don't exist) and creates `DirectoryLookup` instances. This means we need a mechanism for translating between those two. It's not possible to go from `DirectoryLookup` back to the original `HeaderSearch`, so `InitHeaderSearch` now tracks the relationships explicitly. Depends on D111557. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102923
2021-10-12[clang][modules] NFC: Propagate import `SourceLocation` into ↵Jan Svoboda1-4/+9
`HeaderSearch::lookupModule` This patch propagates the import `SourceLocation` into `HeaderSearch::lookupModule`. This enables remarks on search path usage (implemented in D102923) to point to the source code that initiated header search. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D111557
2021-09-01[HeaderSearch] Use `isImport` only for imported headers and not for `#pragma ↵Volodymyr Sapsai1-2/+2
once`. There is a separate field `isPragmaOnce` and when `isImport` combines both, it complicates HeaderFileInfo serialization as `#pragma once` is the inherent property of the header while `isImport` reflects how other headers use it. The usage of the header can be different in different contexts, that's why `isImport` requires tracking separate from `#pragma once`. Differential Revision: https://reviews.llvm.org/D104351
2021-07-08PR51018: Remove explicit conversions from SmallString to StringRef to ↵David Blaikie1-1/+1
future-proof against C++23 C++23 will make these conversions ambiguous - so fix them to make the codebase forward-compatible with C++23 (& a follow-up change I've made will make this ambiguous/invalid even in <C++23 so we don't regress this & it generally improves the code anyway)
2021-06-03[clang][clangd] Use reverse header map lookup in suggestPathToFileForDiagnosticsDmitry Polukhin1-2/+15
Summary: suggestPathToFileForDiagnostics is actively used in clangd for converting an absolute path to a header file to a header name as it should be spelled in the sources. Current approach converts absolute path to relative path. This diff implements missing logic that makes a reverse lookup from the relative path to the key in the header map that should be used in the sources. Prerequisite diff: https://reviews.llvm.org/D103229 Test Plan: check-clang Reviewers: dexonsmith, bruno, rsmith Subscribers: cfe-commits Tasks: Tags: #clang Differential Revision: https://reviews.llvm.org/D103142
2020-12-14Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"Nico Weber1-23/+26
This reverts commit a40db5502b2515a6f2f1676b5d7a655ae0f41179. and follow-up d636b881bb9214938973098a012fad453082c444 Somewhat speculative, likely broke check-clang on Windows: https://reviews.llvm.org/D92975#2453482
2020-12-14Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRefDuncan P. N. Exon Smith1-26/+23
Migrate `HeaderSearch::LoadedModuleMaps` and a number of APIs over to `FileEntryRef`. This should have no functionality change. Note that two `FileEntryRef`s hash the same if they point at the same `FileEntry`. Differential Revision: https://reviews.llvm.org/D92975
2020-11-10Allow searching for prebuilt implicit modules.Alexandre Rames1-2/+27
This reverts commit c67656b994c87224e0b33e2c4b09093986a5cfa6, and addresses the build issue.
2020-11-05Revert "Allow searching for prebuilt implicit modules."Stella Stamenova1-27/+2
This reverts commit 71e108cd86e70b06c5fa3a63689dcb3555c3d13f. This change caused a build failure on Windows: http://lab.llvm.org:8011/#/builders/83/builds/570
2020-11-05Allow searching for prebuilt implicit modules.Alexandre Rames1-2/+27
The behavior is controlled by the `-fprebuilt-implicit-modules` option, and allows searching for implicit modules in the prebuilt module cache paths. The current command-line options for prebuilt modules do not allow to easily maintain and use multiple versions of modules. Both the producer and users of prebuilt modules are required to know the relationships between compilation options and module file paths. Using a particular version of a prebuilt module requires passing a particular option on the command line (e.g. `-fmodule-file=[<name>=]<file>` or `-fprebuilt-module-path=<directory>`). However the compiler already knows how to distinguish and automatically locate implicit modules. Hence this proposal to introduce the `-fprebuilt-implicit-modules` option. When set, it enables searching for implicit modules in the prebuilt module paths (specified via `-fprebuilt-module-path`). To not modify existing behavior, this search takes place after the standard search for prebuilt modules. If not Here is a workflow illustrating how both the producer and consumer of prebuilt modules would need to know what versions of prebuilt modules are available and where they are located. clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v1 <config 1 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v2 <config 2 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v3 <config 3 options> clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules_v1 <config 1 options> clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap <non-prebuilt config options> With prebuilt implicit modules, the producer can generate prebuilt modules as usual, all in the same output directory. The same mechanisms as for implicit modules take care of incorporating hashes in the path to distinguish between module versions. Note that we do not specify the output module filename, so `-o` implicit modules are generated in the cache path `prebuilt_modules`. clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 1 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 2 options> clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 3 options> The user can now simply enable prebuilt implicit modules and point to the prebuilt modules cache. No need to "parse" command-line options to decide what prebuilt modules (paths) to use. clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules -fprebuilt-implicit-modules <config 1 options> clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules -fprebuilt-implicit-modules <non-prebuilt config options> This is for example particularly useful in a use-case where compilation is expensive, and the configurations expected to be used are predictable, but not controlled by the producer of prebuilt modules. Modules for the set of predictable configurations can be prebuilt, and using them does not require "parsing" the configuration (command-line options). Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D68997
2020-10-23HeaderSearch: Simplify use of FileEntryRef in HeaderSearch::LookupFile, NFCDuncan P. N. Exon Smith1-7/+2
Simplify `HeaderSearch::LookupFile`. Instead of deconstructing a `FileEntryRef` into a name and `FileEntry` and then rebuilding it later, use it as is. This helps to unblock making the constructor of `FileEntryRef` private to `FileManager`. Differential Revision:
2020-08-20[HeaderSearch] Fix processing #import-ed headers multiple times with modules ↵Volodymyr Sapsai1-10/+10
enabled. HeaderSearch was marking requested HeaderFileInfo as Resolved only based on the presence of ExternalSource. As the result, using any module was enough to set ExternalSource and headers unknown to this module would have HeaderFileInfo with empty fields, including `isImport = 0`, `NumIncludes = 0`. Such HeaderFileInfo was preserved without changes regardless of how the header was used in other modules and caused incorrect result in `HeaderSearch::ShouldEnterIncludeFile`. Fix by marking HeaderFileInfo as Resolved only if ExternalSource knows about this header. rdar://problem/62126911 Reviewed By: bruno Differential Revision: https://reviews.llvm.org/D80263
2020-06-04[clang] Always allow including builtin headers in [no_undeclared_headers] ↵Martin Boehme1-11/+20
modules. Previously, this would fail if the builtin headers had been "claimed" by a different module that wraps these builtin headers. libc++ does this, for example. This change adds a test demonstrating this situation; the test fails without the fix.
2020-04-28Improve diagnostics for missing import / #include of module.Richard Smith1-2/+14
Fix a few bugs where we would fail to properly determine header to module correspondence when determining whether to suggest a #include or import, and suggest a #include more often in language modes where there is no import syntax. Generally, if the target is in a header with include guards or #pragma once, we should suggest either #including or importing that header, and not importing a module that happens to textually include it. In passing, improve the notes we attach to the corresponding diagnostics: calling an entity that we couldn't see "previous" is confusing.
2020-02-28[modules] Allow frameworks to have only a private module without a public one.Volodymyr Sapsai1-0/+10
Support only preferred spelling 'Modules/module.private.modulemap' and not the deprecated 'module_private.map'. rdar://problem/57715533 Reviewed By: bruno Differential Revision: https://reviews.llvm.org/D75311
2020-02-08Use heterogenous lookup for std;:map<std::string with a StringRef. NFCI.Benjamin Kramer1-1/+1
2020-01-29[clang] Replace SmallStr.str().str() with std::string conversion operator.Jonas Devlieghere1-1/+1
Use the std::string conversion operator introduced in d7049213d0fcda691c9e79f9b41e357198d99738.
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-4/+5
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.
2019-10-11[Stats] Convert some ad-hoc header search stats to ALWAYS_ENABLED_STATISTIC.Volodymyr Sapsai1-11/+22
rdar://problem/55715134 Reviewers: dsanders, bogner, rtereshin Reviewed By: dsanders Subscribers: hiraditya, jkorous, dexonsmith, ributzka, cfe-commits, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68252 llvm-svn: 374581
2019-09-11Fix -Wnonportable-include-path suppression for header maps with absolute paths.Volodymyr Sapsai1-10/+15
In `DirectoryLookup::LookupFile` parameter `HasBeenMapped` doesn't cover the case when clang finds a file through a header map but doesn't remap the lookup filename because the target path is an absolute path. As a result, -Wnonportable-include-path suppression for header maps introduced in r301592 wasn't triggered. Change parameter `HasBeenMapped` to `IsInHeaderMap` and use parameter `MappedName` to track the filename remapping. This way we can handle both relative and absolute paths in header maps, and account for their specific properties, like filename remapping being a property preserved across lookups in multiple directories. rdar://problem/39516483 Reviewers: dexonsmith, bruno Reviewed By: dexonsmith Subscribers: jkorous, cfe-commits, ributzka Differential Revision: https://reviews.llvm.org/D58094 llvm-svn: 371655
2019-08-31Introduce a DirectoryEntryRef that stores both a reference and anAlex Lorenz1-1/+2
accessed name to the directory entry This commit introduces a parallel API that returns a DirectoryEntryRef to the FileManager, similar to the parallel FileEntryRef API. All uses will have to be update in follow-up patches. The immediate use of the new API in this patch fixes the issue where a file manager was reused in clang-scan-deps, but reported an different file path whenever a framework lookup was done through a symlink. Differential Revision: https://reviews.llvm.org/D67026 llvm-svn: 370562
2019-08-26FileManager: Use llvm::Expected in new getFileRef APIDuncan P. N. Exon Smith1-10/+8
`FileManager::getFileRef` is a modern API which we expect to convert to over time. We should modernize the error handling as well, using `llvm::Expected` instead of `llvm::ErrorOr`, to help clients that care about errors to ensure nothing is missed. However, not all clients care. I've also added another path for those that don't: - `FileEntryRef` is now copy- and move-assignable (using a pointer instead of a reference). - `FileManager::getOptionalFileRef` returns an `llvm::Optional` instead of `llvm::Expected`. - Added an `llvm::expectedToOptional` utility in case this is useful elsewhere. https://reviews.llvm.org/D66705 llvm-svn: 369943
2019-08-22Introduce FileEntryRef and use it when handling includes to report correct ↵Alex Lorenz1-103/+110
dependencies when the FileManager is reused across invocations This commit introduces a parallel API to FileManager's getFile: getFileEntryRef, which returns a reference to the FileEntry, and the name that was used to access the file. In the case of a VFS with 'use-external-names', the FileEntyRef contains the external name of the file, not the filename that was used to access it. The new API is adopted only in the HeaderSearch and Preprocessor for include file lookup, so that the accessed path can be propagated to SourceManager's FileInfo. SourceManager's FileInfo now can report this accessed path, using the new getName method. This API is then adopted in the dependency collector, which now correctly reports dependencies when a file is included both using a symlink and a real path in the case when the FileManager is reused across multiple Preprocessor invocations. Note that this patch does not fix all dependency collector issues, as the same problem is still present in other cases when dependencies are obtained using FileSkipped, InclusionDirective, and HasInclude. This will be fixed in follow-up commits. Differential Revision: https://reviews.llvm.org/D65907 llvm-svn: 369680
2019-08-13Don't use std::errcAlexey Bataev1-3/+4
Summary: As noted on Errc.h: // * std::errc is just marked with is_error_condition_enum. This means that // common patters like AnErrorCode == errc::no_such_file_or_directory take // 4 virtual calls instead of two comparisons. And on some libstdc++ those virtual functions conclude that ------------------------ int main() { std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory); return foo == std::errc::no_such_file_or_directory; } ------------------------- should exit with 0. Reviewers: thakis, rnk, jfb Reviewed By: thakis Subscribers: lebedev.ri, dexonsmith, xbolva00, cfe-commits, caomhin Tags: #clang Differential Revision: https://reviews.llvm.org/D66143 llvm-svn: 368739
2019-08-09Don't diagnose errors when a file matches an include componentReid Kleckner1-1/+2
This regressed in r368322, and was reported as PR42948 and on the mailing list. The fix is to ignore the specific error code for this case. The problem doesn't seem to reproduce on Windows, where a different error code is used instead. llvm-svn: 368475
2019-08-08Fix up fd limit diagnosis codeReid Kleckner1-2/+3
Apparently Windows returns the "invalid argument" error code when the path contains invalid characters such as '<'. The test/Preprocessor/include-likely-typo.c test does this, so it was failing after r368322. Also, the diagnostic requires two arguments, so add the filename. llvm-svn: 368348
2019-08-08clang: Diag running out of file handles while looking for filesNico Weber1-2/+11
clang would only print "file not found" when it's unable to find a header file. If the reason for that is a file handle leak, that's not a very useful error message. For errors that aren't in a small whitelist ("file not found", "file is directory"), print an error with the strerror() output. This changes behavior in corner cases: If clang was out of file handles while looking in one -I dir but then suddenly wasn't when looking in the next -I dir, and both directories contained a file with the desired name, previously we'd silently return the file from the second directory. For this reason, it's important to ignore "is a directory" for this new diag: if a file foo/foo exists and -I -Ifoo are passed, an include of "foo" should successfully open file "foo" in directory "foo/" instead of complaining that "./foo" is a directory. No test since we mostly hit this when there's a handle leak somewhere, and currently there isn't one. I manually tested this with the repro steps in comment 2 on the bug below. Fixes PR42524. Differential Revision: https://reviews.llvm.org/D65956 llvm-svn: 368322
2019-08-01[clang] Adopt new FileManager error-returning APIsHarlan Haskins1-41/+65
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-07-16Fix parameter name comments using clang-tidy. NFC.Rui Ueyama1-4/+4
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
2019-07-03[clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya1-16/+28
Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
2019-06-06[clang][HeaderSearch] Consider all path separators equalKadir Cetinkaya1-0/+5
Reviewers: ilya-biryukov, sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62965 llvm-svn: 362731
2019-05-27[Preprocessor] Fix crash emitting note with framework location for "file not ↵Volodymyr Sapsai1-1/+4
found" error. A filename can be remapped with a header map to point to a framework header and we can find the corresponding framework without the header. But if the original filename doesn't have a remapped framework name, we'll fail to find its location and will dereference a null pointer during diagnostics emission. Fix by tracking remappings better and emit the note only if a framework is found before any of the remappings. rdar://problem/48883447 Reviewers: arphaman, erik.pilkington, jkorous Reviewed By: arphaman Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D61707 llvm-svn: 361779
2019-04-24[clang][HeaderSuggestion] Handle the case of dotdot with an absolute pathKadir Cetinkaya1-4/+3
Summary: Include insertion in clangd was inserting absolute paths when the include directory was an absolute path with a double dot. This patch makes sure double dots are handled both with absolute and relative paths. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60873 llvm-svn: 359078
2019-04-24[clang][HeaderSearch] Make sure there are no backslashes in suggestedPathKadir Cetinkaya1-1/+1
Reviewers: sammccall Differential Revision: https://reviews.llvm.org/D60995 llvm-svn: 359075
2019-03-26Basic: Return a reference from FileManager::getVirtualFileSystem, NFCDuncan P. N. Exon Smith1-2/+2
FileManager constructs a VFS in its constructor if it isn't passed one, and there's no way to reset it. Make that contract clear by returning a reference from its accessor. https://reviews.llvm.org/D59388 llvm-svn: 357038
2019-02-05[Preprocessor] Add a note with framework location for "file not found" error.Volodymyr Sapsai1-11/+20
When a framework with the same name is available at multiple framework search paths, we use the first matching location. If a framework at this location doesn't have all the headers, it can be confusing for developers because they see only an error `'Foo/Foo.h' file not found`, can find the complete framework with required header, and don't know the incomplete framework was used instead. Add a note explaining a framework without required header was found. Also mention framework directory path to make it easier to find the incomplete framework. rdar://problem/39246514 Reviewers: arphaman, erik.pilkington, jkorous Reviewed By: jkorous Subscribers: jkorous, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D56561 llvm-svn: 353231
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
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-16[Support] Remove error return value from one overload of fs::make_absolutePavel Labath1-3/+2
Summary: The version of make_absolute which accepted a specific directory to use as the "base" for the computation could never fail, even though it returned a std::error_code. The reason for that seems to be historical -- the CWD flavour (which can fail due to failure to retrieve CWD) was there first, and the new version was implemented by extending that. This removes the error return value from the non-CWD overload and reimplements the CWD version on top of that. This enables us to remove some dead code where people were pessimistically trying to handle the errors returned from this function. Reviewers: zturner, sammccall Subscribers: hiraditya, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D56599 llvm-svn: 351317
2018-11-14[HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directoryAlex Lorenz1-1/+3
Include search paths can be relative paths. The loadSubdirectoryModuleMaps function should account for that and respect the -working-directory parameter given to Clang. rdar://46045849 Differential Revision: https://reviews.llvm.org/D54503 llvm-svn: 346822
2018-10-10Lift VFS from clang to llvm (NFC)Jonas Devlieghere1-5/+6
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-09-20Fix an assert in -Wquoted-include-in-framework-headerErik Pilkington1-1/+1
Fixes rdar://43692300 Differential revision: https://reviews.llvm.org/D52253 llvm-svn: 342679
2018-09-14[VFS] vfs::directory_iterator yields path and file type instead of full StatusSam McCall1-7/+6
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-08-20[Lex] Make HeaderMaps a unique_ptr vectorFangrui Song1-10/+4
Summary: unique_ptr makes the ownership clearer than a raw pointer container. Reviewers: Eugene.Zelenko, dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50945 llvm-svn: 340198