summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/HeaderSearch.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Revert "[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1."Duncan P. N. Exon Smith2014-12-091-29/+11
| | | | | | | | | | | | | This reverts commit r223753. It broke the Green Dragon build for a few hours: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/ http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/consoleFull#43901905849ba4694-19c4-4d7e-bec5-911270d8a58c I suspect `clang-tools-extra` just needs a follow-up for an API change, but I'm not the right one to look into it. llvm-svn: 223759
* [modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1.Richard Smith2014-12-091-11/+29
| | | | | | | | | | | | | 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: 223753
* PR21217: Slightly more eagerly load -fmodule-map-file= files and provideRichard Smith2014-12-061-12/+0
| | | | | | diagnostics if they don't exist. Based on a patch by John Thompson! llvm-svn: 223561
* Additional safety for the root cause of regression in r223443; make the moduleRichard Smith2014-12-061-0/+1
| | | | | | map path more canonical before hashing it. No functionality change. llvm-svn: 223547
* [modules] Track how 'header' directives were written in module map files,Richard Smith2014-12-021-3/+14
| | | | | | | | | | | | | rather than trying to extract this information from the FileEntry after the fact. This has a number of beneficial effects. For instance, diagnostic messages for failed module builds give a path relative to the "module root" rather than an absolute file path, and the contents of the module includes file is no longer dependent on what files the including TU happened to inspect prior to triggering the module build. llvm-svn: 223095
* Add flag -f(no-)modules-implicit-maps.Daniel Jasper2014-11-251-44/+58
| | | | | | | This suppresses the implicit search for files called 'module.modulemap' and similar. llvm-svn: 222745
* clang-format a recent commit I madeDavid Blaikie2014-11-191-1/+1
| | | | llvm-svn: 222317
* Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie2014-11-191-15/+13
| | | | llvm-svn: 222306
* PR21215: Support -fmodule-map-file being specified multiple times. SupportRichard Smith2014-10-171-9/+11
| | | | | | loading multiple module map files from the same directory. llvm-svn: 220020
* Switch to range-based for loop. No functionality change.Richard Smith2014-10-171-9/+3
| | | | llvm-svn: 220014
* Correctly implement -include search logic.Manuel Klimek2014-08-121-36/+14
| | | | | | | | | | | | | | | According to the gcc docs, -include uses the current working directory for the lookup instead of the main source file. This patch gets rid of NormalizeIncludePath (which relied on an implementation detail of FileManager / FileEntry for the include path logic to work), and instead hands the correct lookup information down to LookupFile. This will allow us to change the FileEntry's behavior regarding its Name caching. llvm-svn: 215433
* Refactor the module map file used for uniquing a module name out ofBen Langmuir2014-08-091-1/+3
| | | | | | | | | class Module. It's almost always going to be the same as getContainingModule() for top-level modules, so just add a map to cover the remaining cases. This lets us do less bookkeeping to keep the ModuleMap fields up to date. llvm-svn: 215268
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-3/+1
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-3/+3
| | | | llvm-svn: 210780
* [C++11] Use 'nullptr'. Lex edition.Craig Topper2014-05-171-40/+40
| | | | llvm-svn: 209083
* Use the virtual name of headers when searching for a moduleBen Langmuir2014-05-151-6/+6
| | | | | | | | | | When using the VFS, we want the virtual header location when searching for a framework module, since that will be the one in the correct directory structure for the module. I'll add a regression test once I finish reducing the larger one I have. llvm-svn: 208901
* Allow multiple modules with the same name to coexist in the module cacheBen Langmuir2014-04-141-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To differentiate between two modules with the same name, we will consider the path the module map file that they are defined by* part of the ‘key’ for looking up the precompiled module (pcm file). Specifically, this patch renames the precompiled module (pcm) files from cache-path/<module hash>/Foo.pcm to cache-path/<module hash>/Foo-<hash of module map path>.pcm In addition, I’ve taught the ASTReader to re-resolve the names of imported modules during module loading so that if the header search context changes between when a module was originally built and when it is loaded we can rebuild it if necessary. For example, if module A imports module B first time: clang -I /path/to/A -I /path/to/B ... second time: clang -I /path/to/A -I /different/path/to/B ... will now rebuild A as expected. * in the case of inferred modules, we use the module map file that allowed the inference, not the __inferred_module.map file, since the inferred file path is the same for every inferred module. llvm-svn: 206201
* [HeaderSearch] Make sure we clear the mapped name from the ↵Argyrios Kyrtzidis2014-03-291-1/+1
| | | | | | | | LookupFileCacheInfo when we reset the start point. rdar://16462455 llvm-svn: 205071
* Prevent lookup of subframework modules by name without parent frameworkBen Langmuir2014-03-201-24/+3
| | | | | | | | | | | | | We were 'allowing' the following import @import Sub; where Sub is a subframework of Foo and we had a -F path inside Foo.framework/Frameworks and no module map file for Sub. This would later hit assertion failures in debug builds. Now we should correctly diagnose this as a module not found error. llvm-svn: 204368
* Silencing an MSVC warning about not all control paths returning a value. No ↵Aaron Ballman2014-03-201-0/+1
| | | | | | functional change intended. llvm-svn: 204345
* Add a new spelling for module map files 'module.modulemap'Ben Langmuir2014-03-191-63/+91
| | | | | | | | | | | | | | | This name, while more verbose, plays more nicely with tools that use file extensions to determine file types. The existing spelling 'module.map' will continue to work, but the new spelling will take precedence. In frameworks, this new filename will only go in a new 'Modules' sub-directory. Similarly, add a module.private.modulemap corresponding to module_private.map. llvm-svn: 204261
* Prevent outputting HeaderFileInfos for files not used as headersBen Langmuir2014-03-131-0/+12
| | | | | | | | | | | When building an AST file, we don't want to output HeaderFileInfo structures for files that are not actually used as headers in the current context. This can lead to assuming that unrelated files have include counts of 0, defeating multiple-include prevention. This is accomplished by adding an IsValid bit to the HFI. llvm-svn: 203813
* [HeaderSearch] Fix issue where if a headermap entry maps the filename to a ↵Argyrios Kyrtzidis2014-03-111-10/+28
| | | | | | | | | | framework import (non-absolute path) then we fail to find it if it is re-included later on. rdar://16285490 llvm-svn: 203542
* Fix use-after-free detected by ASan bootstrap.Richard Smith2014-03-061-2/+7
| | | | llvm-svn: 203140
* If a #include finds a file relative to the current file, don't forget to checkRichard Smith2014-03-051-24/+53
| | | | | | whether it's part of a module. llvm-svn: 203005
* Fix false positives in -Wmsvc-include by continuing header searchReid Kleckner2014-02-181-9/+44
| | | | | | | | | | | This makes Clang and LLVM -Wmsvc-include clean. I believe the correct behavior here is to avoid updating the cache when we find the header via MSVC's search rules. Differential Revision: http://llvm-reviews.chandlerc.com/D2733 llvm-svn: 201615
* If the headermap maps the filename to a framework include ("Foo.h" -> ↵Argyrios Kyrtzidis2014-02-141-5/+28
| | | | | | | | | | | | | | "Foo/Foo.h"), continue header lookup using the framework include as filename. This allows us to conveniently treat #import "Foo.h" as an implicit module import if we can resolve "Foo/Foo.h" as such. rdar://16042979 llvm-svn: 201419
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Silence compile warning by removing unused SourceMgr memberWill Wilson2013-12-271-3/+2
| | | | llvm-svn: 198083
* Implement MSVC header search algorithm in MicrosoftMode.Will Wilson2013-12-271-59/+63
| | | | | | Follows algorithm described here: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx llvm-svn: 198082
* Fix comment typo.Will Wilson2013-12-191-1/+1
| | | | llvm-svn: 197695
* Modules: Don't warn upon missing headers while reading the module map.Daniel Jasper2013-12-171-1/+1
| | | | | | | | | | | | | | | Instead, mark the module as unavailable so that clang errors as soon as someone tries to build this module. This works towards the long-term goal of not stat'ing the header files at all while reading the module map and instead read them only when the module is being built (there is a corresponding FIXME in parseHeaderDecl()). However, it seems non-trivial to get there and this unblock us and moves us into the right direction. Also changed the implementation to reuse the same DiagnosticsEngine. llvm-svn: 197485
* Revert "Modules: Make missing headers in a module.map a warning not an error."Daniel Jasper2013-12-161-1/+1
| | | | | | This was committed accidentally. llvm-svn: 197389
* Modules: Make missing headers in a module.map a warning not an error.Daniel Jasper2013-12-161-1/+1
| | | | | | | | | | | | | | | | Instead, mark the module as unavailable so that clang errors as soon as someone tries to build this module. A better long-term strategy might be to not stat the header files at all while reading the module map and instead read them only when the module is being built (there is a corresponding FIXME in parseHeaderDecl()). However, it seems non-trivial to get there and this would be a temporary solution to unblock us. Also changed the implementation to reuse the same DiagnosticsEngine as otherwise warnings can't be enabled or disabled with command-line flags. llvm-svn: 197388
* [Modules] Don't parse any module map if modules are disabled.Argyrios Kyrtzidis2013-12-121-0/+5
| | | | | | Fixes rdar://15644663. llvm-svn: 197165
* Revert r196859, "Use llvm::sys::path::append to concatenate paths", to ↵NAKAMURA Takumi2013-12-101-2/+5
| | | | | | appease FileManager. llvm-svn: 196865
* Use llvm::sys::path::append to concatenate pathsDmitri Gribenko2013-12-101-5/+2
| | | | llvm-svn: 196859
* Preload module maps in normal user directories, too.Douglas Gregor2013-11-011-3/+2
| | | | | | ... in case someone decides to -I/usr/include <rdar://problem/15235948>. llvm-svn: 193893
* Use the same SourceManager for ModuleMaps and compilations.Manuel Klimek2013-10-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows using virtual file mappings on the original SourceManager to map in virtual module.map files. Without this patch, the ModuleMap search will find a module.map file (as the FileEntry exists in the FileManager), but will be unable to get the content from the SourceManager (as ModuleMap previously created its own SourceManager). Two problems needed to be fixed which this patch exposed: 1. Storing the inferred module map When writing out a module, the ASTWriter stores the names of the files in the main source manager; when loading the AST again, the ASTReader errs out if such a file is found missing, unless it is overridden. Previously CompilerInstance's compileModule method would store the inferred module map to a temporary file; the problem with this approach is that now that the module map is handled by the main source manager, the ASTWriter stores the name of the temporary module map as source to the compilation; later, when the module is loaded, the temporary file has already been deleted, which leads to a compilation error. This patch changes the inferred module map to instead inject a virtual file into the source manager. This both saves some disk IO, and works with how the ASTWriter/ASTReader handle overridden source files. 2. Changing test input in test/Modules/Inputs/* Now that the module map file is handled by the main source manager, the VerifyDiagnosticConsumer will not ignore diagnostics created while parsing the module map file. The module test test/Modules/renamed.m uses -I test/Modules/Inputs and triggers recursive loading of all module maps in test/Modules/Inputs, some of which had conflicting names, thus leading errors while parsing the module maps. Those diagnostics already occur on trunk, but before this patch they would not break the test, as they were ignored by the VerifyDiagnosticConsumer. This patch thus changes the module maps that have been recently introduced which broke the invariant of compatible modules maps in test/Modules/Inputs. llvm-svn: 193314
* Allow a header to be part of multiple modules.Daniel Jasper2013-10-221-32/+29
| | | | | | | | | | | | | | | | | | | | This patch changes two things: a) Allow a header to be part of multiple modules. The reasoning is that in existing codebases that have a module-like build system, the same headers might be used in several build targets. Simple reasons might be that they defined different classes that are declared in the same header. Supporting a header as a part of multiple modules will make the transistion easier for those cases. A later step in clang can then determine whether the two modules are actually compatible and can be merged and error out appropriately. The later check is similar to what needs to be done for template specializations anyway. b) Allow modules to be stored in a directory tree separate from the headers they describe. Review: http://llvm-reviews.chandlerc.com/D1951 llvm-svn: 193151
* Add -fmodule-map-file option.Daniel Jasper2013-09-241-7/+29
| | | | | | | | | | | | | | | With this option, arbitrarily named module map files can be specified to be loaded as required for headers in the respective (sub)directories. This, together with the extern module declaration allows for specifying module maps in a modular fashion without the need for files called "module.map". Among other things, this allows a directory to contain two modules that are completely independent of one another. Review: http://llvm-reviews.chandlerc.com/D1697. llvm-svn: 191284
* Module use declarations (II)Daniel Jasper2013-09-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Review: http://llvm-reviews.chandlerc.com/D1546. I have picked up this patch form Lawrence (http://llvm-reviews.chandlerc.com/D1063) and did a few changes. From the original change description (updated as appropriate): This patch adds a check that ensures that modules only use modules they have so declared. To this end, it adds a statement on intended module use to the module.map grammar: use module-id A module can then only use headers from other modules if it 'uses' them. This enforcement is off by default, but may be turned on with the new option -fmodules-decluse. When enforcing the module semantics, we also need to consider a source file part of a module. This is achieved with a compiler option -fmodule-name=<module-id>. The compiler at present only applies restrictions to the module directly being built. llvm-svn: 191283
* [Modules] If a module map resides in a system header directory, treat it as ↵Douglas Gregor2013-06-211-19/+24
| | | | | | | | | a system module. This prevents -pedantic from causing warnings in the system headers used to create modules. Fixes <rdar://problem/14201171>. llvm-svn: 184560
* This patch adds new private headers to the module map. PrivateLawrence Crowl2013-06-201-10/+10
| | | | | | | headers may be included from within the module, but not from outside the module. llvm-svn: 184471
* [Modules] Make r180934 more efficient by only loading top-level module maps ↵Douglas Gregor2013-05-101-0/+14
| | | | | | in system header directories. llvm-svn: 181643
* [PCH] Remove the ASTReaderListener::ReadHeaderFileInfo callback.Argyrios Kyrtzidis2013-05-081-7/+0
| | | | | | | | This made sense in pre-module era, before merging of HeaderFileInfos was introduced. Final part of rdar://13840148. llvm-svn: 181490
* [modules] When building a module, make sure we don't serialize out ↵Argyrios Kyrtzidis2013-05-081-1/+3
| | | | | | | | | | | HeaderFileInfo for headers not belonging to the module. After r180934 we may initiate module map parsing for modules not related to the module what we are building, make sure we ignore the header file info of headers from such modules. First part of rdar://13840148 llvm-svn: 181489
OpenPOWER on IntegriCloud