summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename ASTReader::PerFileData to serialization::Module, pulling it outDouglas Gregor2011-07-225-82/+83
| | | | | | | of ASTReader so it can become its own full-fledged class (eventually). No functionality change. llvm-svn: 135767
* Introduce a global bit-offset continuous range map into the ASTReader,Douglas Gregor2011-07-223-90/+36
| | | | | | | | | | | | | | | | | so that we have one, simple way to map from global bit offsets to local bit offsets. Eliminates a number of loops over the chain, and generalizes for more interesting bit remappings. Also, as an amusing oddity, we were computing global bit offsets *backwards* for preprocessed entities (e.g., the directly included PCH file in the chain would start at offset zero, rather than the original PCH that occurs first in translation unit). Even more amusingly, it made precompiled preambles work, because we were forgetting to adjust the local bit offset to a global bit offset when storing preprocessed entity offsets in the ASTUnit. Two wrongs made a right, and now they're both right. llvm-svn: 135750
* Fix an embarrassing bug in relocatable PCH support, where we wereDouglas Gregor2011-07-221-1/+10
| | | | | | | passing a temporary const char* down as the "isysroot" parameter and then accessing it later. Fixes <rdar://problem/9035180>. llvm-svn: 135749
* In the AST reader, factor out the mapping of local type IDs to globalDouglas Gregor2011-07-223-79/+90
| | | | | | | | type IDs into a single place, and make sure that all of the callers use the appropriate functions to do the mapping. Since the mapping is still the identity function, this is essentially a no-op. llvm-svn: 135733
* Clean up the rest of the local -> global declaration ID mappingsDouglas Gregor2011-07-212-12/+8
| | | | | | within the ASTReader (I hope). llvm-svn: 135720
* In the ASTReader, factor out the loading of (local) declaration IDs,Douglas Gregor2011-07-213-273/+292
| | | | | | | | | | | | | such that every declaration ID loaded from an AST file will go through a central local -> global mapping function. At present, this change does nothing, since the local -> global mapping function is the identity function. This is the mechanical part of the refactoring; a follow-up patch will address a few remaining areas where it's not obvious whether we're dealing with local or global IDs. llvm-svn: 135711
* Cleaning up more of the ID situation in the AST reader. This patch relaxes ↵Jonathan D. Turner2011-07-211-24/+25
| | | | | | and generalizes how CXX base specifiers are identified and loaded by using a ContinuousRangeMap. This also adds a global bit offset (or base) to the PerFileData. llvm-svn: 135705
* Add some debugging output to the AST reader, so we can see the global ↵Douglas Gregor2011-07-211-0/+54
| | | | | | remappings we generate llvm-svn: 135701
* In the AST reader, keep track of the total number of source locationsDouglas Gregor2011-07-211-13/+10
| | | | | | | entries incrementally, rather than iterating over the chain when loading a single AST file. llvm-svn: 135692
* Rework the detailed preprocessing record to separate preprocessingDouglas Gregor2011-07-212-30/+42
| | | | | | | | | | | | | | | entities generated directly by the preprocessor from those loaded from the external source (e.g., the ASTReader). By separating these two sets of entities into different vectors, we allow both to grow independently, and eliminate the need for preallocating all of the loaded preprocessing entities. This is similar to the way the recent SourceManager refactoring treats FileIDs and the source location address space. As part of this, switch over to building a continuous range map to track preprocessing entities. llvm-svn: 135646
* Continuing to improve and generalize how IDs are handled in ASTReader. This ↵Jonathan D. Turner2011-07-201-12/+12
| | | | | | patch cleans up and generalizes TypeID loading and uses a similar table-lookup to Doug's previous Decl patch. llvm-svn: 135622
* Use a ContinuousRangeMap to map from the global macro definition ID inDouglas Gregor2011-07-201-16/+19
| | | | | | | | | | | the AST reader down to the AST file + local ID, rather than walking the PCH chain. More cleanup/generalization, although there is more work to do for preprocessed entities. In particular, the "preallocation" scheme for preprocessed entities is not going to work well with late loading of PCH files, and it's likely we'll have to do something akin to the SourceManager's negative/positive loading. llvm-svn: 135556
* Use a ContinuousRangeMap to map from the global selector ID in the ASTDouglas Gregor2011-07-201-17/+18
| | | | | | | reader down to the AST file + local ID, rather than walking the PCH chain. No functionality change; this is generalization and cleanup. llvm-svn: 135554
* Use a ContinuousRangeMap to map from the global identifier ID in theDouglas Gregor2011-07-201-19/+17
| | | | | | | AST reader down to the AST file + local ID, rather than walking the PCH chain. No functionality change; this is generalization and cleanup. llvm-svn: 135551
* Use a ContinuousRangeMap to map from the global declaration ID in theDouglas Gregor2011-07-202-13/+13
| | | | | | | | AST reader down to the AST file + local ID within that file, rather than lamely walking the PCH chain. There's no actual functionality change now, but this is cleaner and more general. llvm-svn: 135548
* Revamp the SourceManager to separate the representation of parsedDouglas Gregor2011-07-192-136/+240
| | | | | | | | | | | | | | | | | | | | | | | | | | | source locations from source locations loaded from an AST/PCH file. Previously, loading an AST/PCH file involved carefully pre-allocating space at the beginning of the source manager for the source locations and FileIDs that correspond to the prefix, and then appending the source locations/FileIDs used for parsing the remaining translation unit. This design forced us into loading PCH files early, as a prefix, whic has become a rather significant limitation. This patch splits the SourceManager space into two parts: for source location "addresses", the lower values (growing upward) are used to describe parsed code, while upper values (growing downward) are used for source locations loaded from AST/PCH files. Similarly, positive FileIDs are used to describe parsed code while negative FileIDs are used to file/macro locations loaded from AST/PCH files. As a result, we can load PCH/AST files even during parsing, making various improvemnts in the future possible, e.g., teaching #include <foo.h> to look for and load <foo.h.gch> if it happens to be already available. This patch was originally written by Sebastian Redl, then brought forward to the modern age by Jonathan Turner, and finally polished/finished by me to be committed. llvm-svn: 135484
* Augment the interface of ExternalASTSource::FindExternalLexicalDecls()Douglas Gregor2011-07-152-6/+4
| | | | | | | | | | | to allow clients to specify that they've already (correctly) loaded declarations, and that no further action is needed. Also, make sure that we clear the "has external lexical declarations" bit before calling FindExternalLexicalDecls(), to avoid infinite recursion. llvm-svn: 135306
* Move the Serialization library from 'instantiation' to 'expansion', withChandler Carruth2011-07-152-14/+14
| | | | | | the exception of its uses of SourceManager and SourceLocation APIs. llvm-svn: 135260
* Add serialization support for SubstNonTypeTemplateParmExpr.John McCall2011-07-152-285/+135
| | | | | | | | | | Also add the missing serialization support for SEHTryStmt, SEHFinallyStmt, and SEHExceptStmt, and fix and finish the serialization support for AsTypeExpr. In addition, change the code so that it will no longer link if a Stmt subclass is missing serialization support. llvm-svn: 135258
* StringMap::first() is about to start returning a StringRef, adapt.Chris Lattner2011-07-141-2/+2
| | | | llvm-svn: 135166
* Move the rest of the preprocessor terminology from 'instantiate' andChandler Carruth2011-07-142-10/+10
| | | | | | | | | | | | | variants to 'expand'. This changed a couple of public APIs, including one public type "MacroInstantiation" which is now "MacroExpansion". The rest of the codebase was updated to reflect this, especially the libclang code. Two of the C++ (and thus easily changed) libclang APIs were updated as well because they pertained directly to the old MacroInstantiation class. No functionality changed. llvm-svn: 135139
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-062-2/+4
| | | | | | | | | | | | throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. llvm-svn: 134548
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-013-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | type/expression/template argument/etc. is instantiation-dependent if it somehow involves a template parameter, even if it doesn't meet the requirements for the more common kinds of dependence (dependent type, type-dependent expression, value-dependent expression). When we see an instantiation-dependent type, we know we always need to perform substitution into that instantiation-dependent type. This keeps us from short-circuiting evaluation in places where we shouldn't, and lets us properly implement C++0x [temp.type]p2. In theory, this would also allow us to properly mangle instantiation-dependent-but-not-dependent decltype types per the Itanium C++ ABI, but we aren't quite there because we still mangle based on the canonical type in cases like, e.g., template<unsigned> struct A { }; template<typename T> void f(A<sizeof(sizeof(decltype(T() + T())))>) { } template void f<int>(A<sizeof(sizeof(int))>); and therefore get the wrong answer. llvm-svn: 134225
* Preserve that a TemplateName was arrived at by substitutingJohn McCall2011-06-302-0/+16
| | | | | | | | | | | for a template template parameter. Uses to follow. I've also made the uniquing of SubstTemplateTemplateParmPacks use a ContextualFoldingSet as a minor space efficiency. llvm-svn: 134137
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-282-0/+36
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-212-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Make more use of llvm::StringRef in various APIs. In particular, don'tJay Foad2011-06-211-5/+6
| | | | | | use the deprecated forms of llvm::StringMap::GetOrCreateValue(). llvm-svn: 133515
* Objective-C fast enumeration loop variables are not retained in ARC, butJohn McCall2011-06-172-1/+7
| | | | | | | | | | | | they should still be officially __strong for the purposes of errors, block capture, etc. Make a new bit on variables, isARCPseudoStrong(), and set this for 'self' and these enumeration-loop variables. Change the code that was looking for the old patterns to look for this bit, and change IR generation to find this bit and treat the resulting variable as __unsafe_unretained for the purposes of init/destroy in the two places it can come up. llvm-svn: 133243
* Automatic Reference Counting.John McCall2011-06-154-6/+72
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Introduce a -cc1-level option to turn off related result typeDouglas Gregor2011-06-142-0/+3
| | | | | | inference, to be used (only) by the Objective-C rewriter. llvm-svn: 133025
* Eliminate the -f[no]objc-infer-related-result-type flags; there's noDouglas Gregor2011-06-132-3/+0
| | | | | | reason to allow the user to control these semantics through a flag. llvm-svn: 132919
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-112-3/+9
| | | | llvm-svn: 132878
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-114-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* Touchup to comments that weren't quite in sync with codeJonathan D. Turner2011-06-061-2/+3
| | | | llvm-svn: 132679
* Add support for builtin astype:Tanya Lattner2011-06-042-1/+16
| | | | | | | __builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types. Added test case. llvm-svn: 132612
* Improvements to abbreviations for PCH which add support for EnumDecl, ↵Jonathan D. Turner2011-06-033-35/+258
| | | | | | ObjCIvarDecl, TypedefDecl, VarDecl and FieldDecl and improve support for ParmVarDecl. llvm-svn: 132604
* Test of commit access. Jonathan D. Turner2011-06-031-1/+1
| | | | llvm-svn: 132596
* Introduce additional abbreviations into the AST writer forDouglas Gregor2011-06-033-13/+184
| | | | | | | DeclRefExprs, IntegerLiterals, and others, reducing Cocoa PCH size by ~1% and C++ header size by ~2.5%. From Jonathan Turner! llvm-svn: 132528
* [PCH] Store the offsets of source location file entries and go through themArgyrios Kyrtzidis2011-06-022-9/+27
| | | | | | | | | | in ASTReader::validateFileEntries(). This avoids going through all source location entries and fixes the performance regression. Many thanks to Doug for the hint! (rdar://9530587) llvm-svn: 132481
* [PCH] Be conservative and check all the files the PCH references to see ifArgyrios Kyrtzidis2011-06-011-0/+97
| | | | | | | | a file was modified since the time the PCH was created. The parser is not fit to deal with stale PCHs, too many invariants do not hold up. rdar://9530587. llvm-svn: 132389
* Implement a new type node, UnaryTransformType, designed to represent aAlexis Hunt2011-05-242-0/+26
| | | | | | | | type that turns one type into another. This is used as the basis to implement __underlying_type properly - with TypeSourceInfo and proper behavior in the face of templates. llvm-svn: 132017
* When determining whether we can make a declaration into a globalDouglas Gregor2011-05-132-0/+2
| | | | | | | constant, also consider whether it's a class type that has any mutable fields. If so, it can't be a global constant. llvm-svn: 131276
* Implement defaulting of destructors.Alexis Hunt2011-05-122-0/+4
| | | | llvm-svn: 131260
* Implement implicit deletion of default constructors.Alexis Hunt2011-05-112-2/+2
| | | | | | | | Yes, I'm aware that the diagnostics are awful. Tests to follow. llvm-svn: 131203
* Clean up trivial default constructors now.Alexis Hunt2011-05-092-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | hasTrivialDefaultConstructor() really really means it now. Also implement a fun standards bug regarding aggregates. Doug, if you'd like, I can un-implement that bug if you think it is truly a defect. The bug is that non-special-member constructors are never considered user-provided, so the following is an aggregate: struct foo { foo(int); }; It's kind of bad, but the solution isn't obvious - should struct foo { foo (int) = delete; }; be an aggregate or not? Lastly, add a missing initialization to FunctionDecl. llvm-svn: 131101
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-092-2/+2
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Keep track of the file ID corresponding to the original file used toDouglas Gregor2011-05-062-6/+18
| | | | | | | | | | | build a precompiled header. Use this information to eliminate the call to SourceManager::getLocation() while loading a precompiled preamble, since SourceManager::getLocation() itself causes unwanted deserialization. Fixed <rdar://problem/9399352>. llvm-svn: 131021
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-062-4/+4
| | | | | | | | | | | | | | | | | | | | - New isDefined() function checks for deletedness - isThisDeclarationADefinition checks for deletedness - New doesThisDeclarationHaveABody() does what isThisDeclarationADefinition() used to do - The IsDeleted bit is not propagated across redeclarations - isDeleted() now checks the canoncial declaration - New isDeletedAsWritten() does what it says on the tin. - isUserProvided() now correct (thanks Richard!) This fixes the bug that we weren't catching void foo() = delete; void foo() {} as being a redefinition. llvm-svn: 131013
* Introduce a new libclang parsing flag,Douglas Gregor2011-05-061-2/+2
| | | | | | | | | | | | | CXTranslationUnit_NestedMacroInstantiations, which indicates whether we want to see "nested" macro instantiations (e.g., those that occur inside other macro instantiations) within the detailed preprocessing record. Many clients (e.g., those that only care about visible tokens) don't care about this information, and in code that uses preprocessor metaprogramming, this information can have a very high cost. Addresses <rdar://problem/9389320>. llvm-svn: 130990
* Implement support for C++0x alias templates.Richard Smith2011-05-054-4/+19
| | | | llvm-svn: 130953
OpenPOWER on IntegriCloud