summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Re-commit r246497 (and dependent changes r246524 and r246521), reverted inRichard Smith2015-09-011-1/+0
| | | | | | | | | | | | | | | | | | | r246546, with a workaround for an MSVC 2013 miscompile and an MSVC 2015 rejects-valid. Original commit message: [modules] Rework serialized DeclContext lookup table management. Instead of walking the loaded ModuleFiles looking for lookup tables for the context, store them all in one place, and merge them together if we find we have too many (currently, more than 4). If we do merge, include the merged form in our serialized lookup table, so that downstream readers never need to look at our imports' tables. This gives a huge performance improvement to builds with very large numbers of modules (in some cases, more than a 2x speedup was observed). llvm-svn: 246582
* Reverting r246497 (which requires also reverting r246524 and r246521 to ↵Aaron Ballman2015-09-011-0/+1
| | | | | | | | | | | avoid merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 bot with testing issues. llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117): error C2065: 'Files': undeclared identifier http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2917 llvm-svn: 246546
* [modules] Rework serialized DeclContext lookup table management. Instead ofRichard Smith2015-08-311-1/+0
| | | | | | | | | | | | | walking the loaded ModuleFiles looking for lookup tables for the context, store them all in one place, and merge them together if we find we have too many (currently, more than 4). If we do merge, include the merged form in our serialized lookup table, so that downstream readers never need to look at our imports' tables. This gives a huge performance improvement to builds with very large numbers of modules (in some cases, more than a 2x speedup was observed). llvm-svn: 246497
* [MS ABI] Correctly mangle classes without names for linkage purposesDavid Majnemer2015-08-311-5/+0
| | | | | | | | | | | | | | | | 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
* Don't call a member function on a null pointer.Richard Smith2015-08-271-2/+5
| | | | llvm-svn: 246215
* [modules] Further simplification and speedup of redeclaration chain loading.Richard Smith2015-08-221-10/+25
| | | | | | | | 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] Rearrange how redeclaration chains are loaded, to remove a walk overRichard Smith2015-08-221-36/+95
| | | | | | | | | | | | | | | | | | | | | | | | | 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] Don't eagerly deserialize so many ImportDecls. CodeGen basically ↵Richard Smith2015-08-191-6/+11
| | | | | | ignores ImportDecls imported from modules, so only eagerly deserialize the ones from a PCH / preamble. llvm-svn: 245406
* [modules] Improve performance when there is a local declaration of an entityRichard Smith2015-07-121-68/+34
| | | | | | | | 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
* [modules] Fix crash when writing an update record for a redeclaration of an ↵Richard Smith2015-07-081-4/+6
| | | | | | empty namespace. llvm-svn: 241732
* 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-0/+26
| | | | | | | | | | | | | | | | | | | | 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
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | 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
* Extend type nullability qualifiers for Objective-C.Douglas Gregor2015-06-191-1/+2
| | | | | | | | | | | | | | | 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
* push_back() loop -> append() for random access iterators.Benjamin Kramer2015-06-121-2/+1
| | | | | | | append will resize the vector to the optimal size. No functional change intended. llvm-svn: 239607
* [modules] Reconstruct template default argument inheritance on reload ratherRichard Smith2015-06-101-12/+13
| | | | | | than wasting storage and triggering eager deserializations by serializing it. llvm-svn: 239454
* Refactor storage of default template arguments.Richard Smith2015-06-101-7/+13
| | | | | | | This is just a preparatory step towards fixing visibility for default template arguments in modules builds. llvm-svn: 239447
* [AST] Put VarDeclBitfields on a dietDavid Majnemer2015-05-191-14/+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] Work around PR23030 again, in a different code path, whereChandler Carruth2015-03-271-6/+9
| | | | | | | | | | I again added the "reasonable" assertions and they again fired during a modules self-host. This hopefully will un-break the self-host build bot. No test case handy and adding one seems to have little or no value really. llvm-svn: 233426
* [Modules] When walking the lookup results in a namespace, sort them byChandler Carruth2015-03-271-9/+23
| | | | | | | | | | | | declaration name so that we mark declarations for emission in a deterministic order (and in turn give them deterministic IDs). This is the last for loop or data structure I can find by inspection of the AST writer which doesn't use a deterministic order. Found by inspection, no test case. llvm-svn: 233348
* [Modules] Delete a bunch of complex code for ensuring visible decls inChandler Carruth2015-03-261-2/+2
| | | | | | | | | | | | | | updated decl contexts get emitted. Since this code was added, we have newer vastly simpler code for handling this. The code I'm removing was very expensive and also generated unstable order of declarations which made module outputs non-deterministic. All of the tests continue to pass for me and I'm able to check the difference between the .pcm files after merging modules together. llvm-svn: 233251
* [modules] Deserialize CXXCtorInitializer list for a constructor lazily.Richard Smith2015-03-241-14/+15
| | | | | | | | | | | | | 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] Don't clobber a destructor's operator delete when adding another one;Richard Smith2015-03-101-1/+1
| | | | | | | move the operator delete updating into a separate update record so we can cope with updating another module's destructor's operator delete. llvm-svn: 231735
* [modules] Rework merging of redeclaration chains on module import.Richard Smith2015-03-051-14/+31
| | | | | | | | | | | | | | | | | | | | | | We used to save out and eagerly load a (potentially huge) table of merged formerly-canonical declarations when we loaded each module. This was extremely inefficient in the presence of large amounts of merging, and didn't actually save any merging lookup work, because we still needed to perform name lookup to check that our merged declaration lists were complete. This also resulted in a loss of laziness -- even if we only needed an early declaration of an entity, we would eagerly pull in all declarations that had been merged into it regardless. We now store the relevant fragments of the table within the declarations themselves. In detail: * The first declaration of each entity within a module stores a list of first declarations from imported modules that are merged into it. * Loading that declaration pre-loads those other entities, so that they appear earlier within the redeclaration chain. * The name lookup tables list the most recent local lookup result, if there is one, or all directly-imported lookup results if not. llvm-svn: 231424
* [modules] When writing out a list of specializations for a template, if we haveRichard Smith2015-02-271-51/+58
| | | | | | | | undeserialized specializations (because we merged an imported declaration of the same template since we last added one), don't bother reading in the specializations themselves just so we can write out their IDs again. llvm-svn: 230805
* [modules] Treat friend declarations that are lexically within a dependentRichard Smith2015-02-071-2/+11
| | | | | | | context as anonymous for merging purposes. They can't be found by their names, so we merge them based on their position within the surrounding context. llvm-svn: 228485
* PR22405: don't lose implicit-deleted-ness across AST write / read.Richard Smith2015-02-061-14/+14
| | | | llvm-svn: 228464
* [modules] If a module declares an entity and then imports another declarationRichard Smith2015-02-061-8/+26
| | | | | | | | | of that entity, ensure that the redeclaration chain is reordered properly on reload. Otherwise, the result of name lookup for that entity may point to an entity that is too old; if that's an injected friend name or the like, that can result in the name not being found at all. llvm-svn: 228371
* Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFCAlexey Bataev2015-01-121-2/+2
| | | | llvm-svn: 225624
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-1/+2
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
* Change how we distinguish bitfield widths, in-classJohn McCall2014-10-101-9/+8
| | | | | | | | initializers, and captured VLA types so that we can answer questions like "is this a bit-field" without looking at the enclosing DeclContext. NFC. llvm-svn: 219522
* [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixesRichard Smith2014-09-031-0/+1
| | | | | | | merging of namespace aliases across modules and improves source fidelity. Incidentally also fixes PR20816. llvm-svn: 217103
* Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper2014-08-301-2/+2
| | | | | | and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. llvm-svn: 216824
* [modules] Fix deserialization cycle when loading a tag declaration with a ↵Richard Smith2014-08-301-10/+19
| | | | | | typedef name for linkage purposes. When loading the type, delay loading its typedef until we've finished loading and merging the type. In its place, save out the name of the typedef, which we need for merging purposes. llvm-svn: 216806
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-3/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* [modules] Number anonymous declarations that are lexically within mergeableRichard Smith2014-08-281-0/+6
| | | | | | contexts, so that we can merge them when we merge the surrounding context. llvm-svn: 216639
* [modules] Add an assert that we properly manage the IsCompleteDefinition flagRichard Smith2014-08-271-1/+2
| | | | | | | | on CXXRecordDecls when merging definitions, and make it pass by not trying to save and restore this flag across AST serialization/deserialization. For CXXRecordDecls, we have a separate mechanism to manage this. llvm-svn: 216633
* [modules] Track the described template in an alias declaration that is theRichard Smith2014-08-261-0/+1
| | | | | | | pattern of an alias template declaration. Use this to merge alias templates properly when they're members of class template specializations. llvm-svn: 216437
* [modules] Add abbreviation for ImplicitCastExpr. This is the most commonRichard Smith2014-07-271-0/+18
| | | | | | record type in LLVM's IR module. llvm-svn: 214048
* [modules] Improve abbreviations for C++:Richard Smith2014-07-261-8/+72
| | | | | | | | | | | | | | | | | * Add abbreviation for CXXMethodDecl and for FunctionProtoType. These come up a *lot* in C++ modules. * Allow typedef declarations to use the abbreviation if they're class members, or if they're used. In passing, add more record name records for Clang AST node kinds. The downside is that we had already used up our allotment of 12 abbreviations, so this pushes us to an extra bit on each record to support the extra abbrev kinds, which increases file size by ~1%. This patch *barely* pays for that through the other improvements, but we've got room for another 18 abbrevs, so we should be able to make it much more profitable with future changes. llvm-svn: 214024
* [PCH] Remove the BackingIvarReferencedInAccessor field from DECL_OBJC_IVAR ↵Argyrios Kyrtzidis2014-06-211-2/+0
| | | | | | | | abbreviation record. Patch by Yiding Jia! llvm-svn: 211438
* Recompute the injected class name type for a class template specializationRichard Smith2014-05-231-2/+0
| | | | | | rather than saving and restoring it. llvm-svn: 209557
* [C++11] Use 'nullptr'. Serialization edition.Craig Topper2014-05-221-11/+11
| | | | llvm-svn: 209392
* [OPENMP] Initial codegen for '#pragma omp parallel'Alexey Bataev2014-05-061-2/+4
| | | | llvm-svn: 208077
* When a module completes the definition of a class template specialization ↵Richard Smith2014-04-191-3/+4
| | | | | | imported from another module, emit an update record, rather than using the broken decl rewriting mechanism. If multiple modules do this, merge the definitions together, much as we would if they were separate declarations. llvm-svn: 206680
* Fix PR18307: Properly (de)serialize inherited constructors and their using ↵Stephan Tolksdorf2014-03-271-0/+1
| | | | | | | | declarations Reviewed in http://llvm-reviews.chandlerc.com/D3102 llvm-svn: 204951
* If a name is injected into an imported inline namespace without reopening thatRichard Smith2014-03-231-3/+8
| | | | | | | namespace, we need to update both the visible names of that namespace and of its enclosing namespace set. llvm-svn: 204570
OpenPOWER on IntegriCloud