summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
Commit message (Collapse)AuthorAgeFilesLines
...
* <rdar://problem/13479214> Make Clang's <stddef.h> robust against system ↵Douglas Gregor2013-03-224-0/+24
| | | | | | | | | | | | | | headers defining size_t/ptrdiff_t/wchar_t. Clang's <stddef.h> provides definitions for the C standard library types size_t, ptrdiff_t, and wchar_t. However, the system's C standard library headers tend to provide the same typedefs, and the two generally avoid each other using the macros _SIZE_T/_PTRDIFF_T/_WCHAR_T. With modules, however, we need to see *all* of the places where these types are defined, so provide the typedefs (ignoring the macros) when modules are enabled. llvm-svn: 177686
* <rdar://problem/13477190> Give the Clang module cache directory some ↵Douglas Gregor2013-03-211-1/+1
| | | | | | | | | | structure, so it's easier to find. We now put the Clang module cache in <system-temp-directory>/org.llvm.clang/ModuleCache. Perhaps some day there will be other caches under <system-temp-directory>/org.llvm.clang>. llvm-svn: 177671
* <rdar://problem/13037793> Allow the names of modules to differ from the name ↵Douglas Gregor2013-03-216-6/+19
| | | | | | of their subdirectory in the include path. llvm-svn: 177621
* <rdar://problem/12368093> Extend module maps with a 'conflict' declaration, ↵Douglas Gregor2013-03-204-0/+19
| | | | | | and warn when a newly-imported module conflicts with an already-imported module. llvm-svn: 177577
* <rdar://problem/10796651> Introduce configuration macros into module maps.Douglas Gregor2013-03-203-0/+40
| | | | | | | | | | | | | | | | | | | | | | Configuration macros are macros that are intended to alter how a module works, such that we need to build different module variants for different values of these macros. A module can declare its configuration macros, in which case we will complain if the definition of a configation macro on the command line (or lack thereof) differs from the current preprocessor state at the point where the module is imported. This should eliminate some surprises when enabling modules, because "#define CONFIG_MACRO ..." followed by "#include <module/header.h>" would silently ignore the CONFIG_MACRO setting. At least it will no longer be silent about it. Configuration macros are eventually intended to help reduce the number of module variants that need to be built. When the list of configuration macros for a module is exhaustive, we only need to consider the settings for those macros when building/finding the module, which can help isolate modules for various project-specific -D flags that should never affect how modules are build (but currently do). llvm-svn: 177466
* <rdar://problem/13363214> Eliminate race condition between module rebuild ↵Douglas Gregor2013-03-193-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | and the global module index. The global module index was querying the file manager for each of the module files it knows about at load time, to prune out any out-of-date information. The file manager would then cache the results of the stat() falls used to find that module file. Later, the same translation unit could end up trying to import one of the module files that had previously been ignored by the module cache, but after some other Clang instance rebuilt the module file to bring it up-to-date. The stale stat() results in the file manager would trigger a second rebuild of the already-up-to-date module, causing failures down the line. The global module index now lazily resolves its module file references to actual AST reader module files only after the module file has been loaded, eliminating the stat-caching race. Moreover, the AST reader can communicate to its caller that a module file is missing (rather than simply being out-of-date), allowing us to simplify the module-loading logic and allowing the compiler to recover if a dependent module file ends up getting deleted. llvm-svn: 177367
* Ensure that the identifier chains have the most recent declaration after ↵Douglas Gregor2013-02-184-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | module deserialization. This commit introduces a set of related changes to ensure that the declaration that shows up in the identifier chain after deserializing declarations with a given identifier is, in fact, the most recent declaration. The primary change involves waiting until after we deserialize and wire up redeclaration chains before updating the identifier chains. There is a minor optimization in here to avoid recursively deserializing names as part of looking to see whether top-level declarations for a given name exist. A related change that became suddenly more urgent is to property record a merged declaration when an entity first declared in the current translation unit is later deserialized from a module (that had not been loaded at the time of the original declaration). Since we key off the canonical declaration (which is parsed, not from an AST file) for emitted redeclarations, we simply record this as a merged declaration during AST writing and let the readers merge them. Re-fixes <rdar://problem/13189985>, presumably for good this time. llvm-svn: 175447
* Change this comment to helpfully explain why it's there.Nick Lewycky2013-02-131-1/+2
| | | | llvm-svn: 175027
* Order the methods in the global method pool based on when they become ↵Douglas Gregor2013-02-123-6/+22
| | | | | | visible, not when they become deserialized <rdar://problem/13203033>. llvm-svn: 175018
* Fix a bug reduced from a crash when trying to use modules with libc++. We checkRichard Smith2013-02-123-0/+23
| | | | | | | | the linkage of functions and variables while merging declarations from modules, and we don't necessarily have enough of the rest of the AST loaded at that point to allow us to compute linkage, so serialize it instead. llvm-svn: 174943
* Remove an assert which triggers when a decl context in a module hits the 'hasRichard Smith2013-02-123-0/+21
| | | | | | | | | lexical storage but not visible storage' case in C++. It's unclear whether we even need the special-case handling for C++, since it seems to be working around our not serializing a lookup table for the TU in C. But in any case, the assertion is incorrect. llvm-svn: 174931
* [Modules] Cope better with top-level declarations loaded after being ↵Douglas Gregor2013-02-115-0/+29
| | | | | | | | | | | | | | | | | | | | declared in the current translation unit <rdar://problem/13189985>. These two related tweaks to keep the information associated with a given identifier correct when the identifier has been given some top-level information (say, a top-level declaration) and more information is then loaded from a module. The first ensures that an identifier that was "interesting" before being loaded from an AST is considered to be different from its on-disk counterpart. Otherwise, we lose such changes when writing the current translation unit as a module. Second, teach the code that injects AST-loaded names into the identifier chain for name lookup to keep the most recent declaration, so that we don't end up confusing our declaration chains by having a different declaration in there. llvm-svn: 174895
* Ensure that type definitions present in just-loaded modules areDouglas Gregor2013-02-093-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | visible. The basic problem here is that a given translation unit can use forward declarations to form pointers to a given type, say, class X; X *x; and then import a module that includes a definition of X: import XDef; We will then fail when attempting to access a member of X, e.g., x->method() because the AST reader did not know to look for a default of a class named X within the new module. This implementation is a bit of a C-centric hack, because the only definitions that can have this property are enums, structs, unions, Objective-C classes, and Objective-C protocols, and all of those are either visible at the top-level or can't be defined later. Hence, we can use the out-of-date-ness of the name and the identifier-update mechanism to force the update. In C++, we will not be so lucky, and will need a more advanced solution, because the definitions could be in namespaces defined in two different modules, e.g., // module 1 namespace N { struct X; } // module 2 namespace N { struct X { /* ... */ }; } One possible implementation here is for C++ to extend the information associated with each identifier table to include the declaration IDs of any definitions associated with that name, regardless of context. We would have to eagerly load those definitions. llvm-svn: 174794
* Fix test failure by making sure this file isn't identical to any other fileNick Lewycky2013-02-081-0/+1
| | | | | | | included in the same test. Clang gets confused about whether it's already built a module for this file, when running on a content-addressible filesystem. llvm-svn: 174694
* Fix conflict between r174685 and r174645 (rename -fmodule-cache-path <foo> ↵Richard Smith2013-02-081-1/+1
| | | | | | to -fmodules-cache-path=<foo>). llvm-svn: 174690
* Fix stack overflow and improve performance when a module contains manyRichard Smith2013-02-083-0/+2017
| | | | | | | | | | | | | overloads of a name by claiming that there are no lookup results for that name in modules while loading the names from the module. Lookups in deserialization really don't want to find names which they themselves are in the process of introducing. This also has the pleasant side-effect of automatically caching PCH lookups which found no names. The runtime here is still quadratic in the number of overloads, but the constant is lower. llvm-svn: 174685
* Teach subframework header lookup to suggest modules <rdar://problem/13176200>.Douglas Gregor2013-02-086-0/+16
| | | | llvm-svn: 174683
* Form the default -fmodules-cache-path= properly.Douglas Gregor2013-02-071-1/+1
| | | | llvm-svn: 174674
* Add missing header from r174648Douglas Gregor2013-02-071-0/+3
| | | | llvm-svn: 174649
* Retain all hidden methods in the global method pool, because they may become ↵Douglas Gregor2013-02-074-0/+14
| | | | | | visible <rdar://problem/13172858>. llvm-svn: 174648
* Rename -fmodule-cache-path <blah> to -fmodules-cache-path=<blah> for ↵Douglas Gregor2013-02-0743-104/+104
| | | | | | consistency. llvm-svn: 174645
* Fix handling of module imports adding names to a DeclContext after qualifiedRichard Smith2013-02-073-6/+33
| | | | | | | | | | | | | | | | name lookup has been performed in that context (this probably only happens in C++). 1) Whenever we add names to a context, set a flag on it, and if we perform lookup and discover that the context has had a lookup table built but has the flag set, update all entries in the lookup table with additional names from the external source. 2) When marking a DeclContext as having external visible decls, mark the context in which lookup is performed, not the one we are adding. These won't be the same if we're adding another copy of a pre-existing namespace. llvm-svn: 174577
* Be a little more permissive with -fmodules-ignore-macro= by removing ↵Douglas Gregor2013-02-071-0/+7
| | | | | | everything after the second '=' if it is there. llvm-svn: 174567
* Introduce -fmodules-ignore-macro=NNN to ignore a macro when building/loading ↵Douglas Gregor2013-02-071-2/+22
| | | | | | | | | | | | | | | | | | | | | modules. The use of this flag enables a modules optimization where a given set of macros can be labeled as "ignored" by the modules system. Definitions of those macros will be completely ignored when building the module hash and will be stripped when actually building modules. The overall effect is that this flag can be used to drastically reduce the number of Eventually, we'll want modules to tell us what set of macros they respond to (the "configuration macros"), and anything not in that set will be excluded. However, that requires a lot of per-module information that must be accurate, whereas this option can be used more readily. Fixes the rest of <rdar://problem/13165109>. llvm-svn: 174560
* Detect when we end up trying to load conflicting module files.Douglas Gregor2013-02-063-0/+34
| | | | | | | | | | | | This can happen when one abuses precompiled headers by passing more -D options when using a precompiled hedaer than when it was built. This is intentionally permitted by precompiled headers (and is exploited by some build environments), but causes problems for modules. First part of <rdar://problem/13165109>, detecting when something when horribly wrong. llvm-svn: 174554
* Merge "special" types from different modules in the AST reader.Douglas Gregor2013-02-013-0/+18
| | | | | | | | | Different modules may have different views of the various "special" types in the AST, such as the redefinition type for "id". Merge those types rather than only considering the redefinition types for the first AST file loaded. llvm-svn: 174234
* Enable the global module index by default. Introduce theDouglas Gregor2013-01-281-3/+3
| | | | | | | | -fno-modules-global-index -cc1 option to allow one to disable the index for performance testing purposes, but with a 10% win in -fsyntax-only time, there is no reason a user would do this. llvm-svn: 173707
* clang/test: Drop "REQUIRES:shell" in three tests. They can run on win32.NAKAMURA Takumi2013-01-251-1/+0
| | | | llvm-svn: 173419
* Implement the reader of the global module index and wire it into theDouglas Gregor2013-01-251-1/+8
| | | | | | | | | | | | | | | | | | | | | | | AST reader. The global module index tracks all of the identifiers known to a set of module files. Lookup of those identifiers looks first in the global module index, which returns the set of module files in which that identifier can be found. The AST reader only needs to look into those module files and any module files not known to the global index (e.g., because they were (re)built after the global index), reducing the number of on-disk hash tables to visit. For an example source I'm looking at, we go from 237844 total identifier lookups into on-disk hash tables down to 126817. Unfortunately, this does not translate into a performance advantage. At best, it's a wash once the global module index has been built, but that's ignore the cost of building the global module index (which is itself fairly large). Profiles show that the global module index code is far less efficient than it should be; optimizing it might give enough of an advantage to justify its continued inclusion. llvm-svn: 173405
* Rename the -cc1 option "-generate-module-index" toDouglas Gregor2013-01-251-1/+7
| | | | | | | "-fmodules-global-index" and expand its behavior to include both the use and generation of the global module index. llvm-svn: 173404
* clang/GlobalModuleIndex: Don't open the same file twice. Use ↵NAKAMURA Takumi2013-01-241-2/+0
| | | | | | | raw_fd_ostream(fd, ...) instead. FIXME: PathV2::unique_file() is assumed to open the file with binary mode on win32. llvm-svn: 173330
* clang/test/Modules/global_index.m: XFAILing on win32 when investigating for now.NAKAMURA Takumi2013-01-241-0/+1
| | | | llvm-svn: 173326
* Implement the writer side of the global module index. Douglas Gregor2013-01-231-0/+8
| | | | | | | | | | | | | | | | | | | | The global module index is a "global" index for all of the module files within a particular subdirectory in the module cache, which keeps track of all of the "interesting" identifiers and selectors known in each of the module files. One can perform a fast lookup in the index to determine which module files will have more information about entities with a particular name/selector. This information can help eliminate redundant lookups into module files (a serious performance problem) and help with creating auto-import/auto-include Fix-Its. The global module index is created or updated at the end of a translation unit that has triggered a (re)build of a module by scraping all of the .pcm files out of the module cache subdirectory, so it catches everything. As with module rebuilds, we use the file system's atomicity to synchronize. llvm-svn: 173301
* [PCH] Temporarily disable the "ambiguous macro" warning that is currently ↵Argyrios Kyrtzidis2013-01-231-0/+1
| | | | | | | | | | | | bogus with a PCH that redefined a macro without undef'ing it first. Proper reconstruction of the macro info history from modules will properly fix this in subsequent commits. rdar://13016031 llvm-svn: 173281
* Add a comment for DanielDouglas Gregor2013-01-171-0/+2
| | | | llvm-svn: 172695
* [IRgen] Update modules autolink metadata to use module flags (as now specifiedDaniel Dunbar2013-01-171-1/+3
| | | | | | in the LangRef). llvm-svn: 172692
* clang/test/Modules/compiler_builtins.m: Mark this as XFAIL:win32 for now. ↵NAKAMURA Takumi2013-01-171-0/+1
| | | | | | Investigating. llvm-svn: 172689
* Treat hidden Objective-C protocol definitions as if they wereDouglas Gregor2013-01-174-1/+44
| | | | | | | undefined, and don't find methods or protocols within those protocol definitions. This completes <rdar://problem/10634711>. llvm-svn: 172686
* Rework the traversal of Objective-C categories and extensions toDouglas Gregor2013-01-165-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | consider (sub)module visibility. The bulk of this change replaces myriad hand-rolled loops over the linked list of Objective-C categories/extensions attached to an interface declaration with loops using one of the four new category iterator kinds: visible_categories_iterator: Iterates over all visible categories and extensions, hiding any that have their "hidden" bit set. This is by far the most commonly used iterator. known_categories_iterator: Iterates over all categories and extensions, ignoring the "hidden" bit. This tends to be used for redeclaration-like traversals. visible_extensions_iterator: Iterates over all visible extensions, hiding any that have their "hidden" bit set. known_extensions_iterator: Iterates over all extensions, whether they are visible to normal name lookup or not. The effect of this change is that any uses of the visible_ iterators will respect module-import visibility. See the new tests for examples. Note that the old accessors for categories and extensions are gone; there are *Raw() forms for some of them, for those (few) areas of the compiler that have to manipulate the linked list of categories directly. This is generally discouraged. Part two of <rdar://problem/10634711>. llvm-svn: 172665
* Teach global selector lookup to ignore hidden methods, which occurDouglas Gregor2013-01-164-0/+32
| | | | | | | when the methods are declared in a submodule that has not yet been imported. Part of <rdar://problem/10634711>. llvm-svn: 172635
* Add -fmodules-autolink/-fno-modules-autolink (defaults to on) so thatDouglas Gregor2013-01-161-1/+1
| | | | | | users can explicitly enable/disable modules autolinking. llvm-svn: 172592
* Topologically sort the link options generated for modules based onDouglas Gregor2013-01-141-3/+8
| | | | | | | module-import dependencies, so we'll get the link order correct for those silly linkers that need it. llvm-svn: 172459
* When forming the link options for an imported module, also include theDouglas Gregor2013-01-142-4/+5
| | | | | | link options for the modules it imports. llvm-svn: 172448
* Switch autolinking metadata format over to actual linker options, e.g.,Douglas Gregor2013-01-141-5/+5
| | | | | | | | | | | | | | | | | | | !0 = metadata !{metadata !"-lautolink"} !1 = metadata !{metadata !"-framework", metadata !"autolink_framework"} referenced from llvm.module.linkoptions, e.g., !llvm.module.linkoptions = !{!0, !1, !2, !3} This conceptually moves the logic for figuring out the syntax the linker will accept from LLVM into Clang. Moreover, it makes it easier to support MSVC's #pragma comment(linker, "some option") in the future, should anyone care to do so. llvm-svn: 172441
* Infer "link" lines for top-level frameworks. Essentially, a frameworkDouglas Gregor2013-01-143-1/+13
| | | | | | | | will have a shared library with the same name as its framework (and no suffix!) within its .framework directory. Detect this both when inferring the whole top-level framework and when parsing a module map. llvm-svn: 172439
* Implement parsing, AST, (de-)serialization, and placeholder globalDouglas Gregor2013-01-145-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | metadata for linking against the libraries/frameworks for imported modules. The module map language is extended with a new "link" directive that specifies what library or framework to link against when a module is imported, e.g., link "clangAST" or link framework "MyFramework" Importing the corresponding module (or any of its submodules) will eventually link against the named library/framework. For now, I've added some placeholder global metadata that encodes the imported libraries/frameworks, so that we can test that this information gets through to the IR. The format of the data is still under discussion. llvm-svn: 172437
* Provide Decl::getOwningModule(), which determines the (sub)module inDouglas Gregor2013-01-121-10/+3
| | | | | | | | | | | | | which a particular declaration resides. Use this information to customize the "definition of 'blah' must be imported from another module" diagnostic with the module the user actually has to import. Additionally, recover by importing that module, so we don't complain about other names in that module. Still TODO: coming up with decent Fix-Its for these cases, and expand this recovery approach for other name lookup failures. llvm-svn: 172290
* When name lookup for a redeclaration finds declarations that are knownDouglas Gregor2013-01-093-0/+44
| | | | | | | | | | (because they are part of some module) but have not been made visible (because they are in a submodule that wasn't imported), filter out those declarations unless both the old declaration and the new declaration have external linkage. When one or both has internal linkage, there should be no conflict unless both are imported. llvm-svn: 171925
* Add the module name to the 'incomplete umbrella header' warning.Douglas Gregor2013-01-041-1/+1
| | | | llvm-svn: 171497
* Remove -Wmodule-build; it was a dumb idea anyway. <rdar://problem/12957525>Douglas Gregor2013-01-041-5/+0
| | | | llvm-svn: 171478
OpenPOWER on IntegriCloud