summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* In the ASTReader, factor out the loading of (local) declaration IDs,Douglas Gregor2011-07-211-100/+118
| | | | | | | | | | | | | 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-211-29/+41
| | | | | | | | | | | | | | | 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-201-3/+8
| | | | | | | | 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-191-86/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-151-5/+2
| | | | | | | | | | | 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-151-3/+3
| | | | | | the exception of its uses of SourceManager and SourceLocation APIs. llvm-svn: 135260
* Move the rest of the preprocessor terminology from 'instantiate' andChandler Carruth2011-07-141-5/+5
| | | | | | | | | | | | | 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
* Preserve that a TemplateName was arrived at by substitutingJohn McCall2011-06-301-0/+8
| | | | | | | | | | | 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-281-0/+20
| | | | | | | | | | | | | | | 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
* 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
* Automatic Reference Counting.John McCall2011-06-151-5/+10
| | | | | | | | | | 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-141-0/+2
| | | | | | 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-131-2/+0
| | | | | | reason to allow the user to control these semantics through a flag. llvm-svn: 132919
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [PCH] Store the offsets of source location file entries and go through themArgyrios Kyrtzidis2011-06-021-7/+9
| | | | | | | | | | 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-241-0/+13
| | | | | | | | 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
* Keep track of the file ID corresponding to the original file used toDouglas Gregor2011-05-061-5/+12
| | | | | | | | | | | 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
* 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-051-3/+3
| | | | llvm-svn: 130953
* there i fixed itAlexis Hunt2011-05-041-9/+25
| | | | | | | | | 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-041-9/+22
| | | | llvm-svn: 130822
* Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),Douglas Gregor2011-05-041-1/+2
| | | | | | | | 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
* Re-applies the patch first applied way back in r106099, withChandler Carruth2011-05-011-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | accompanying fixes to make it work today. The core of this patch is to provide a link from a TemplateTypeParmType back to the TemplateTypeParmDecl node which declared it. This in turn provides much more precise information about the type, where it came from, and how it functions for AST consumers. To make the patch work almost a year after its first attempt, it needed serialization support, and it now retains the old getName() interface. Finally, it requires us to not attempt to instantiate the type in an unsupported friend decl -- specifically those coming from template friend decls but which refer to a specific type through a dependent name. A cleaner representation of the last item would be to build FriendTemplateDecl nodes for these, storing their template parameters etc, and to perform proper instantation of them like any other template declaration. They can still be flagged as unsupported for the purpose of access checking, etc. This passed an asserts-enabled bootstrap for me, and the reduced test case mentioned in the original review thread no longer causes issues, likely fixed at somewhere amidst the 24k revisions that have elapsed. llvm-svn: 130628
* Enhance clang_getCXTUResourceUsage() to report the sizes of the memory ↵Ted Kremenek2011-04-281-0/+17
| | | | | | buffers used by PCH. llvm-svn: 130460
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-0/+1
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* Fix a crash when ASTReader emits diagnostic when another one is in flight. ↵Argyrios Kyrtzidis2011-04-251-4/+11
| | | | | | Fixes rdar//9334563. llvm-svn: 130162
* Store the full list of pending instantiations in a chained PCH. Previously ↵Sebastian Redl2011-04-241-11/+11
| | | | | | we attempted to store only new pending instantiations, but our filter was incorrect, dropping implicit instantiations of class template members. It's just not worth coming up with a complex filter that is correct, when the only cost is PCH files that are a few hundred bytes (at most) larger. llvm-svn: 130098
* Teach the AST reader and writer to preserve the __DEPRECATED bit inChandler Carruth2011-04-231-0/+2
| | | | | | | | | | | language options, and warn when reading an AST with a different value for the bit. There doesn't appear to be a good way to test this (commenting out similar other language options doesn't break anything) but if folks have suggestions on tests I'm happy to add them. llvm-svn: 130071
* Teach SourceManager::getSLocEntry() that it can fail due to problemsDouglas Gregor2011-04-201-2/+2
| | | | | | | | during deserialization from a precompiled header, and update all of its callers to note when this problem occurs and recover (more) gracefully. Fixes <rdar://problem/9119249>. llvm-svn: 129839
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-2/+2
| | | | llvm-svn: 129567
* C1X: add a language standardPeter Collingbourne2011-04-151-0/+2
| | | | llvm-svn: 129553
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+5
| | | | | | draft standard (N3291). llvm-svn: 129541
* The ASTReader created by -chain-include used the generated PCH buffers in ↵Sebastian Redl2011-04-141-2/+2
| | | | | | the wrong order. The effect was that all but the first chain-include files was ignored for subsequent compilations. llvm-svn: 129513
* Fix AST serialization of reference-to-reference types. This previously causedRichard Smith2011-04-121-2/+2
| | | | | | | | | a crash when deserializing the AST for this: typedef char (&R); extern R &r; llvm-svn: 129358
* PR8369: make __attribute((regparm(0))) work correctly. Original patch byEli Friedman2011-04-091-5/+6
| | | | | | pageexec@freemail.hu, tweaks by me. llvm-svn: 129206
* Basic, untested implementation for an "unknown any" type requested by LLDB.John McCall2011-04-071-0/+1
| | | | | | | | | | | | The idea is that you can create a VarDecl with an unknown type, or a FunctionDecl with an unknown return type, and it will still be valid to access that object as long as you explicitly cast it at every use. I'm still going back and forth about how I want to test this effectively, but I wanted to go ahead and provide a skeletal implementation for the LLDB folks' benefit and because it also improves some diagnostic goodness for placeholder expressions. llvm-svn: 129065
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-121-9/+12
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* Forgotten part of previous commit.Abramo Bagnara2011-03-121-2/+2
| | | | llvm-svn: 127536
* Introduce '-chain-include' option to specify headers that will be converted ↵Argyrios Kyrtzidis2011-03-091-14/+20
| | | | | | | | | | to chained PCHs in memory without having to use multiple runs and intermediate files. Intended for testing & debugging of chained PCH. llvm-svn: 127339
* When deserializing CXXBaseSpecifiers (and offsets), make sure to walk the ↵Anders Carlsson2011-03-091-8/+10
| | | | | | chain in the correct order. llvm-svn: 127315
* Reinstate r127112, "Propagate new-style exception spec information to ↵Sebastian Redl2011-03-061-2/+4
| | | | | | ExtProtoInfo.", this time with the missing header. llvm-svn: 127118
OpenPOWER on IntegriCloud