summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [MS ABI] Correctly mangle classes without names for linkage purposesDavid Majnemer2015-08-311-6/+3
| | | | | | | | | | | | | | | | A class without a name for linkage purposes gets a name along the lines of <unnamed-type-foo> where foo is either the name of a declarator which defined it (like a variable or field) or a typedef-name (like a typedef or alias-declaration). We handled the declarator case correctly but it would fall down during template instantiation if the declarator didn't share the tag's type. We failed to handle the typedef-name case at all. Instead, keep track of the association between the two and keep it up to date in the face of template instantiation. llvm-svn: 246469
* [modules] Further simplification and speedup of redeclaration chain loading.Richard Smith2015-08-221-34/+35
| | | | | | | | Instead of eagerly deserializing a list of DeclIDs when we load a module file and doing a binary search to find the redeclarations of a decl, store a list of redeclarations of each chain before the first declaration and load it directly. llvm-svn: 245789
* [modules] Remove some dead code after r245779.Richard Smith2015-08-221-168/+35
| | | | llvm-svn: 245780
* [modules] Rearrange how redeclaration chains are loaded, to remove a walk overRichard Smith2015-08-221-40/+37
| | | | | | | | | | | | | | | | | | | | | | | | | all modules and reduce the number of declarations we load when loading a redeclaration chain. The new approach is: * when loading the first declaration of an entity within a module file, we first load all declarations of the entity that were imported into that module file, and then load all the other declarations of that entity from that module file and build a suitable decl chain from them * when loading any other declaration of an entity, we first load the first declaration from the same module file As before, we complete redecl chains through name lookup where necessary. To make this work, I also had to change the way that template specializations are stored -- it no longer suffices to track only canonical specializations; we now emit all "first local" declarations when emitting a list of specializations for a template. On one testcase with several thousand imported module files, this reduces the total runtime by 72%. llvm-svn: 245779
* [modules] When loading a template specialization, re-canonicalize its templateRichard Smith2015-08-091-4/+7
| | | | | | | | arguments because the reloaded form might have become non-canonical across the serialization/deserialization step (this particularly happens when the canonical form of the type involves an expression). llvm-svn: 244409
* [modules] Remove now-unused MergedLookups map.Richard Smith2015-08-061-20/+0
| | | | llvm-svn: 244277
* [modules] Defer setting up the lookup table for a DeclContext until we canRichard Smith2015-08-061-39/+33
| | | | | | | | | | | | | | | | determine the primary context, rather than sometimes registering the lookup table on the wrong context. This exposed a couple of bugs: * the odr violation check didn't deal properly with mergeable declarations if the declaration retained by name lookup wasn't in the canonical definition of the class * the (broken) RewriteDecl mechanism would emit two name lookup tables for the same DeclContext into the same module file (one as part of the rewritten declaration and one as a visible update for the old declaration) These are both fixed too. llvm-svn: 244192
* [AST] ArrayRefize BlockDecl::setCaptures. No functionality change intended.Benjamin Kramer2015-08-051-2/+1
| | | | llvm-svn: 244027
* [modules] Make IndirectFieldDecl mergeable to avoid lookup ambiguity when ↵Richard Smith2015-08-041-0/+9
| | | | | | the same anonymous union is defined across multiple modules. llvm-svn: 243940
* [modules] Add an assert for redeclarations that we never added to their redeclRichard Smith2015-07-271-17/+30
| | | | | | | | | | | | | | | chain and fix the cases where it fires. * Handle the __va_list_tag as a predefined decl. Previously we failed to merge sometimes it because it's not visible to name lookup. (In passing, remove redundant __va_list_tag typedefs that we were creating for some ABIs. These didn't affect the mangling or representation of the type.) * For Decls derived from Redeclarable that are not in fact redeclarable (implicit params, function params, ObjC type parameters), remove them from the list of expected redeclarable decls. llvm-svn: 243259
* [Modules] Wrap the main ModuleManager visitor in a function_ref.Benjamin Kramer2015-07-251-12/+5
| | | | | | | Avoids the awkward passing of an opaque void *UserData argument. No functional change intended. llvm-svn: 243213
* [modules] Switch to the normal reverse postorder visitation algorithm when ↵Richard Smith2015-07-151-75/+80
| | | | | | computing redeclaration chains. llvm-svn: 242253
* Minor simplification, no functionality change.Richard Smith2015-07-121-14/+1
| | | | llvm-svn: 242001
* [modules] Improve performance when there is a local declaration of an entityRichard Smith2015-07-121-17/+27
| | | | | | | | before the first imported declaration. We don't need to track all formerly-canonical declarations of an entity; it's sufficient to track those ones for which no other formerly-canonical declaration was imported into the same module. We call those ones "key declarations", and use them as our starting points for collecting redeclarations and performing namespace lookups. llvm-svn: 241999
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-0/+2
| | | | | | | | | | | | | | | Introduce co- and contra-variance for Objective-C type parameters, which allows us to express that (for example) an NSArray is covariant in its type parameter. This means that NSArray<NSMutableString *> * is a subtype of NSArray<NSString *> *, which is expected of the immutable Foundation collections. Type parameters can be annotated with __covariant or __contravariant to make them co- or contra-variant, respectively. This feature can be detected by __has_feature(objc_generics_variance). Implements rdar://problem/20217490. llvm-svn: 241549
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). llvm-svn: 241543
* Handle Objective-C type arguments.Douglas Gregor2015-07-071-2/+1
| | | | | | | | | | | | | | | | | | | | | Objective-C type arguments can be provided in angle brackets following an Objective-C interface type. Syntactically, this is the same position as one would provide protocol qualifiers (e.g., id<NSCopying>), so parse both together and let Sema sort out the ambiguous cases. This applies both when parsing types and when parsing the superclass of an Objective-C class, which can now be a specialized type (e.g., NSMutableArray<T> inherits from NSArray<T>). Check Objective-C type arguments against the type parameters of the corresponding class. Verify the length of the type argument list and that each type argument satisfies the corresponding bound. Specializations of parameterized Objective-C classes are represented in the type system as distinct types. Both specialized types (e.g., NSArray<NSString *> *) and unspecialized types (NSArray *) are represented, separately. llvm-svn: 241542
* Parsing, semantic analysis, and AST for Objective-C type parameters.Douglas Gregor2015-07-071-1/+36
| | | | | | | | | | | | | | | | | | | | Produce type parameter declarations for Objective-C type parameters, and attach lists of type parameters to Objective-C classes, categories, forward declarations, and extensions as appropriate. Perform semantic analysis of type bounds for type parameters, both in isolation and across classes/categories/extensions to ensure consistency. Also handle (de-)serialization of Objective-C type parameter lists, along with sundry other things one must do to add a new declaration to Clang. Note that Objective-C type parameters are typedef name declarations, like typedefs and C++11 type aliases, in support of type erasure. Part of rdar://problem/6294649. llvm-svn: 241541
* [modules] Merging support for specializations of a function template. This veryRichard Smith2015-07-011-5/+5
| | | | | | | rarely matters, but can affect whether two dependent types are canonically equivalent. llvm-svn: 241207
* [modules] Remove some out-of-date (fixed) FIXMEs.Richard Smith2015-07-011-9/+0
| | | | llvm-svn: 241205
* [ObjC] Add NSValue support for objc_boxed_expressionsAlex Denisov2015-06-261-1/+9
| | | | | | | | | | | | | Patch extends ObjCBoxedExpr to accept records (structs and unions): typedef struct __attribute__((objc_boxable)) _Color { int r, g, b; } Color; Color color; NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)]; llvm-svn: 240761
* [modules] Properly merge visibility of class definitions that got merged whileRichard Smith2015-06-251-5/+7
| | | | | | parsing then merged again when the module was loaded. llvm-svn: 240700
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-5/+5
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-5/+5
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* [modules] When determining whether a definition of a class is visible, check ↵Richard Smith2015-06-201-0/+3
| | | | | | all modules even if we've already found a definition that's not visible. llvm-svn: 240204
* [modules] Refactor and slightly simplify class definition merging.Richard Smith2015-06-201-48/+26
| | | | llvm-svn: 240200
* Extend type nullability qualifiers for Objective-C.Douglas Gregor2015-06-191-1/+3
| | | | | | | | | | | | | | | Introduce context-sensitive, non-underscored nullability specifiers (nonnull, nullable, null_unspecified) for Objective-C method return types, method parameter types, and properties. Introduce Objective-C-specific semantics, including computation of the nullability of the result of a message send, merging of nullability information from the @interface of a class into its @implementation, etc . This is the Objective-C part of rdar://problem/18868820. llvm-svn: 240154
* [modules] Merging support for enums with a local definition prior to the firstRichard Smith2015-06-181-43/+54
| | | | | | imported definition. llvm-svn: 240068
* [modules] Ensure that if we merge the definitions of two enumerations, thatRichard Smith2015-06-171-17/+23
| | | | | | making either of them visible makes the merged definition visible. llvm-svn: 239969
* [modules] Fix typo in default argument merging.Richard Smith2015-06-171-3/+3
| | | | llvm-svn: 239954
* [modules] Track all default template arguments for a given parameter acrossRichard Smith2015-06-101-2/+1
| | | | | | | modules, and allow use of a default template argument if any of the parameters providing it is visible. llvm-svn: 239485
* [modules] Reconstruct template default argument inheritance on reload ratherRichard Smith2015-06-101-17/+44
| | | | | | than wasting storage and triggering eager deserializations by serializing it. llvm-svn: 239454
* Refactor storage of default template arguments.Richard Smith2015-06-101-11/+24
| | | | | | | This is just a preparatory step towards fixing visibility for default template arguments in modules builds. llvm-svn: 239447
* Allow skipping imports in the module visitor.Manuel Klimek2015-05-201-8/+39
| | | | | | | Skip imports when we know that we do not need to visit any imports because we've already deserialized the redecls from a module. llvm-svn: 237782
* [AST] Put VarDeclBitfields on a dietDavid Majnemer2015-05-191-7/+9
| | | | | | | | VarDeclBitfields contained bits which are never present in parameters. Split these out so that ParmVarDeclBitfields wouldn't grow past 32-bits if another field was added. llvm-svn: 237648
* [modules] Add local submodule visibility support for declarations.Richard Smith2015-05-151-15/+30
| | | | | | | | | | | | With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-4/+4
| | | | | | | | | | | | | | 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
* Revert file unintentionally changed in r235162.Daniel Jasper2015-04-171-1/+1
| | | | llvm-svn: 235163
* clang-format: Add default fallback style.Daniel Jasper2015-04-171-1/+1
| | | | | | Thanks to Michael Schlottke. llvm-svn: 235162
* [modules] When merging class definitions, make the retained definition visibleRichard Smith2015-03-271-11/+23
| | | | | | | | if the merged definition is visible, and perform lookups into all merged copies of the definition (not just for special members) so that we can complete the redecl chains for members of the class. llvm-svn: 233420
* [modules] Handle defining a tag with a typedef name for linkage purposes on ↵Richard Smith2015-03-271-6/+5
| | | | | | top of an existing imported-but-not-visible definition. llvm-svn: 233345
* [Modules] Fix tiny bug where we failed to get the canonical decl whenChandler Carruth2015-03-261-1/+1
| | | | | | | | | | | | | | | deserializing an inherited constructor. This is the exact same logic we use when deserializing method overrides for the same reason: the canonical decl may end up pinned to a different decl when we are improting modules, we need to re-pin to the canonical one during reading. My test case for this will come in a subsequent commit. I was trying to test a more tricky bug fix and the test case happened to tickle this bug as well. llvm-svn: 233325
* [modules] If we reach a definition of a class for which we already have aRichard Smith2015-03-261-0/+14
| | | | | | | | non-visible definition, skip the new definition and make the old one visible instead of trying to parse it again and failing horribly. C++'s ODR allows us to assume that the two definitions are identical. llvm-svn: 233250
* Keep track of canonical decls in Redeclarable.Manuel Klimek2015-03-251-0/+4
| | | | | | | | More than 2x speedup on modules builds with large redecl chains. Roughly 15-20% speedup on non-modules builds for very large TUs. Between 2-3% cost in memory on large TUs. llvm-svn: 233228
* [modules] Deserialize CXXCtorInitializer list for a constructor lazily.Richard Smith2015-03-241-8/+18
| | | | | | | | | | | | | Previously we'd deserialize the list of mem-initializers for a constructor when we deserialized the declaration of the constructor. That could trigger a significant amount of unnecessary work (pulling in all base classes recursively, for a start) and was causing problems for the modules buildbot due to cyclic deserializations. We now deserialize these on demand. This creates a certain amount of duplication with the handling of CXXBaseSpecifiers; I'll look into reducing that next. llvm-svn: 233052
* [modules] Remove redundant import of lexical decls when building a lookup tableRichard Smith2015-03-231-39/+38
| | | | | | | | | | | | | | | for a DeclContext, and fix propagation of exception specifications along redeclaration chains. This reverts r232905, r232907, and r232907, which reverted r232793, r232853, and r232853. One additional change is present here to resolve issues with LLDB: distinguish between whether lexical decls missing from the lookup table are local or are provided by the external AST source, and still look in the external source if that's where they came from. llvm-svn: 232928
* Reverting 232853 and 232870 because they depend on 232793,Vince Harron2015-03-221-38/+39
| | | | | | which was reverted because it was causing LLDB test failures llvm-svn: 232907
* [modules] When either redecl chain merging or an update record causes us toRichard Smith2015-03-211-36/+31
| | | | | | | | | give an exception specification to a declaration that didn't have an exception specification in any of our imported modules, emit an update record ourselves. Without this, code importing the current module would not see an exception specification that we could see and might have relied on. llvm-svn: 232870
* [modules] Remove temporary IdentifierInfo lookup results when we're done ↵Richard Smith2015-03-201-3/+7
| | | | | | with them. llvm-svn: 232853
* [modules] Fix bug where an anonymous namespace could cause the containingRichard Smith2015-03-171-9/+18
| | | | | | | | | | | | | | | | namespace to not merge properly. We have an invariant here: after a declaration reads its canonical declaration, it can assume the canonical declaration is fully merged. This invariant can be violated if deserializing some declaration triggers the deserialization of a later declaration, because that later declaration can in turn deserialize a redeclaration of that first declaration before it is fully merged. The anonymous namespace for a namespace gets stored with the first declaration of that namespace, which may be before its parent namespace, so defer loading it until after we've finished merging the surrounding namespace. llvm-svn: 232455
OpenPOWER on IntegriCloud