aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Module.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-02-27Forward declare FileEntry and DirectoryEntry in Module.hReid Kleckner1-2/+7
FileManager.h is an expensive header (~350ms for me in isolation), so try to do without it. Notably, we need to avoid checking the alignment of FileEntry, which happens for DenseMap<FileEntry*> and PointerUnion<FileEntry*>. I adjusted the code to avoid PointerUnion, and moved the DenseMap insertion to the .cpp file. Globally, this only saved about ~17 includes of the related headers because SourceManager.h still includes FileManager.h, and it is more popular than Module.h.
2020-01-29Fix conversions in clang and examplesBenjamin Kramer1-1/+1
2019-08-01[clang] Adopt new FileManager error-returning APIsHarlan Haskins1-2/+2
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-05-07-frewrite-imports: Add support for wildcard rules in umbrella modules withDavid Blaikie1-0/+15
This trips over a few other limitations, but in the interests of incremental development I'm starting here & I'll look at the issues with -verify and filesystem checks (the fact that the behavior depends on the existence of a 'foo' directory even though it shouldn't need it), etc. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D61656 llvm-svn: 360195
2019-02-23Enable coroutines under -std=c++2a.Richard Smith1-1/+1
llvm-svn: 354736
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
2018-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington1-1/+1
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
2018-09-18[Modules] Add platform and environment features to requires clauseBruno Cardoso Lopes1-1/+33
Allows module map writers to add build requirements based on platform/os. This helps when target features and language dialects aren't enough to conditionalize building a module, among other things, it allow module maps for different platforms to live in the same file. rdar://problem/43909745 Differential Revision: https://reviews.llvm.org/D51910 llvm-svn: 342499
2018-09-12When we leave a module header, make that header visible in itsRichard Smith1-6/+5
includer's context, even if its overall module is unavailable. llvm-svn: 342096
2018-07-30Remove trailing spaceFangrui Song1-14/+14
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-1/+1
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-20Record whether a module came from a private module mapJordan Rose1-1/+4
Right now we only use this information in one place, immediately after we calculate it, but it's still nice information to have. The Swift project is going to use this to tidy up its "API notes" feature (see past discussion on cfe-dev that never quite converged). Reviewed by Bruno Cardoso Lopes. llvm-svn: 330452
2018-02-14[Modules] Add more language features to be used with requires-declarationBruno Cardoso Lopes1-0/+5
Features added: c99, c11, c17, cplusplus14 and cplusplus17. rdar://problem/36328787 rdar://problem/36668431 llvm-svn: 325154
2018-01-05Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to ↵Bruno Cardoso Lopes1-1/+6
shadow implicitly found ones When modules come from module map files explicitly specified by -fmodule-map-file= arguments, allow those to override/shadow modules with the same name that are found implicitly by header search. If such a module is looked up by name (e.g. @import), we will always find the one from -fmodule-map-file. If we try to use a shadowed module by including one of its headers report an error. This enables developers to force use of a specific copy of their module to be used if there are multiple copies that would otherwise be visible, for example if they develop modules that are installed in the default search paths. Patch originally by Ben Langmuir, http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html Based on cfe-dev discussion: http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html Differential Revision: https://reviews.llvm.org/D31269 rdar://problem/23612102 llvm-svn: 321855
2018-01-04Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow ↵Bruno Cardoso Lopes1-6/+1
implicitly found ones" This reverts r321781 until I fix the leaks pointed out by bots: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12146 http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3741 llvm-svn: 321786
2018-01-04[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly ↵Bruno Cardoso Lopes1-1/+6
found ones When modules come from module map files explicitly specified by -fmodule-map-file= arguments, allow those to override/shadow modules with the same name that are found implicitly by header search. If such a module is looked up by name (e.g. @import), we will always find the one from -fmodule-map-file. If we try to use a shadowed module by including one of its headers report an error. This enables developers to force use of a specific copy of their module to be used if there are multiple copies that would otherwise be visible, for example if they develop modules that are installed in the default search paths. Patch originally by Ben Langmuir, http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html Based on cfe-dev discussion: http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html Differential Revision: https://reviews.llvm.org/D31269 rdar://problem/23612102 llvm-svn: 321781
2017-11-03[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko1-7/+18
other minor fixes (NFC). llvm-svn: 317381
2017-09-14[Module map] Introduce a private module re-export directive.Douglas Gregor1-0/+5
Introduce a new "export_as" directive for top-level modules, which indicates that the current module is a "private" module whose symbols will eventually be exported through the named "public" module. This is in support of a common pattern in the Darwin ecosystem where a single public framework is constructed of several private frameworks, with (currently) header duplication and some support from the linker. Addresses rdar://problem/34438420. llvm-svn: 313316
2017-06-19Support non-identifier module names when preprocessing modules.Richard Smith1-22/+41
llvm-svn: 305758
2017-06-02Support lazy stat'ing of files referenced by module maps.Richard Smith1-1/+20
This patch adds support for a `header` declaration in a module map to specify certain `stat` information (currently, size and mtime) about that header file. This has two purposes: - It removes the need to eagerly `stat` every file referenced by a module map. Instead, we track a list of unresolved header files with each size / mtime (actually, for simplicity, we track submodules with such headers), and when attempting to look up a header file based on a `FileEntry`, we check if there are any unresolved header directives with that `FileEntry`'s size / mtime and perform deferred `stat`s if so. - It permits a preprocessed module to be compiled without the original files being present on disk. The only reason we used to need those files was to get the `stat` information in order to do header -> module lookups when using the module. If we're provided with the `stat` information in the preprocessed module, we can avoid requiring the files to exist. Unlike most `header` directives, if a `header` directive with `stat` information has no corresponding on-disk file the enclosing module is *not* marked unavailable (so that behavior is consistent regardless of whether we've resolved a header directive, and so that preprocessed modules don't get marked unavailable). We could actually do this for all `header` directives: the only reason we mark the module unavailable if headers are missing is to give a diagnostic slightly earlier (rather than waiting until we actually try to build the module / load and validate its .pcm file). Differential Revision: https://reviews.llvm.org/D33703 llvm-svn: 304515
2017-05-28[coroutines] Support "coroutines" feature in module map requires clauseEric Fiselier1-0/+1
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33538 llvm-svn: 304107
2017-05-27Revert "[coroutines] Support "coroutines" feature in module map requires clause"Eric Fiselier1-1/+0
This reverts commit r304054. llvm-svn: 304057
2017-05-27[coroutines] Support "coroutines" feature in module map requires clauseEric Fiselier1-0/+1
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33538 llvm-svn: 304054
2017-04-11Modular Codegen: Add/use a bit in serialized function definitions to track ↵David Blaikie1-1/+1
whether they are the subject of modular codegen Some decls are created not where they are written, but in other module files/users (implicit special members and function template implicit specializations). To correctly identify them, use a bit next to the definition to track the modular codegen property. Discussed whether the module file bit could be omitted in favor of reconstituting from the modular codegen decls list - best guess today is that the efficiency improvement of not having to deserialize the whole list whenever any function is queried by a module user is worth it for the small size increase of this redundant (list + bit-on-def) representation. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D29901 llvm-svn: 299982
2017-03-13Modules: Use hash of PCM content for SIGNATUREDuncan P. N. Exon Smith1-1/+1
Change ASTFileSignature from a random 32-bit number to the hash of the PCM content. - Move definition ASTFileSignature to Basic/Module.h so Module and ASTSourceDescriptor can use it. - Change the signature from uint64_t to std::array<uint32_t,5>. - Stop using (saving/reading) the size and modification time of PCM files when there is a valid SIGNATURE. - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record and other records that shouldn't affect the hash. Because implicit modules reuses the same file for multiple levels of -Werror, this includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS. This helps to solve a PCH + implicit Modules dependency issue: PCH files are handled by the external build system, whereas implicit modules are handled by internal compiler build system. This prevents invalidating a PCH when the compiler overwrites a PCM file with the same content (modulo the diagnostic differences). Design and original patch by Manman Ren! llvm-svn: 297655
2017-01-30Prototype of modules codegenDavid Blaikie1-1/+1
First pass at generating weak definitions of inline functions from module files (& skipping (-O0) or emitting available_externally (optimizations) definitions where those modules are used). External functions defined in modules are emitted into the modular object file as well (this may turn an existing ODR violation (if that module were imported into multiple translations) into valid/linkable code). Internal symbols (static functions, for example) are not correctly supported yet. The symbol will be produced, internal, in the modular object - unreferenceable from the users. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D28845 llvm-svn: 293456
2016-10-21[Modules] Add 'no_undeclared_includes' module map attributeBruno Cardoso Lopes1-1/+8
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-09-04[Modules] Add 'freestanding' to the 'requires-declaration' feature-list.Elad Cohen1-0/+1
This adds support for modules that require (non-)freestanding environment, such as the compiler builtin mm_malloc submodule. Differential Revision: https://reviews.llvm.org/D23871 llvm-svn: 280613
2016-08-30[Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.Bruno Cardoso Lopes1-0/+1
This adds support for modules that require (no-)gnu-inline-asm environment, such as the compiler builtin cpuid submodule. This is the gnu-inline-asm variant of https://reviews.llvm.org/D23871 Differential Revision: https://reviews.llvm.org/D23905 rdar://problem/26931199 llvm-svn: 280159
2016-03-09[modules] Simplify code logic. NFC.Davide Italiano1-6/+2
llvm-svn: 263060
2016-02-11[Modules] Don't infinite recurse on implicit import of circular modules in ↵Ben Langmuir1-0/+1
preamble Update the Preprocessor's VisibleModuleSet when typo-correction creates an implicit module import so that we won't accidentally write an invalid SourceLocation into the preamble AST. This would later lead to infinite recursion when loading the preamble AST because we use the value in ImportLocs to prevent visiting a module twice. rdar://problem/24440990 llvm-svn: 260543
2016-01-29Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren1-1/+1
r259192 post commit comment. llvm-svn: 259232
2015-11-05[modules] If we're given a module file, via -fmodule-file=, for a module, butRichard Smith1-5/+6
we can't load that file due to a configuration mismatch, and implicit module building is disabled, and the user turns off the error-by-default warning for that situation, then fall back to textual inclusion for the module rather than giving an error if any of its headers are included. llvm-svn: 252114
2015-08-13[Modules] Add Darwin-specific compatibility module map parsing hacksBen Langmuir1-0/+9
This preserves backwards compatibility for two hacks in the Darwin system module map files: 1. The use of 'requires excluded' to make headers non-modular, which should really be mapped to 'textual' now that we have this feature. 2. Silently removes a bogus cplusplus requirement from IOKit.avc. Once we start diagnosing missing requirements and headers on auto-imports these would have broken compatibility with existing Darwin SDKs. llvm-svn: 244912
2015-07-30Add support for System z vector language extensionsUlrich Weigand1-0/+1
The z13 vector facility has an associated language extension, closely modeled on AltiVec/VSX. The main differences are: - vector long, vector float and vector pixel are not supported - vector long long and vector double are supported (like VSX) - comparison operators return a vector rather than a scalar integer - shift operators behave like the OpenCL shift operators - vector bool is only supported as argument to certain operators; some operators allow mixing a bool with a non-bool vector This patch adds clang support for the extension. It is closely modelled on the AltiVec support. Similarly to the -faltivec option, there's a new -fzvector option to enable the extensions (as well as an -mzvector alias for compatibility with GCC). There's also a separate LangOpt. The extension as implemented here is intended to be compatible with the -mzvector extension recently implemented by GCC. Based on a patch by Richard Sandiford. Differential Revision: http://reviews.llvm.org/D11001 llvm-svn: 243642
2015-07-13[Modules] Allow missing header before a missing requirementBen Langmuir1-7/+11
And make the module unavailable without breaking any parent modules. If there's a missing requirement after we've already seen a missing header, still update the IsMissingRequiement bit correctly. Also, diagnose missing requirements before missing headers, since the existence of the header is moot if there are missing requirements. llvm-svn: 242055
2015-06-30Add a function to ExternalASTSource that returns a descriptor thatAdrian Prantl1-1/+1
abstracts the commonalities between modules and PCH files that are needed to emit debug info for a module or precompiled header. llvm-svn: 241083
2015-05-16[modules] Retain the name as written for umbrella headers and directories, ↵Richard Smith1-8/+8
rather than converting to an absolute path. No observable change expected, but this allows us to correctly compute the module for an umbrella header, which later changes will require. llvm-svn: 237508
2015-05-01[modules] Start moving the module visibility information off the Module itself.Richard Smith1-7/+50
It has no place there; it's not a property of the Module, and it makes restoring the visibility set when we leave a submodule more difficult. llvm-svn: 236300
2015-03-26[modules] Restrict the module use-declaration to only appear in top-levelRichard Smith1-0/+13
modules, and allow sub-modules of a module with a use-declaration to make use of the nominated modules. llvm-svn: 233323
2015-02-02Add cc1 option '-fmodule-feature' to add custom values for 'requires' declsBen Langmuir1-10/+15
This allows clang-based tools to specify custom features that can be tested by the 'requires' declaration in a module map file. llvm-svn: 227868
2015-01-13Handle [extern_c] attribute in module printerBen Langmuir1-2/+5
I'm not sure why we have OS.indent(Indent+2) for the system attribute, but presumably we want the same behaviour for all attributes... llvm-svn: 225802
2014-12-02[modules] Track how 'header' directives were written in module map files,Richard Smith1-12/+13
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
2014-10-22[modules] Add support for 'textual header' directives.Richard Smith1-19/+15
This allows a module to specify that it logically contains a file, but that said file is non-modular and intended for textual inclusion. This allows layering checks to work properly in the presence of such files. llvm-svn: 220448
2014-08-09Refactor the module map file used for uniquing a module name out ofBen Langmuir1-3/+7
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
2014-05-08[C++11] Use 'nullptr'.Craig Topper1-6/+6
llvm-svn: 208280
2014-04-23Do not print inferred submodules explicitly in __inferred_module.mapBen Langmuir1-4/+6
Otherwise including a header in your source file that is not included by framework's umbrella header will silently add an empty submodule with that name. is automatically translated to @import Foo.NotInModule; which then would have succeeded because the inferred module map contained an empty submodule called NotInModule. llvm-svn: 207024
2014-04-21Initialize clang::Module::IsMissingRequirement. Fix msan issue and hopefully ↵Richard Smith1-6/+6
some builder failures. llvm-svn: 206736
2014-04-18Fix a hole with nested unavailable submodules from r206664Ben Langmuir1-3/+4
If a module doesn't meet a requirement, neither do its submodules. If we don't propogate that, we might think it's an error to be missing a header in one of those submodules. llvm-svn: 206673
2014-04-18Don't build modules with (submodules with) missing headersBen Langmuir1-0/+5
Unless they are in submodules that aren't available anyway, due to requirements not being met. Also, mark children as unavailable when the parent is. llvm-svn: 206664