summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules/Inputs
Commit message (Collapse)AuthorAgeFilesLines
...
* C++ modules: fix a bug where loading a declaration with some name would preventRichard Smith2013-09-092-0/+12
| | | | | | | | | | | | | | | | | name lookup from lazily deserializing the other declarations with the same name, by tracking a bit to indicate whether a name in a DeclContext might have additional external results. This also allows lazier reconciling of the lookup table if a module import adds decls to a pre-existing DC. However, this exposes a pre-existing bug, which causes a regression in test/Modules/decldef.mm: if we have a reference to a declaration, and a later-imported module adds a redeclaration, nothing causes us to load that redeclaration when we use or emit the reference (which can manifest as a reference to an undefined inline function, a use of an incomplete type, and so on). decldef.mm has been extended with an additional testcase which fails with or without this change. llvm-svn: 190293
* Note when a decl is used in AST files.Eli Friedman2013-09-052-1/+3
| | | | | | | | | | | | | | | When an AST file is built based on another AST file, it can use a decl from the fist file, and therefore mark the "isUsed" bit. We need to note this in the AST file so that the bit is set correctly when the second AST file is loaded. This patch introduces the distinction between setIsUsed() and markUsed() so that we don't call into the ASTMutationListener callback when it wouldn't be appropriate. Fixes PR16635. llvm-svn: 190016
* Map from local decl IDs to global decl IDs when lazily deserializing friend ↵Richard Smith2013-08-303-0/+12
| | | | | | decl chains. llvm-svn: 189629
* When merging redeclaration chains across modules, if a declaration is visibleRichard Smith2013-08-022-0/+8
| | | | | | | | | | | | | | | | | | | in one module but is only declared as a friend in another module, keep it visible in the result of the merge. This is incomplete on two axes: 1) Our handling of local extern declarations is basically broken (we put them in the wrong decl context, and don't find them in redeclaration lookup, unless they've previously been declared), and this results in them making friends visible after a merge. 2) Eventually we'll need to mark that this has happened, and more carefully check whether a declaration should be visible if it was only visible in some of the modules in which it was declared. Fortunately it's rare for the identifier namespace of a declaration to change along its redeclaration chain. llvm-svn: 187639
* Fix assert when instantiating a default argument of a template defined in aRichard Smith2013-08-011-0/+2
| | | | | | module. llvm-svn: 187556
* When we perform dependent name lookup during template instantiation, it's notRichard Smith2013-07-255-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sufficient to only consider names visible at the point of instantiation, because that may not include names that were visible when the template was defined. More generally, if the instantiation backtrace goes through a module M, then every declaration visible within M should be available to the instantiation. Any of those declarations might be part of the interface that M intended to export to a template that it instantiates. The fix here has two parts: 1) If we find a non-visible declaration during name lookup during template instantiation, check whether the declaration was visible from the defining module of all entities on the active template instantiation stack. The defining module is not the owning module in all cases: we look at the module in which a template was defined, not the module in which it was first instantiated. 2) Perform pending instantiations at the end of a module, not at the end of the translation unit. This is general goodness, since it significantly cuts down the amount of redundant work that is performed in every TU importing a module, and also implicitly adds the module containing the point of instantiation to the set of modules checked for declarations in a lookup within a template instantiation. There's a known issue here with template instantiations performed while building a module, if additional imports are added later on. I'll fix that in a subsequent commit. llvm-svn: 187167
* If an unimported submodule of an imported module contains a declaration of aRichard Smith2013-07-143-0/+10
| | | | | | | global allocation or deallocation function, that should not cause that global allocation or deallocation function to become unavailable. llvm-svn: 186270
* Fix deserializing of class template partial specializations. Assign sequenceRichard Smith2013-06-254-0/+17
| | | | | | | | | | numbers as we deserialize class template partial specializations. We can't assume that the old sequence numbers will work. The sequence numbers are still deterministic, but are now a lot less predictable for class template partial specializations in modules/PCH. llvm-svn: 184811
* Check for matching template-parameter-lists when merging template declarations.Richard Smith2013-06-242-0/+8
| | | | llvm-svn: 184791
* Slightly improve cross-module merging for function templates.Richard Smith2013-06-243-0/+20
| | | | llvm-svn: 184689
* [Modules] If a module map resides in a system header directory, treat it as ↵Douglas Gregor2013-06-212-0/+5
| | | | | | | | | a system module. This prevents -pedantic from causing warnings in the system headers used to create modules. Fixes <rdar://problem/14201171>. llvm-svn: 184560
* Add test header missing from r184504.Douglas Gregor2013-06-211-0/+3
| | | | llvm-svn: 184505
* When building a module, keep *all* declared methods in the global method pool.Douglas Gregor2013-06-212-0/+5
| | | | | | | | | | | | | | | | | As an optimization, we only kept declared methods with distinct signatures in the global method pool, to keep the method lists small. Under modules, however, one could have two different methods with the same signature that occur in different (sub)modules. If only the later submodule is important, message sends to 'id' with that selector would fail because the first method (the only one that got into the method pool) was hidden. When building a module, keep *all* of the declared methods. I did a quick check of both module build time and uses of modules, and found no performance regression despite this causing us to keep more methods in the global method pool. Fixes <rdar://problem/14148896>. llvm-svn: 184504
* Test files for private header patch.Lawrence Crowl2013-06-2013-0/+101
| | | | llvm-svn: 184472
* Add -Wincomplete-module, which detects when a header is included from a ↵Douglas Gregor2013-05-203-0/+7
| | | | | | module but isn't itself part of a module. llvm-svn: 182263
* When building a module, forward diagnostics to the outer diagnostic consumer.Douglas Gregor2013-05-033-0/+12
| | | | | | | | | | | | | | | Previously, we would clone the current diagnostic consumer to produce a new diagnostic consumer to use when building a module. The problem here is that we end up losing diagnostics for important diagnostic consumers, such as serialized diagnostics (where we'd end up with two diagnostic consumers writing the same output file). With forwarding, the diagnostics from all of the different modules being built get forwarded to the one serialized-diagnostic consumer and are emitted in a sane way. Fixes <rdar://problem/13663996>. llvm-svn: 181067
* When looking for the module associated with one of our magical builtin ↵Douglas Gregor2013-05-023-0/+15
| | | | | | | | | | | | | | | headers, speculatively load module maps. The "magical" builtin headers are the headers we provide as part of the C standard library, which typically comes from /usr/include. We essentially merge our headers into that location (due to cyclic dependencies). This change makes sure that, when header search finds one of our builtin headers, we figure out which module it actually lives in. This case is fairly rare; one ends up having to include one of the few built-in C headers we provide before including anything from /usr/include to trigger it. Fixes <rdar://problem/13787184>. llvm-svn: 180934
* Add a module testcase with a using declaration.Rafael Espindola2013-04-052-0/+4
| | | | | | Thanks a lot to Richard Smith for the suggestion. llvm-svn: 178825
* Add hasExternalLinkageUncached back with the test that Richard provided, butRafael Espindola2013-04-043-0/+11
| | | | | | keep the call at the current location. llvm-svn: 178741
* <rdar://problem/13560075> Teach name lookup for builtin names to find hidden ↵Douglas Gregor2013-04-033-0/+14
| | | | | | | | | | | | | | declarations. Normal name lookup ignores any hidden declarations. When name lookup for builtin declarations fails, we just synthesize a new declaration at the point of use. With modules, this could lead to multiple declarations of the same builtin, if one came from a (hidden) submodule that was later made visible. Teach name lookup to always find builtin names, so we don't create these redundant declarations in the first place. llvm-svn: 178711
* [preprocessor] Allow comparing two macro definitions syntactically instead ↵Argyrios Kyrtzidis2013-04-032-0/+4
| | | | | | | | | | | | | | of only lexically. Syntactically means the function macro parameter names do not need to use the same identifiers in order for the definitions to be considered identical. Syntactic equivalence is a microsoft extension for macro redefinitions and we'll also use this kind of comparison to check for ambiguous macros coming from modules. rdar://13562254 llvm-svn: 178671
* [modules] If a submodule has re-definitions of the same macro, only the last ↵Argyrios Kyrtzidis2013-04-031-2/+2
| | | | | | | | definition will be used as the "exported" one. Fixes rdar://13562262 llvm-svn: 178622
* [modules] Make sure enabled diagnostic pragmas inside the module don't ↵Argyrios Kyrtzidis2013-03-272-0/+7
| | | | | | | | | | | | affect the translation unit that imports the module. Getting diagnostic sections from modules properly working is a fixme. rdar://13516663 llvm-svn: 178151
* <rdar://problem/13479214> Make Clang's <stddef.h> robust against system ↵Douglas Gregor2013-03-223-0/+17
| | | | | | | | | | | | | | 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/13037793> Allow the names of modules to differ from the name ↵Douglas Gregor2013-03-214-3/+8
| | | | | | of their subdirectory in the include path. llvm-svn: 177621
* <rdar://problem/12368093> Extend module maps with a 'conflict' declaration, ↵Douglas Gregor2013-03-203-0/+12
| | | | | | 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-202-0/+12
| | | | | | | | | | | | | | | | | | | | | | 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-192-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-183-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 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-122-0/+8
| | | | | | 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-122-0/+15
| | | | | | | | 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-122-0/+15
| | | | | | | | | 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-114-0/+21
| | | | | | | | | | | | | | | | | | | | 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-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 stack overflow and improve performance when a module contains manyRichard Smith2013-02-082-0/+2008
| | | | | | | | | | | | | 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-085-0/+9
| | | | llvm-svn: 174683
* 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-073-0/+6
| | | | | | visible <rdar://problem/13172858>. llvm-svn: 174648
* Fix handling of module imports adding names to a DeclContext after qualifiedRichard Smith2013-02-072-0/+14
| | | | | | | | | | | | | | | | 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
* Detect when we end up trying to load conflicting module files.Douglas Gregor2013-02-062-0/+12
| | | | | | | | | | | | 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-012-0/+5
| | | | | | | | | 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
* Treat hidden Objective-C protocol definitions as if they wereDouglas Gregor2013-01-173-0/+18
| | | | | | | 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-164-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-163-0/+14
| | | | | | | when the methods are declared in a submodule that has not yet been imported. Part of <rdar://problem/10634711>. llvm-svn: 172635
* When forming the link options for an imported module, also include theDouglas Gregor2013-01-141-0/+0
| | | | | | link options for the modules it imports. llvm-svn: 172448
* Infer "link" lines for top-level frameworks. Essentially, a frameworkDouglas Gregor2013-01-142-0/+0
| | | | | | | | 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-144-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* When name lookup for a redeclaration finds declarations that are knownDouglas Gregor2013-01-092-0/+17
| | | | | | | | | | (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
OpenPOWER on IntegriCloud