summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/HeaderSearch.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix handling of -fmodule-map-file=X where X has no directory component.Richard Smith2017-03-091-2/+4
| | | | llvm-svn: 297349
* [Modules] Support #import when entering files with modulesBruno Cardoso Lopes2017-01-111-4/+43
| | | | | | | | | | | | Textual headers and builtins that are #import'd from different modules should get re-entered when these modules are independent from each other. Differential Revision: https://reviews.llvm.org/D26267 rdar://problem/25881934 llvm-svn: 291644
* shared_ptrify (from InclusiveRefCntPtr) HeaderSearchOptionsDavid Blaikie2017-01-061-1/+1
| | | | llvm-svn: 291202
* [modules] Handle modules with nonstandard names in module.private.modulemapsGraydon Hoare2016-12-211-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The module system supports accompanying a primary module (say Foo) with an auxiliary "private" module (defined in an adjacent module.private.modulemap file) that augments the primary module when associated private headers are available. The feature is intended to be used to augment the primary module with a submodule (say Foo.Private), however some users in the wild are choosing to augment the primary module with an additional top-level module with a "similar" name (in all cases so far: FooPrivate). This "works" when a user of the module initially imports a private header, such as '#import "Foo/something_private.h"' since the Foo import winds up importing FooPrivate in passing. But if the import is subsequently recorded in a PCH file, reloading the PCH will fail to validate because of a cross-check that attempts to find the module.modulemap (or module.private.modulemap) using HeaderSearch algorithm, applied to the "FooPrivate" name. Since it's stored in Foo.framework/Modules, not FooPrivate.framework/Modules, the check fails and the PCH is rejected. This patch adds a compensatory workaround in the HeaderSearch algorithm when searching (and failing to find) a module of the form FooPrivate: the name used to derive filesystem paths is decoupled from the module name being searched for, and if the initial search fails and the module is named "FooPrivate", the filesystem search name is altered to remove the "Private" suffix, and the algorithm is run a second time (still looking for a module named FooPrivate, but looking in directories derived from Foo). Accompanying this change is a new warning that triggers when a user loads a module.private.modulemap that defines a top-level module with a different name from the top-level module defined in its adjacent module.modulemap. Reviewers: doug.gregor, manmanren, bruno Subscribers: bruno, cfe-commits Differential Revision: https://reviews.llvm.org/D27852 llvm-svn: 290219
* [CrashReproducer] Collect headermap filesBruno Cardoso Lopes2016-12-111-0/+7
| | | | | | | | | | Include headermaps (.hmap files) in the .cache directory and add VFS entries. All headermaps are known after HeaderSearch setup, collect them right after. rdar://problem/27913709 llvm-svn: 289360
* Add some more asserts to clearly indicate that there are special casesChandler Carruth2016-11-041-1/+4
| | | | | | | | | | | | | | | | | which guarantee pointers are not null. These all seem to have useful properties and correlations to document, in one case we even had it in a comment but now it will also be an assert. This should prevent PVS-Studio from incorrectly claiming that there are a bunch of potential bugs here. But I feel really strongly that the PVS-Studio warnings that pointed at this code have a far too high false-positive rate to be entirely useful. These are just places where there did seem to be a useful invariant to document and verify with an assert. Several other places in the code were already correct and already have perfectly clear code documenting and validating their invariants, but still ran afoul of PVS-Studio. llvm-svn: 285985
* [Modules] Add 'no_undeclared_includes' module map attributeBruno Cardoso Lopes2016-10-211-7/+36
| | | | | | | | | | | | | The 'no_undeclared_includes' attribute should be used in a module to tell that only non-modular headers and headers from used modules are accepted. The main motivation behind this is to prevent dep cycles between system libraries (such as darwin) and libc++. Patch by Richard Smith! llvm-svn: 284797
* Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)Mehdi Amini2016-10-111-1/+1
| | | | llvm-svn: 283856
* Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini2016-10-101-8/+10
| | | | llvm-svn: 283815
* Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini2016-10-011-1/+1
| | | | llvm-svn: 283043
* Module: add -fprebuilt-module-path to support loading prebuilt modules.Manman Ren2016-08-181-2/+20
| | | | | | | | | | | | | In this mode, there is no need to load any module map and the programmer can simply use "@import" syntax to load the module directly from a prebuilt module path. When loading from prebuilt module path, we don't support rebuilding of the module files and we ignore compatible configuration mismatches. rdar://27290316 Differential Revision: http://reviews.llvm.org/D23125 llvm-svn: 279096
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+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-6/+8
| | | | | | | | | | | 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-8/+6
| | | | llvm-svn: 272572
* Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2016-06-131-6/+8
| | | | | | | | | | | | | 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-8/+6
| | | | llvm-svn: 271761
* Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2016-06-031-6/+8
| | | | | | | | | | | 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
* Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer2016-05-271-2/+4
| | | | | | No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
* NFC: simplify logic.Manman Ren2016-05-171-2/+2
| | | | llvm-svn: 269794
* Modules: set SystemHeader to true if we are building a system module.Manman Ren2016-05-171-3/+4
| | | | | | | | | | | | If we are processing a #include from a module build, we should treat it as a system header if we're building a system module. Passing an optional flag to HeaderSearch::LookupFile. Before this, the testing case will crash when accessing a freed FileEntry. rdar://26214027 llvm-svn: 269730
* [Modules] Use vfs for (recursive) directory iterationBruno Cardoso Lopes2016-05-161-8/+11
| | | | | | | | | | | | | | | | Clang performs directory walk while searching headers inside modules by using the ::sys::fs instead of ::vfs. This prevents any code that uses the VFS (e.g, reproducer scripts) to actually find such headers, since the VFS will never be searched for those. Change these places to use vfs::recursive_directory_iterator and vfs::directory_iterator instead. Differential Revision: http://reviews.llvm.org/D20266 rdar://problem/25880368 llvm-svn: 269661
* Remove unused LangOpts private variable in HeaderSearch.Samuel Antao2016-04-271-2/+1
| | | | | | Was causing warnings during the build. llvm-svn: 267805
* [modules] When diagnosing a missing module import, suggest adding a #include ifRichard Smith2016-04-271-0/+51
| | | | | | | the current language doesn't have an import syntax and we can figure out a suitable file to include. llvm-svn: 267802
* Move LocInfoType from Sema to AST.Benjamin Kramer2016-02-011-1/+0
| | | | | | | While transient and only used during parsing, LocInfoTypes are still used from ASTDumper and are part of the AST. llvm-svn: 259376
* Module debugging: Make the module format part of the module hash insteadAdrian Prantl2016-01-121-2/+1
| | | | | | | | | | of the file name. This is consistent with how other HeaderSearchOptions are handled. Due to the other inputs of the module hash (revision number) this is not really testable in a meaningful way. llvm-svn: 257520
* Add back null check removed accidentally in r250554Reid Kleckner2015-10-201-0/+2
| | | | | | Fixes PR25262 llvm-svn: 250844
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | 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-1/+1
| | | | | | | | | | | | 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
* Refactor module lookup when looking up a header file, and wire through the ↵Richard Smith2015-10-161-85/+83
| | | | | | requesting module. No functionality change. llvm-svn: 250554
* Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1Adrian Prantl2015-08-271-1/+1
| | | | | | | | | | | | | to enable the use of external type references in the debug info (a.k.a. module debugging). The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs" and passes that to cc1. All this does at the moment is set a flag codegenopts. http://reviews.llvm.org/D11958 llvm-svn: 246192
* [modules] Remove unnecessary deserialization of fully-external ↵Richard Smith2015-08-241-28/+56
| | | | | | HeaderFileInfos for all files we've seen in this compilation. llvm-svn: 245881
* [modules] Fix HeaderFileInfo serialization to store all the known owning ↵Richard Smith2015-08-181-33/+40
| | | | | | modules for a header, not just the current favourite. llvm-svn: 245390
* [modules] Stop dropping 'module.timestamp' files into the current directoryRichard Smith2015-08-151-2/+2
| | | | | | when building with implicit modules disabled. llvm-svn: 245136
* [modules] Produce an error if -cc1 wants to implicitly build a module and noRichard Smith2015-07-211-2/+3
| | | | | | | module cache has been provided, rather than creating one in the current directory. llvm-svn: 242819
* 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
* [modules] When checking the include guard for a header, check whether it'sRichard Smith2015-07-101-8/+10
| | | | | | | | | | visible in the module we're considering entering. Previously we assumed that if we knew the include guard for a modular header, we'd already parsed it, but that need not be the case if a header is present in the current module and one of its dependencies; the result of getting this wrong was that the current module's submodule for the header would end up empty. llvm-svn: 241953
* [Modules] Be consistent about finding a module for framework headersBen Langmuir2015-07-021-10/+12
| | | | | | | | | | | | | | | | We use findModuleForHeader() in several places, but in header search we were not calling it when a framework module didn't show up with the expected name, which would then lead to unexpected non-modular includes. Now we will find the module unconditionally for frameworks. For regular frameworks, we use the spelling of the module name from the module map file, and for inferred ones we use the canonical directory name. In the future we might want to lock down framework modules sufficiently that these name mismatches cannot happen. rdar://problem/20465870 llvm-svn: 241258
* [modules] Before checking whether the controlling macro of a header is defined,Richard Smith2015-07-011-2/+7
| | | | | | | | | | | update the identifier in case we've imported a definition of the macro (and thus the contents of the header) from a module. Also fold ExternalIdentifierLookup into ExternalPreprocessorSource; it no longer makes sense to keep these separate now that the only user of the former also needs the latter. llvm-svn: 241137
* [modules] Make the include guard optimization fire a bit more when consideringRichard Smith2015-07-011-2/+6
| | | | | | | | | | | re-entering a modular header. When we do the include guard check, we're in the visibility state for the file with the #include; the include guard may not be visible there, but we don't actually need it to be: if we've already parsed the submodule we're considering entering, it's always safe to skip it. llvm-svn: 241135
* [modules] Simplify -cc1 interface for enabling implicit module maps.Richard Smith2015-06-161-7/+7
| | | | | | | | | | | | | We used to have a flag to enable module maps, and two more flags to enable implicit module maps. This is all redundant; we don't need any flag for enabling module maps in the abstract, and we don't usually have -fno- flags for -cc1. We now have just a single flag, -fimplicit-module-maps, that enables implicitly searching the file system for module map files and loading them. The driver interface is unchanged for now. We should probably rename -fmodule-maps to -fimplicit-module-maps at some point. llvm-svn: 239789
* [modules] If we see a #include that maps to a module, but use of precompiled ↵Richard Smith2015-05-181-2/+8
| | | | | | modules is disabled, track submodule visibility anyway if -fmodules-local-submodule-visibility is enabled. This, in effect, gives modules semantics but without precompilation. llvm-svn: 237550
* Revert "Fix path separator issue on Windows."Nikola Smiljanic2015-05-081-1/+3
| | | | | | This reverts commit 9242ff16b0460b488691fd70b42a2bf81a531e3a. llvm-svn: 236806
* Fix path separator issue on Windows.Nikola Smiljanic2015-05-081-3/+1
| | | | llvm-svn: 236804
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-2/+5
| | | | | | | | | | | | | | Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-12/+12
| | | | | | | | | | | | | | | 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
* Don't load Framework module.map files when searching subdirectoriesBen Langmuir2015-02-241-2/+4
| | | | | | | | | | | This would cause frameworks to have spurious "redefinition" errors if they had both a (legacy) "module.map" and a (new) "module.modulemap" file and we happened to do a sub-directory search in that directory using a non-framework include path (e.g. -Ifoo/ -Ffoo/). For migration purposes it's very handy that the compiler will prefer the new spelling of the filename and not look at the old one if it doesn't need to. llvm-svn: 230308
* Revert "Mangle the IsSystem bit into the .pcm file name"Ben Langmuir2015-02-191-8/+2
| | | | | | | | While I investigate some possible problems with this patch. This reverts commit r228966 llvm-svn: 229910
* Mangle the IsSystem bit into the .pcm file nameBen Langmuir2015-02-121-2/+8
| | | | | | | | | When mangling the module map path into a .pcm file name, also mangle the IsSystem bit, which can also depend on the header search paths. For example, the user may change from -I to -isystem. This can affect diagnostics in the importing TU. llvm-svn: 228966
* [modules] When constructing paths relative to a module, strip out /./ directoryRichard Smith2014-12-111-9/+17
| | | | | | | components. These sometimes get synthetically added, and we don't want -Ifoo and -I./foo to be treated fundamentally differently here. llvm-svn: 224055
* Reinstate r223753, reverted in r223759 due to breakage of clang-tools-extra.Richard Smith2014-12-101-11/+29
| | | | | | | | | | | | | | | | | Original commit message: [modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1. For files named by -fmodule-map-file=, and files found by 'extern module' directives, this flag specifies that we should resolve filenames relative to the current working directory rather than relative to the directory in which the module map file resides. This is aimed at fixing path handling, in particular for relative -I paths, when building modules that represent components of the current project (rather than libraries installed on the current system, which the current project has as dependencies, where we'd typically expect the module map files to be looked up implicitly). llvm-svn: 223913
OpenPOWER on IntegriCloud