summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
Commit message (Collapse)AuthorAgeFilesLines
...
* Teach the search for modules to consider modules described by a moduleDouglas Gregor2011-11-113-0/+10
| | | | | | | | | | | | | | map, so long as they have an umbrella header. This makes it possible to introduce a module map + umbrella header for a given set of headers, to turn it into a module. There are two major deficiencies here: first, we don't go hunting for module map files when we just see a module import (so we won't know about the modules described therein). Second, we don't yet have a way to build modules that don't have umbrella headers, or have incomplete umbrella headers. llvm-svn: 144424
* Wire up the mapping from header files mentioned in module maps over toDouglas Gregor2011-11-111-2/+4
| | | | | | | the corresponding (top-level) modules. This isn't actually useful yet, because we don't yet have a way to build modules out of module maps. llvm-svn: 144410
* Introduce basic support for parsing module map files.Douglas Gregor2011-11-118-0/+28
| | | | | | | | | | | | | | Module map files provide a way to map between headers and modules, so that we can layer a module system on top of existing headers without changing those headers at all. This commit introduces the module map file parser and the module map that it generates, and wires up the module map file parser so that we'll automatically find module map files as part of header search. Note that we don't yet use the information stored in the module map. llvm-svn: 144402
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AST file more lazy, so that we don't eagerly load that information for all known identifiers each time a new AST file is loaded. The eager reloading made some sense in the context of precompiled headers, since very few identifiers were defined before PCH load time. With modules, however, a huge amount of code can get parsed before we see an @import, so laziness becomes important here. The approach taken to make this information lazy is fairly simple: when we load a new AST file, we mark all of the existing identifiers as being out-of-date. Whenever we want to access information that may come from an AST (e.g., whether the identifier has a macro definition, or what top-level declarations have that name), we check the out-of-date bit and, if it's set, ask the AST reader to update the IdentifierInfo from the AST files. The update is a merge, and we now take care to merge declarations before/after imports with declarations from multiple imports. The results of this optimization are fairly dramatic. On a small application that brings in 14 non-trivial modules, this takes modules from being > 3x slower than a "perfect" PCH file down to 30% slower for a full rebuild. A partial rebuild (where the PCH file or modules can be re-used) is down to 7% slower. Making the PCH file just a little imperfect (e.g., adding two smallish modules used by a bunch of .m files that aren't in the PCH file) tips the scales in favor of the modules approach, with 24% faster partial rebuilds. This is just a first step; the lazy scheme could possibly be improved by adding versioning, so we don't search into modules we already searched. Moreover, we'll need similar lazy schemes for all of the other lookup data structures, such as DeclContexts. llvm-svn: 143100
* For modules, all macros that aren't include guards are implicitlyDouglas Gregor2011-10-174-1/+14
| | | | | | | public. Add a __private_macro__ directive to hide a macro, similar to the __module_private__ declaration specifier. llvm-svn: 142188
* When building a module, use the macro definitions on the command lineDouglas Gregor2011-10-174-5/+24
| | | | | | | | | as part of the hash rather than ignoring them. This means we'll end up building more module variants (overall), but it allows configuration macros such as NDEBUG to work so long as they're specified via command line. More to come in this space. llvm-svn: 142187
* Introduce an opt-in warning when a module is being implicitly builtDouglas Gregor2011-09-291-0/+5
| | | | | | from sources. llvm-svn: 140746
* When we load header file information from the external source (i.e.,Douglas Gregor2011-09-172-0/+9
| | | | | | | | the AST reader), merge that header file information with whatever header file information we already have. Otherwise, we might forget something we already knew (e.g., that the header was #import'd already). llvm-svn: 139979
* With modules, we can end up loading a new module after we've seen anDouglas Gregor2011-09-171-1/+2
| | | | | | | | | arbitrary amount of code. This forces us to stage the AST writer more strictly, ensuring that we don't assign a declaration ID to a declaration until after we're certain that no more modules will get loaded. llvm-svn: 139974
* Add an experimental flag -fauto-module-import that automatically turnsDouglas Gregor2011-09-153-0/+17
| | | | | | | #include or #import direcctives of framework headers into module imports of the corresponding framework module. llvm-svn: 139860
* Add test case for mutually recursive modulesDouglas Gregor2011-09-153-0/+21
| | | | llvm-svn: 139838
* When we load the first module, make sure that we wire up the ASTConsumer to ↵Douglas Gregor2011-09-151-0/+15
| | | | | | the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in llvm-svn: 139824
* Teach LangOptions::resetNonModularOptions to actually do what it says it doesDouglas Gregor2011-09-152-3/+9
| | | | llvm-svn: 139791
* Make -E work with module importsDouglas Gregor2011-09-141-0/+3
| | | | llvm-svn: 139750
* Don't try to write a macro offset for an identifier that names a ↵Douglas Gregor2011-09-141-0/+5
| | | | | | non-exported macro, for real this time llvm-svn: 139745
* Revert my exported-macro hackery. Something is amissDouglas Gregor2011-09-141-5/+0
| | | | llvm-svn: 139734
* Don't try to write a macro offset for an identifier that names a ↵Douglas Gregor2011-09-141-0/+5
| | | | | | non-exported macro llvm-svn: 139728
* Add test for the driver's handling of modulesDouglas Gregor2011-09-141-0/+6
| | | | llvm-svn: 139727
* For modules, use a hash of the compiler version, language options, andDouglas Gregor2011-09-138-20/+21
| | | | | | | | | target triple to separate modules built under different conditions. The hash is used to create a subdirectory in the module cache path where other invocations of the compiler (with the same version, language options, etc.) can find the precompiled modules. llvm-svn: 139662
* When building a module on-demand, clear out the "non-modular" languageDouglas Gregor2011-09-132-2/+6
| | | | | | and preprocessor options (such as macro definitions) first. llvm-svn: 139638
* Switch the serialization of LangOptions over to use the .def file. WeDouglas Gregor2011-09-131-1/+1
| | | | | | | should no longer have the serialization of LangOptions out of sync with the structure itself (yay). llvm-svn: 139613
* Add a struct-size check for modules when dealing with module-private fieldsDouglas Gregor2011-09-131-1/+9
| | | | llvm-svn: 139597
* When an import statement fails to find a module in the module cache,Douglas Gregor2011-09-122-0/+17
| | | | | | | | | but there is a corresponding umbrella header in a framework, build the module on-the-fly so it can be immediately loaded at the import statement. This is very much proof-of-concept code, with details to be fleshed out over time. llvm-svn: 139558
* Introduce a cc1-level option to provide the path to the module cache,Douglas Gregor2011-09-127-16/+16
| | | | | | | | where the compiler will look for module files. Eliminates the egregious hack where we looked into the header search paths for modules. llvm-svn: 139538
* Diagnose attempt to mark function-local declarations as __module_private__.Douglas Gregor2011-09-121-0/+10
| | | | llvm-svn: 139519
* Allow __module_private__ on fieldsDouglas Gregor2011-09-121-0/+10
| | | | llvm-svn: 139499
* Remove the restriction on module-private friends. Since the friendDouglas Gregor2011-09-121-2/+2
| | | | | | | declaration may be the first declaration, we want the ability to that declaration to be marked module-private. llvm-svn: 139497
* Don't crash when we fail to load a module. It's unbecoming of aDouglas Gregor2011-09-101-1/+3
| | | | | | well-bred compiler like Clang. llvm-svn: 139442
* Friends cannot be declared module-privateDouglas Gregor2011-09-091-0/+3
| | | | llvm-svn: 139411
* Specializations cannot be module-hidden. Diagnose attempts to do so.Douglas Gregor2011-09-091-0/+17
| | | | llvm-svn: 139406
* __module_private__ is inherited by redeclarations of an entity, andDouglas Gregor2011-09-091-0/+26
| | | | | | must also be present of the first declaration of that entity. llvm-svn: 139384
* Propagate __module_private__ from previous declarations to laterDouglas Gregor2011-09-091-2/+12
| | | | | | declarations. llvm-svn: 139380
* Modules: introduce the __module_private__ declaration specifier, whichDouglas Gregor2011-09-091-0/+56
| | | | | | | indicates that a declaration is only visible within the module it is declared in. llvm-svn: 139348
* Make test slightly trickierDouglas Gregor2011-09-011-0/+3
| | | | llvm-svn: 138957
* Modules hide macro definitions by default, so that silly things likeDouglas Gregor2011-09-011-0/+33
| | | | | | | | | | | include guards don't show up as macro definitions in every translation unit that imports a module. Macro definitions can, however, be exported with the intentionally-ugly #__export_macro__ directive. Implement this feature by not even bothering to serialize non-exported macros to a module, because clients of that module need not (should not) know that these macros even exist. llvm-svn: 138943
* Support importing of ObjC categories from modules.Argyrios Kyrtzidis2011-09-011-0/+85
| | | | | | | | | | | | The initial incentive was to fix a crash when PCH chaining categories to an interface, but the fix was done in the "modules way" that I hear is popular with the kids these days. Each module stores the local chain of categories and we combine them when the interface is loaded. We also warn if non-dependent modules introduce duplicate named categories. llvm-svn: 138926
* Switch __import__ over to __import_module__, so we don't conflict withDouglas Gregor2011-08-317-12/+12
| | | | | | | | existing practice with Python extension modules. Not that Python extension modules should be using a double-underscored identifier anyway, but... llvm-svn: 138870
* Take an entirely different approach to handling the "parsing" ofDouglas Gregor2011-08-271-1/+0
| | | | | | | | | __import__ within the preprocessor, since the prior one foolishly assumed that Preprocessor::Lex() was re-entrant. We now handle __import__ at the top level (only), after macro expansion. This should fix the buildbot failures. llvm-svn: 138704
* XFAIL one of the module tests on win32, until we figure out what's happeningDouglas Gregor2011-08-271-0/+1
| | | | llvm-svn: 138688
* Introduce support for a simple module import declaration, whichDouglas Gregor2011-08-268-13/+52
| | | | | | | | | | | | | | | | | | | | | | loads the named module. The syntax itself is intentionally hideous and will be replaced at some later point with something more palatable. For now, we're focusing on the semantics: - Module imports are handled first by the preprocessor (to get macro definitions) and then the same tokens are also handled by the parser (to get declarations). If both happen (as in normal compilation), the second one is redundant, because we currently have no way to hide macros or declarations when loading a module. Chris gets credit for this mad-but-workable scheme. - The Preprocessor now holds on to a reference to a module loader, which is responsible for loading named modules. CompilerInstance is the only important module loader: it now knows how to create and wire up an AST reader on demand to actually perform the module load. - We search for modules in the include path, using the module name with the suffix ".pcm" (precompiled module) for the file name. This is a temporary hack; we hope to improve the situation in the future. llvm-svn: 138679
* Introduce a -cc1 option "-emit-module", that creates a binary moduleDouglas Gregor2011-08-253-5/+8
| | | | | | | | | from the given source. -emit-module behaves similarly to -emit-pch, except that Sema is somewhat more strict about the contents of -emit-module. In the future, there are likely to be more interesting differences. llvm-svn: 138595
* Use the module manager's search facility to look for methods with aDouglas Gregor2011-08-253-0/+25
| | | | | | | | | given selector, rather than walking the chain backwards. Teach its visitor how to merge multiple result sets into a single result set, combining the results of selector lookup in several different modules into a single result set. llvm-svn: 138556
* Introduce a depth-first search of modules into the module manager,Douglas Gregor2011-08-241-3/+9
| | | | | | | | | | | | which supports both pre-order and post-order traversal via a visitor mechanism. Use this depth-first search with a post-order traversal to give predictable ordering semantics when walking all of the lexical declarations in the translation unit. Eventually, module imports will occur in the source code rather than at the beginning, and we'll have to revisit this walk. llvm-svn: 138490
* In the AST reader, switch name lookup within a DeclContect over to theDouglas Gregor2011-08-243-0/+16
| | | | | | | | | | | | | | | | | | module DAG-based lookup scheme. This required some reshuffling, so that each module stores its own mapping from DeclContexts to their lexical and visible sets for those DeclContexts (rather than one big "chain"). Overall, this allows simple qualified name lookup into the translation unit to gather results from multiple modules, with the lookup results in module B shadowing the lookup results in module A when B imports A. Walking all of the lexical declarations in a module DAG is still a mess; we'll end up walking the loaded module list backwards, which works fine for chained PCH but doesn't make sense in a DAG. I'll tackle this issue as a separate commit. llvm-svn: 138463
* Make the loading of multiple records for the same identifier (fromDouglas Gregor2011-08-203-0/+11
| | | | | | | | | | different modules) more robust. It already handled (simple) merges of the set of declarations attached to that identifier, so add a test case that shows us getting two different declarations for the same identifier (one struct, one function) from different modules, and are able to use both of them. llvm-svn: 138189
* Introduce a module visitation function that starts at the top-levelDouglas Gregor2011-08-203-0/+9
| | | | | | | | | | | | | | | | | modules (those that no other module depends on) and performs a search over all of the modules, visiting a new module only when all of the modules that depend on it have already been visited. The visitor can abort the search for all modules that a module depends on, which allows us to minimize the number of lookups necessary when performing a search. Switch identifier lookup from a linear walk over the set of modules to this module visitation operation. The behavior is the same for simple PCH and chained PCH, but provides the proper search order for modules. Verified with printf debugging, since we don't have enough in place to actually test this. llvm-svn: 138187
* Teach ModuleManager::addModule() to check whether a particular moduleDouglas Gregor2011-08-195-0/+18
| | | | | | | | | | | | | | | | | | has already been loaded before allocating a new Module structure. If the module has already been loaded (uniquing based on file name), then just return the existing module rather than trying to load it again. This allows us to load a DAG of modules. Introduce a simple test case that forms a diamond-shaped module graph, and illustrates that a source file importing the bottom of the diamond can see declarations in all four of the modules that make up the diamond. Note that this version moves the file-opening logic into the module manager, rather than splitting it between the module manager and the AST reader. More importantly, it properly handles the weird-but-possibly-useful case of loading an AST file from "-". llvm-svn: 138030
* Temporarily revert r137925 to appease buildbots. Original commit message:Chad Rosier2011-08-185-18/+0
| | | | | | | | | | | | | | Teach ModuleManager::addModule() to check whether a particular module has already been loaded before allocating a new Module structure. If the module has already been loaded (uniquing based on file name), then just return the existing module rather than trying to load it again. This allows us to load a DAG of modules. Introduce a simple test case that forms a diamond-shaped module graph, and illustrates that a source file importing the bottom of the diamond can see declarations in all four of the modules that make up the diamond. llvm-svn: 137971
* Teach ModuleManager::addModule() to check whether a particular moduleDouglas Gregor2011-08-185-0/+18
has already been loaded before allocating a new Module structure. If the module has already been loaded (uniquing based on file name), then just return the existing module rather than trying to load it again. This allows us to load a DAG of modules. Introduce a simple test case that forms a diamond-shaped module graph, and illustrates that a source file importing the bottom of the diamond can see declarations in all four of the modules that make up the diamond. llvm-svn: 137925
OpenPOWER on IntegriCloud