aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderSearch.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-12-11[CrashReproducer] Collect headermap filesBruno Cardoso Lopes1-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
2016-11-04Add some more asserts to clearly indicate that there are special casesChandler Carruth1-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
2016-10-21[Modules] Add 'no_undeclared_includes' module map attributeBruno Cardoso Lopes1-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
2016-10-11Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)Mehdi Amini1-1/+1
llvm-svn: 283856
2016-10-10Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini1-8/+10
llvm-svn: 283815
2016-10-01Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini1-1/+1
llvm-svn: 283043
2016-08-18Module: add -fprebuilt-module-path to support loading prebuilt modules.Manman Ren1-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
2016-07-18[NFC] Header cleanupMehdi Amini1-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
2016-06-13Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh1-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
2016-06-13Revert r272562 for build bot failure (clang-x86-win2008-selfhost)Taewook Oh1-8/+6
llvm-svn: 272572
2016-06-13Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh1-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
2016-06-04Revert commit r271708Taewook Oh1-8/+6
llvm-svn: 271761
2016-06-03Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh1-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
2016-05-27Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer1-2/+4
No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
2016-05-17NFC: simplify logic.Manman Ren1-2/+2
llvm-svn: 269794
2016-05-17Modules: set SystemHeader to true if we are building a system module.Manman Ren1-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
2016-05-16[Modules] Use vfs for (recursive) directory iterationBruno Cardoso Lopes1-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
2016-04-27Remove unused LangOpts private variable in HeaderSearch.Samuel Antao1-2/+1
Was causing warnings during the build. llvm-svn: 267805
2016-04-27[modules] When diagnosing a missing module import, suggest adding a #include ifRichard Smith1-0/+51
the current language doesn't have an import syntax and we can figure out a suitable file to include. llvm-svn: 267802
2016-02-01Move LocInfoType from Sema to AST.Benjamin Kramer1-1/+0
While transient and only used during parsing, LocInfoTypes are still used from ASTDumper and are part of the AST. llvm-svn: 259376
2016-01-12Module debugging: Make the module format part of the module hash insteadAdrian Prantl1-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
2015-10-20Add back null check removed accidentally in r250554Reid Kleckner1-0/+2
Fixes PR25262 llvm-svn: 250844
2015-10-20Roll-back r250822.Angel Garcia Gomez1-1/+1
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-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
2015-10-16Refactor module lookup when looking up a header file, and wire through the ↵Richard Smith1-85/+83
requesting module. No functionality change. llvm-svn: 250554
2015-08-27Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1Adrian Prantl1-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
2015-08-24[modules] Remove unnecessary deserialization of fully-external ↵Richard Smith1-28/+56
HeaderFileInfos for all files we've seen in this compilation. llvm-svn: 245881
2015-08-18[modules] Fix HeaderFileInfo serialization to store all the known owning ↵Richard Smith1-33/+40
modules for a header, not just the current favourite. llvm-svn: 245390
2015-08-15[modules] Stop dropping 'module.timestamp' files into the current directoryRichard Smith1-2/+2
when building with implicit modules disabled. llvm-svn: 245136
2015-07-21[modules] Produce an error if -cc1 wants to implicitly build a module and noRichard Smith1-2/+3
module cache has been provided, rather than creating one in the current directory. llvm-svn: 242819
2015-07-17Make the clang module container format selectable from the command line.Adrian Prantl1-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
2015-07-10[modules] When checking the include guard for a header, check whether it'sRichard Smith1-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
2015-07-02[Modules] Be consistent about finding a module for framework headersBen Langmuir1-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
2015-07-01[modules] Before checking whether the controlling macro of a header is defined,Richard Smith1-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
2015-07-01[modules] Make the include guard optimization fire a bit more when consideringRichard Smith1-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
2015-06-16[modules] Simplify -cc1 interface for enabling implicit module maps.Richard Smith1-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
2015-05-18[modules] If we see a #include that maps to a module, but use of precompiled ↵Richard Smith1-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
2015-05-08Revert "Fix path separator issue on Windows."Nikola Smiljanic1-1/+3
This reverts commit 9242ff16b0460b488691fd70b42a2bf81a531e3a. llvm-svn: 236806
2015-05-08Fix path separator issue on Windows.Nikola Smiljanic1-3/+1
llvm-svn: 236804
2015-04-29[modules] Stop trying to fake up a linear MacroDirective history.Richard Smith1-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
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-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
2015-02-24Don't load Framework module.map files when searching subdirectoriesBen Langmuir1-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
2015-02-19Revert "Mangle the IsSystem bit into the .pcm file name"Ben Langmuir1-8/+2
While I investigate some possible problems with this patch. This reverts commit r228966 llvm-svn: 229910
2015-02-12Mangle the IsSystem bit into the .pcm file nameBen Langmuir1-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
2014-12-11[modules] When constructing paths relative to a module, strip out /./ directoryRichard Smith1-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
2014-12-10Reinstate r223753, reverted in r223759 due to breakage of clang-tools-extra.Richard Smith1-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
2014-12-09Revert "[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1."Duncan P. N. Exon Smith1-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
2014-12-09[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1.Richard Smith1-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
2014-12-06PR21217: Slightly more eagerly load -fmodule-map-file= files and provideRichard Smith1-12/+0
diagnostics if they don't exist. Based on a patch by John Thompson! llvm-svn: 223561
2014-12-06Additional safety for the root cause of regression in r223443; make the moduleRichard Smith1-0/+1
map path more canonical before hashing it. No functionality change. llvm-svn: 223547