summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
* 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
* there i fixed itAlexis Hunt2011-05-042-9/+46
| | | | | | | | | Increase robustness of the delegating constructor cycle detection mechanism. No more infinite loops on invalid or logic errors leading to false results. Ensure that this is maintained correctly accross serialization. llvm-svn: 130887
* Implement serialization of delegating constructors.Alexis Hunt2011-05-042-15/+31
| | | | llvm-svn: 130822
* Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),Douglas Gregor2011-05-042-2/+4
| | | | | | | | which determines whether a particular file is actually a header that is intended to be guarded from multiple inclusions within the same translation unit. llvm-svn: 130808
* Revise the representation of parameter scope data so that theJohn McCall2011-05-022-3/+14
| | | | | | | scope depth overlaps with the ObjCDeclQualifier, dropping memory usage back to previous levels. llvm-svn: 130671
* Add an optional field attached to a DeclRefExpr which points back to theChandler Carruth2011-05-012-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decl actually found via name lookup & overload resolution when that Decl is different from the ValueDecl which is actually referenced by the expression. This can be used by AST consumers to correctly attribute references to the spelling location of a using declaration, and otherwise gain insight into the name resolution performed by Clang. The public interface to DRE is kept as narrow as possible: we provide a getFoundDecl() which always returns a NamedDecl, either the ValueDecl referenced or the new, more precise NamedDecl if present. This way AST clients can code against getFoundDecl without know when exactly the AST has a split representation. For an example of the data this provides consider: % cat x.cc namespace N1 { struct S {}; void f(const S&); } void test(N1::S s) { f(s); using N1::f; f(s); } % ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc [...] void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1> (CallExpr 0x5b01df0 <line:6:3, col:6> 'void' (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)')) (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))) (DeclStmt 0x5b01ee0 <line:7:3, col:14> 0x5b01e40 "UsingN1::;") (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void' (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f'))) (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))) Now we can tell that the second call is 'using' (no pun intended) the using declaration, and *which* using declaration it sees. Without this, we can mistake calls that go through using declarations for ADL calls, and have no way to attribute names looked up with using declarations to the appropriate UsingDecl. llvm-svn: 130670
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-012-0/+6
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Remove the NameQualifier struct, which was just a wrapper aroundChandler Carruth2011-05-011-1/+1
| | | | | | | | | NestedNameSpecifierLoc. It predates when we had such an object. Reference the NNSLoc directly in DREs, and embed it directly into the MemberNameQualifier struct. llvm-svn: 130668
* Several cosmetic changes, no functionality changed.Chandler Carruth2011-05-011-1/+1
| | | | | | | | | | Mostly trailing whitespace so that me editor nuking it doesn't muddy the waters of subsequent commits that do change functionality. Also nukes a stray statement that was harmless but redundant that I introduced in r130666. llvm-svn: 130667
* Move the state bits in DeclRefExpr out of the pointer union and intoChandler Carruth2011-05-011-9/+5
| | | | | | | | | | | | | | | a bitfield in the base class. DREs weren't using any bits here past the normal Expr bits, so we have plenty of room. This makes the common case of getting a Decl out of a DRE no longer need to do any masking etc. Also, while here, clean up code to use the accessor methods rather than directly poking these bits, and provide a nice comment for DREs that includes the information previously attached to the bits going into the pointer union. No functionality changed here, but DREs should be a tad faster now. llvm-svn: 130666
OpenPOWER on IntegriCloud