Commit Graph

424 Commits

Author SHA1 Message Date
Enea Zaffanella e05a3cf648 Improve clarity/consistency of a few UsingDecl methods and related helpers.
No functionality change.

In Sema helper functions:
 * renamed isTypeName as HasTypenameKeyword
In UsingDecl:
 * renamed get/setUsingLocation to get/setUsingLoc
 * renamed is/setTypeName as has/setTypename

llvm-svn: 186816
2013-07-22 10:54:09 +00:00
David Blaikie a8d23ce8ce Serialization support for TagDecl::IsCompleteDefinitionRequired
Requested by Richard Smith in post-commit review of r186262

llvm-svn: 186266
2013-07-14 01:07:41 +00:00
Richard Smith 95d99308c4 C++ modules: Don't call DeclContext::lookup when half-way through deserializing
decls. That can reenter deserialization and explode horribly by trying to merge
a declaration that we've not got very far through deserializing yet.

llvm-svn: 186236
2013-07-13 02:00:19 +00:00
Richard Smith feb3e1a1e3 Lazily deserialize function template specializations. This fixes a cycle in
module deserialization / merging, and more laziness here is general goodness.

llvm-svn: 185132
2013-06-28 04:37:53 +00:00
Richard Smith 68ad0e7154 Lazily deserialize the "first' friend declaration when deserializing a class
declaration. This PCH a little lazier, and breaks a deserialization cycle that
causes crashes with modules enabled.

llvm-svn: 184904
2013-06-26 02:41:25 +00:00
Richard Smith 5de91b58d0 Fix deserializing of class template partial specializations. Assign sequence
numbers as we deserialize class template partial specializations. We can't
assume that the old sequence numbers will work.

The sequence numbers are still deterministic, but are now a lot less
predictable for class template partial specializations in modules/PCH.

llvm-svn: 184811
2013-06-25 01:25:15 +00:00
Richard Smith bf78e646e1 Check for matching template-parameter-lists when merging template declarations.
llvm-svn: 184791
2013-06-24 22:51:00 +00:00
Richard Smith 8f8f05cf00 Slightly improve cross-module merging for function templates.
llvm-svn: 184689
2013-06-24 04:45:28 +00:00
Enea Zaffanella a86d88c7cd Improved source code fidelity for gcc mode attribute.
llvm-svn: 184417
2013-06-20 12:46:19 +00:00
Rafael Espindola 50df3a02be Fix linkage computation for derived types in inline functions.
John noticed that the fix for pr15930 (r181981) didn't handle indirect
uses of local types. For example, a pointer to local struct, or a
function that returns it.

One way to implement this would be to recursively look for local
types. This would look a lot like the linkage computation itself for
types.

To avoid code duplication and utilize the existing linkage cache, this
patch just makes the computation of "type with no linkage but
externally visible because it is from an inline function"  part of the
linkage computation itself.

llvm-svn: 182711
2013-05-25 17:16:20 +00:00
Richard Smith 1d209d075b Fix bitcode desynchronization when loading a PCH containing a class template
specialization with modules enabled. Just don't merge them at all for now;
we'll revisit this when support for template merging is added.

In passing, make Decl::dump() a little safer to use with PCH/modules, by making
it not deserialize any additional declarations. From a debugger you can call
decls_begin() or similar first if you want to dump all child decls.

llvm-svn: 182544
2013-05-23 01:49:11 +00:00
Richard Smith ba71c08523 First pass of semantic analysis for init-captures: check the initializer, build
a FieldDecl from it, and propagate both into the closure type and the
LambdaExpr.

You can't do much useful with them yet -- you can't use them within the body
of the lambda, because we don't have a representation for "the this of the
lambda, not the this of the enclosing context". We also don't have support or a
representation for a nested capture of an init-capture yet, which was intended
to work despite not being allowed by the current standard wording.

llvm-svn: 181985
2013-05-16 06:20:58 +00:00
Alexey Bataev 6f6f3b4baf OpenMP threadprivate with qualified names.
llvm-svn: 181683
2013-05-13 04:18:18 +00:00
Rafael Espindola 3ae00052cd Cleanup handling of UniqueExternalLinkage.
This patch renames getLinkage to getLinkageInternal. Only code that
needs to handle UniqueExternalLinkage specially should call this.

Linkage, as defined in the c++ standard, is provided by
getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage.

Most places in the compiler actually want isExternallyVisible, which
handles UniqueExternalLinkage as internal.

llvm-svn: 181677
2013-05-13 00:12:11 +00:00
Richard Smith 1fa5d64b76 C++1y deduced return types: when we deduce a return type for a function which
we loaded from PCH, if we're building another PCH, create an update record to
patch the return type of the earlier declaration.

llvm-svn: 181659
2013-05-11 05:45:24 +00:00
Enea Zaffanella acb8ecd664 In VarDecl nodes, store the thread storage class specifier as written.
llvm-svn: 181113
2013-05-04 08:27:07 +00:00
Ben Langmuir ce914fc84b Serialization for captured statements
Add serialization for captured statements and captured decls.  Also add
a const_capture_iterator to CapturedStmt.

Test contributed by Wei Pan

Differential Revision: http://llvm-reviews.chandlerc.com/D727

llvm-svn: 181048
2013-05-03 19:20:19 +00:00
Argyrios Kyrtzidis fac3162022 Keep track of an @implementation's super class name location, if one was provided.
llvm-svn: 181039
2013-05-03 18:05:44 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D433

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
John McCall 5e77d76c95 Basic support for Microsoft property declarations and
references thereto.

Patch by Tong Shen!

llvm-svn: 179585
2013-04-16 07:28:30 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
Richard Smith c0fbba7d8a Pare back r164351 somewhat. The problem that change was addressing was that we
don't serialize a lookup map for the translation unit outside C++ mode, so we
can't tell when lookup within the TU needs to look within modules. Only apply
the fix outside C++ mode, and only to the translation unit.

llvm-svn: 178706
2013-04-03 22:49:41 +00:00
Rafael Espindola 6ae7e50be4 Add 178663 back.
http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green
before it processed the reverted 178663, so it could not have been the culprit.

Revert "Revert 178663."

This reverts commit 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41.

llvm-svn: 178682
2013-04-03 19:27:57 +00:00
Rafael Espindola 985a3abee4 Revert 178663.
Looks like it broke http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb

Revert "Don't compute a patched/semantic storage class."

This reverts commit 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05.

llvm-svn: 178681
2013-04-03 19:22:20 +00:00
Rafael Espindola adea16bd9e Don't compute a patched/semantic storage class.
For variables and functions clang used to store two storage classes. The one
"as written" in the code and a patched one, which, for example, propagates
static to the following decls.

This apparently is from the days clang lacked linkage computation. It is now
redundant and this patch removes it.

llvm-svn: 178663
2013-04-03 15:50:00 +00:00
Alexey Bataev a769e07232 OpenMP threadprivate directive parsing and semantic analysis
llvm-svn: 177705
2013-03-22 06:34:35 +00:00
Michael Han 84324357b8 [Sema] Semantic analysis for empty-declaration and attribute-declaration.
Introduce a new AST Decl node "EmptyDecl" to model empty-declaration. Have attributes from attribute-declaration appertain
to the EmptyDecl node by creating the AST representations of these attributes and attach them to the EmptyDecl node so these
attributes can be sema checked just as attributes attached to "normal" declarations.

llvm-svn: 175900
2013-02-22 17:15:32 +00:00
Douglas Gregor 6168bd2323 Ensure that the identifier chains have the most recent declaration after module deserialization.
This commit introduces a set of related changes to ensure that the
declaration that shows up in the identifier chain after deserializing
declarations with a given identifier is, in fact, the most recent
declaration. The primary change involves waiting until after we
deserialize and wire up redeclaration chains before updating the
identifier chains. There is a minor optimization in here to avoid
recursively deserializing names as part of looking to see whether
top-level declarations for a given name exist.

A related change that became suddenly more urgent is to property
record a merged declaration when an entity first declared in the
current translation unit is later deserialized from a module (that had
not been loaded at the time of the original declaration). Since we key
off the canonical declaration (which is parsed, not from an AST file)
for emitted redeclarations, we simply record this as a merged
declaration during AST writing and let the readers merge them.

Re-fixes <rdar://problem/13189985>, presumably for good this time.

llvm-svn: 175447
2013-02-18 15:53:43 +00:00
Argyrios Kyrtzidis 83a6e3bfab [PCH] Deserializing the DeclContext of a template parameter is not safe
until recursive loading is finished.

Otherwise we may end up with a template trying to deserialize a template
parameter that is in the process of getting loaded.

rdar://13135282

llvm-svn: 175329
2013-02-16 00:48:59 +00:00
Richard Smith 8858159fb5 Fix a bug reduced from a crash when trying to use modules with libc++. We check
the linkage of functions and variables while merging declarations from modules,
and we don't necessarily have enough of the rest of the AST loaded at that
point to allow us to compute linkage, so serialize it instead.

llvm-svn: 174943
2013-02-12 05:48:23 +00:00
Richard Smith 645d755d3e Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).

1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.

2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.

llvm-svn: 174577
2013-02-07 03:37:08 +00:00
Enea Zaffanella eb22c870ac Added outer template parameter lists to friend type AST nodes.
llvm-svn: 174050
2013-01-31 09:54:08 +00:00
Fariborz Jahanian 7865220da4 patch for PR9027 and // rdar://11861085
Title: [PR9027] volatile struct bug: member is not loaded at -O;
This is caused by last flag passed to @llvm.memcpy being false, 
not honoring that aggregate has at least one 'volatile' data member 
(even though aggregate itself has not been qualified as 'volatile'. 
As a result, optimization optimizes away the memcpy altogether.
Patch review by John MaCall (I still need to fix up a test though).

llvm-svn: 173535
2013-01-25 23:57:05 +00:00
Douglas Gregor fe732d538f When deserializing a declaration, don't look for redeclarations if its
kind indicates that it can never be redeclared. Good for a 1% speedup,
and redeclaration searching drops off the profile.

llvm-svn: 173054
2013-01-21 16:16:40 +00:00
Chris Lattner 0e6c940d2c update to use the new BitcodeCursor readRecord that takes a StringRef blob parameter,
and adopt "advance" in more places.

llvm-svn: 172951
2013-01-20 02:38:54 +00:00
Douglas Gregor 048fbfa302 Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.

The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:

  visible_categories_iterator: Iterates over all visible categories
  and extensions, hiding any that have their "hidden" bit set. This is
  by far the most commonly used iterator.

  known_categories_iterator: Iterates over all categories and
  extensions, ignoring the "hidden" bit. This tends to be used for
  redeclaration-like traversals.

  visible_extensions_iterator: Iterates over all visible extensions,
  hiding any that have their "hidden" bit set.

  known_extensions_iterator: Iterates over all extensions, whether
  they are visible to normal name lookup or not.

The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.

Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.

Part two of <rdar://problem/10634711>.
 

llvm-svn: 172665
2013-01-16 23:00:23 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
David Blaikie ff7d47a354 Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as per review discussion in r170365
This does limit these typedefs to being sequences, but no current usage
requires them to be contiguous (we could expand this to a more general
iterator pair range concept at some point).

Also, it'd be nice if SmallVector were constructible directly from an ArrayRef
but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the
inverse conversion. (& generalizing over all range-like things, while nice,
would require some nontrivial SFINAE I haven't thought about yet)

llvm-svn: 170482
2012-12-19 00:45:41 +00:00
Richard Smith 6b02d46dae Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
2012-12-08 08:32:28 +00:00
Richard Smith 593f993a68 Implement C++03 [dcl.init]p5's checking for value-initialization of references
properly, rather than faking it up by pretending that a reference member makes
the default constructor non-trivial. That leads to rejects-valids when putting
such types inside unions.

llvm-svn: 169662
2012-12-08 02:01:17 +00:00
Argyrios Kyrtzidis 1eb71a1ba7 Add a bit on FunctionDecl/ObjCMethodDecl to indicate if there was a body
that was skipped by the parser.

llvm-svn: 169531
2012-12-06 18:59:10 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Richard Smith 328aae595c Refactor to reduce duplication in handling of special member functions. No functionality change.
llvm-svn: 168977
2012-11-30 05:11:39 +00:00
Richard Smith 1c33fe8fea Store on the CXXRecordDecl whether the class has, or would have, a copy
constructor/assignment operator with a const-qualified parameter type. The
prior method for determining this incorrectly used overload resolution.

llvm-svn: 168775
2012-11-28 06:23:12 +00:00
Argyrios Kyrtzidis a1c27eb8dd [PCH] Write out the ClassTemplateDecl::Common::InjectedClassNameType type
reference instead of relying on computing it.

In general, if storage is no issue, it is preferable to deserialize info from
the PCH instead of trying to recompute it after the PCH was loaded.

The incentive to change this now was due to r155303 changing how friend template
classes in dependent contexts are handled; such classes can now be chained to
a previous template class but the computed InjectedClassNameType may be different
due to the extra template parameters from the dependent context.

The new handling requires more investigation but, in the meantime, writing out
InjectedClassNameType fixes PCH issue in rdar://12627738.

llvm-svn: 167425
2012-11-06 00:35:02 +00:00
John McCall 0d54a17b52 Set a special flag in class metadata when an Objective-C class
has ivars that require destruction, but none that require anything
except zero-initialization.  This is common in ARC and (when true
throughout a class hierarchy) permits the elimination of an
unnecessary message-send during allocation.

llvm-svn: 166088
2012-10-17 04:53:31 +00:00
Jordan Rose d01e83ab3e Rename ObjCMethodDecl::isSynthesized to isPropertyAccessor.
This more accurately reflects its use: this flag is set when a method
matches the getter or setter name for a property in the same class,
and does not actually specify whether or not the definition of the method
will be synthesized (either implicitly or explicitly with @synthesize).

This renames the setter and backing field as well, and changes the
(soon-to-be-obsolete?) XML dump format to use 'property_accessor'
instead of 'synthesized'.

llvm-svn: 165626
2012-10-10 16:42:25 +00:00
Douglas Gregor a6017bbd52 When we load a function or method body from an AST file, we check
whether that function/method already has a body (loaded from some
other AST file), as introduced in r165137. Delay this check until
after the redeclaration chains have been wired up.

While I'm here, make the loading of method bodies lazy.

llvm-svn: 165513
2012-10-09 17:21:28 +00:00
Axel Naumann c6848efaac Fix r165005: The lexical DeclContext is not the right place to make a decision about whether we need to call tryAddTopLevelDecl or not. That call should be made when the DeclContext's redeclaration context is the translation unit.
llvm-svn: 165215
2012-10-04 07:34:43 +00:00
Douglas Gregor e96037923f Remove ASTReader::needPendingInstantiation(), introduced in r164993,
which is neither correct nor necessary. The use of this routine was
eliminated by r165137.

llvm-svn: 165139
2012-10-03 18:38:43 +00:00
Douglas Gregor e4a838ac3f Add some FIXMEs to the ASTReader code
llvm-svn: 165138
2012-10-03 18:36:10 +00:00
Douglas Gregor 559458c830 Revert most of the functionality in r165001. Instead, make sure that
the ASTReader doesn't attach a body to a function that is already
defined elsewhere.

llvm-svn: 165137
2012-10-03 18:34:48 +00:00
Argyrios Kyrtzidis 7b8e555814 [PCH] Fix serialization of an ImportDecl.
ImportDecl's module ID was not written out and the reader accepted as module ID
the serialized:
  Record.push_back(!IdentifierLocs.empty());

llvm-svn: 165087
2012-10-03 01:58:45 +00:00
Axel Naumann 0439f03bcf Add redecls into their lexical DeclContext: this is what they assert on, and the merging should have set it correctly.
This is especially relevant for templatedDecls that might be injected (and thus have their DeclContext set to) somewhere completely different.

llvm-svn: 165005
2012-10-02 13:06:13 +00:00
Axel Naumann d9a25b3c17 Only those InterestingDecls that got added to the AST should be passed to the ASTConsumer.
llvm-svn: 165001
2012-10-02 12:18:46 +00:00
Axel Naumann 63469422c4 Merge pending instantiations instead of overwriting existing ones.
Check whether a pending instantiation needs to be instantiated (or whether an instantiation already exists).
Verify the size of the PendingInstantiations record (was only checking size of existing PendingInstantiations).

Migrate Obj-C++ part of redecl-merge into separate test, now that this is growing.
templates.mm: test that CodeGen has seen exactly one definition of template instantiations.
redecl-merge.m: use "@" specifier for expected-diagnostics.

llvm-svn: 164993
2012-10-02 09:09:43 +00:00
Axel Naumann 866ba3e365 Also merge template redeclarations.
Don't require specializations (of existing and read template) to be unique.

llvm-svn: 164931
2012-10-01 09:18:00 +00:00
Axel Naumann a31dee2e04 Bring ASTReader and Writer into sync for the case where a canonical template specialization was written, which is non-canonical at the time of reading: force the reading of the ClassTemplateDecl if it was written.
The easiest way out is to store whether the decl was canonical at the time of writing.
Add test.

llvm-svn: 164927
2012-10-01 07:34:47 +00:00
Argyrios Kyrtzidis 6fa1682368 [PCH] After deserializing a DeclContext, if it has external lexical decls but not
external visible decls, call DeclContext::setMustBuildLookupTable so that the
"lazy decls" bit of the LookupPtr is set.

Previously, in non-C++, if there were no new declarations causing the "lazy decls" bit
to be set, then DeclContext::lookups_begin() would fail to return the decls from the PCH.

Fixes rdar://12316296.

llvm-svn: 164351
2012-09-21 01:30:00 +00:00
Douglas Gregor 12cda633be Serialize the 'IsConstexpr' bit of VarDecls. Fixes <rdar://problem/12328814>.
llvm-svn: 164335
2012-09-20 23:43:29 +00:00
Eli Friedman d564afb0ad Add the TypeSourceInfo for the lambda call operator to the lambda's
definition info; it needs to be there because the mangler needs to
access it before we're finished defining the lambda class.
PR12808.

llvm-svn: 164186
2012-09-19 01:18:11 +00:00
Craig Topper 802579dc7f Remove an unused private field exposed by the recent LLVM_DELETED_FUNCTION changes.
llvm-svn: 164106
2012-09-18 05:34:55 +00:00
Dmitri Gribenko a664e5b88f Use LLVM_DELETED_FUNCTION in place of 'DO NOT IMPLEMENT' comments.
llvm-svn: 163983
2012-09-15 20:20:27 +00:00
Argyrios Kyrtzidis e60e408661 [PCH] Add a null check to avoid crashing.
Unfortunately, no test case. rdar://11960120

llvm-svn: 163566
2012-09-10 23:28:22 +00:00
Richard Smith 1fde8ece37 PR9023: A template template parameter whose template parameter list contains an
unexpanded parameter pack is a pack expansion. Thus, as with a non-type template
parameter which is a pack expansion, it needs to be expanded early into a fixed
list of template parameters.

Since the expanded list of template parameters is not itself a parameter pack,
it is permitted to appear before the end of the template parameter list, so also
remove that restriction (for both template template parameter pack expansions and
non-type template parameter pack expansions).

llvm-svn: 163369
2012-09-07 02:06:42 +00:00
Joao Matos e9a3ed4d71 Normalize line endings of r163013 (part 2).
llvm-svn: 163032
2012-08-31 22:18:20 +00:00
Joao Matos dc86f94f62 Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.
llvm-svn: 163013
2012-08-31 18:45:21 +00:00
Benjamin Kramer fc6eb7d383 Reduce duplicated hash map lookups.
llvm-svn: 162361
2012-08-22 15:37:55 +00:00
Eric Christopher f8378ca2b1 Remove HasSynthBitfield and all callers/writers/etc. Also remove
previous ResetObjCLayout calls since this is now handled in Sema.

Part of rdar://11842763

llvm-svn: 160527
2012-07-19 22:22:55 +00:00
Richard Smith ded9c2ee92 Stop instantiating a class if we hit a static_assert failure. Also, if the
static_assert fails when parsing the template, don't diagnose it again on every
instantiation.

llvm-svn: 160088
2012-07-11 22:37:56 +00:00
Argyrios Kyrtzidis 33b4bfcef5 [AST/libclang] Fix the selector locations that are reported for a
method definition that has its '{' attached to the method name without
a space.

With a method like:

-(id)meth{
.....
}

the logic in ObjCMethodDecl that determined the selector locations got
confused because it was initialized based on an end location for '{' but
that end location changed to '}' after the method was finished.

Fix this by having an immutable end location for the declarator and
for getLocEnd() get the end location from the body itself.

Fixes rdar://11659739.

llvm-svn: 158583
2012-06-16 00:46:02 +00:00
Richard Smith 4086a13df8 Remove CXXRecordDecl flags which are unused after r158289.
We need an efficient mechanism to determine whether a defaulted default
constructor is constexpr, in order to determine whether a class is a literal
type, so keep the incrementally-built form on CXXRecordDecl. Remove the
on-demand computation of same, so that we only have one method for determining
whether a default constructor is constexpr. This doesn't affect correctness,
since default constructor lookup is much simpler than selecting a constructor
for copying or moving.

We don't need a corresponding mechanism for defaulted copy or move constructors,
since they can't affect whether a type is a literal type. Conversely, checking
whether such functions are constexpr can require non-trivial effort, so we defer
such checks until the copy or move constructor is required.

Thus we now only compute whether a copy or move constructor is constexpr on
demand, and only compute whether a default constructor is constexpr in advance.
This is unfortunate, but seems like the best solution.

llvm-svn: 158290
2012-06-10 07:07:24 +00:00
Richard Smith 2b013185f8 PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.

llvm-svn: 158288
2012-06-10 03:12:00 +00:00
David Blaikie 7e64fd9d53 Address minor FIXME in RedeclLink to contain a PointerIntPair instead of derive from it.
Use actual factory functions rather than derived classes acting as named constructors/factories.

llvm-svn: 157588
2012-05-28 19:38:42 +00:00
Douglas Gregor c48eafea50 Fix ASTReader handling of ImportDecls, from Meador Inge!
llvm-svn: 156923
2012-05-16 16:31:58 +00:00
Argyrios Kyrtzidis 08f96a9b5e [AST/libclang] Speed up clang_getOverriddenCursors() considerably by reserving a bit
in ObjCMethodDecl to indicate whether the method does not override any other method,
which is the majority of cases.

That way we can avoid unnecessary work doing lookups, especially when PCH is involved.

rdar://11360082

llvm-svn: 156476
2012-05-09 16:12:57 +00:00
Richard Smith e2648bac3a A union can have a constexpr defaulted default constructor, if it has an
in-class initializer for one of its fields. Value-initialization of such
a type should use the in-class initializer!

The former was just a bug, the latter is a (reported) standard defect.

llvm-svn: 156274
2012-05-07 01:07:30 +00:00
Argyrios Kyrtzidis 566e40775b [PCH] Use DenseMap instead of std::map to keep track of SwitchCases.
Part of rdar://11353109.

llvm-svn: 156185
2012-05-04 18:17:30 +00:00
Argyrios Kyrtzidis 0f7d7ab968 [PCH] Really, pinky swear, fix for PR12689
rdar://11353109

llvm-svn: 156145
2012-05-04 01:49:36 +00:00
Argyrios Kyrtzidis 2a5deff59d [PCH] Clear switch case IDs when deserializing a objc method body.
Fixes rdar://11353109 & http://llvm.org/bugs/show_bug.cgi?id=12689

llvm-svn: 156056
2012-05-03 02:26:32 +00:00
Benjamin Kramer 89f0b2d8a2 Use forward declarations for ASTDeclContextNameLookupTable and add a missing delete.
It would be nice to use OwningPtr here, but DeclContextInfo is stored in a DenseMap.

llvm-svn: 154763
2012-04-15 12:36:49 +00:00
John McCall cf6ce28f71 Serialize and deserialize some missing bits from BlockDecl.
llvm-svn: 154676
2012-04-13 17:33:29 +00:00
Richard Smith 4b38ded66a Instantiating a class template should not instantiate the definition of any
scoped enumeration members. Later uses of an enumeration temploid as a nested
name specifier should cause its instantiation. Plus some groundwork for
explicit specialization of member enumerations of class templates.

llvm-svn: 152750
2012-03-14 23:13:10 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Fariborz Jahanian 86c2f5cc70 objective-c: provide fixit hint when atomic property does not
have matching user defined setter/getter and a warning is issued. 
In this case, a fixit note is displayed. // rdar://10267155

llvm-svn: 151766
2012-02-29 22:18:55 +00:00
Richard Smith 561fb15801 Teach CXXRecordDecl::hasIrrelevantDestructor to check the base classes and
data members for deleted or user-provided destructors.

Now it's computed in advance, serialize it, and in passing fix all the other
record DefinitionData flags whose serialization was missing.

llvm-svn: 151441
2012-02-25 07:33:38 +00:00
Douglas Gregor ed90df3800 Generate an AST for the conversion from a lambda closure type to a
block pointer that returns a block literal which captures (by copy)
the lambda closure itself. Some aspects of the block literal are left
unspecified, namely the capture variable (which doesn't actually
exist) and the body (which will be filled in by IRgen because it can't
be written as an AST).

Because we're switching to this model, this patch also eliminates
tracking the copy-initialization expression for the block capture of
the conversion function, since that information is now embedded in the
synthesized block literal. -1 side tables FTW.

llvm-svn: 151131
2012-02-22 05:02:47 +00:00
Douglas Gregor 680e9e018d Improve our handling of lambda expressions that occur within default
arguments. There are two aspects to this:

  - Make sure that when marking the declarations referenced in a
  default argument, we don't try to mark local variables, both because
  it's a waste of time and because the semantics are wrong: we're not
  in a place where we could capture these variables again even if it
  did make sense.
  - When a lambda expression occurs in a default argument of a
  function template, make sure that the corresponding closure type is
  considered dependent, so that it will get properly instantiated. The
  second bit is a bit of a hack; to fix it properly, we may have to
  rearchitect our handling of default arguments, parsing them only
  after creating the function definition. However, I'd like to
  separate that work from the lambdas work.

llvm-svn: 151076
2012-02-21 19:11:17 +00:00
Douglas Gregor 7fcbd902b4 Implement name mangling for lambda expressions that occur within the
default arguments of function parameters. This simple-sounding task is
complicated greatly by two issues:

  (1) Default arguments aren't actually a real context, so we need to
  maintain extra state within lambda expressions to track when a
  lambda was actually in a default argument.
  (2) At the time that we parse a default argument, the FunctionDecl
  doesn't exist yet, so lambda closure types end up in the enclosing
  context. It's not clear that we ever want to change that, so instead
  we introduce the notion of the "effective" context of a declaration
  for the purposes of name mangling.

llvm-svn: 151011
2012-02-21 00:37:24 +00:00
Fariborz Jahanian a7765fea90 modern objc translator. Finish off first cut of the
modern meta-data translation by commenting out private ivar
declarations in user source. Also, added several tests.

llvm-svn: 150985
2012-02-20 20:09:20 +00:00
Douglas Gregor 6379854457 Basic support for name mangling of C++11 lambda expressions. Because
name mangling in the Itanium C++ ABI for lambda expressions is so
dependent on context, we encode the number used to encode each lambda
as part of the lambda closure type, and maintain this value within
Sema.

Note that there are a several pieces still missing:
  - We still get the linkage of lambda expressions wrong
  - We aren't properly numbering or mangling lambda expressions that
  occur in default function arguments or in data member initializers.
  - We aren't (de-)serializing the lambda numbering tables

llvm-svn: 150982
2012-02-20 19:44:39 +00:00
Douglas Gregor d3b672c385 Implicitly define a lambda's conversion functions (to function
pointers and block pointers). We use dummy definitions to keep the
invariant that an implicit, used definition has a body; IR generation
will substitute the actual contents, since they can't be represented
as C++. 

For the block pointer case, compute the copy-initialization needed to
capture the lambda object in the block, which IR generation will need
later.

llvm-svn: 150645
2012-02-16 01:06:16 +00:00
Douglas Gregor 99ae806aff Implement AST (de-)serialization for lambda expressions.
llvm-svn: 150491
2012-02-14 17:54:36 +00:00
Sebastian Redl a935179ab7 Represent C++ direct initializers as ParenListExprs before semantic analysis
instead of having a special-purpose function.

- ActOnCXXDirectInitializer, which was mostly duplication of
  AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days
  ago), is dropped completely.
- MultiInitializer, which was an ugly hack I added, is dropped again.
- We now have the infrastructure in place to distinguish between
  int x = {1};
  int x({1});
  int x{1};
-- VarDecl now has getInitStyle(), which indicates which of the above was used.
-- CXXConstructExpr now has a flag to indicate that it represents list-
   initialization, although this is not yet used.
- InstantiateInitializer was renamed to SubstInitializer and simplified.
- ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which
  always produces a ParenListExpr. Placed that so far failed to convert that
  back to a ParenExpr containing comma operators have been fixed. I'm pretty
  sure I could have made a crashing test case before this.

The end result is a (I hope) considerably cleaner design of initializers.
More importantly, the fact that I can now distinguish between the various
initialization kinds means that I can get the tricky generalized initializer
test cases Johannes Schaub supplied to work. (This is not yet done.)

This commit passed self-host, with the resulting compiler passing the tests. I
hope it doesn't break more complicated code. It's a pretty big change, but one
that I feel is necessary.

llvm-svn: 150318
2012-02-11 23:51:47 +00:00
Argyrios Kyrtzidis 7456ac44b0 [PCH] Add some comments, per Ted's request.
llvm-svn: 150162
2012-02-09 07:46:54 +00:00
Argyrios Kyrtzidis 6c07547b56 [PCH] Set the DeclContext before doing any deserialization, to make sure internal
calls to Decl::getASTContext() by Decl's methods will find the TranslationUnitDecl
without crashing due to a parent declaration context still deserializing.

llvm-svn: 150153
2012-02-09 06:02:44 +00:00
Argyrios Kyrtzidis 6f40eb7e56 [PCH] Avoid using Decl::setAttrs() and Decl::setLexicalDeclContext() from the ASTReaderDecl
directly; they internally call Decl::getASTContext() which may crash if a declaration context
parent is still deserializing.

llvm-svn: 150137
2012-02-09 02:44:08 +00:00
Douglas Gregor 404cddec1b Reimplement (de-)serialization of Objective-C categories to eliminate
the direct serialization of the linked-list structure. Instead, use a
scheme similar to how we handle redeclarations, with redeclaration
lists on the side. This addresses several issues:
  - In cases involving mixing and matching of many categories across
  many modules, the linked-list structure would not be consistent
  across different modules, and categories would get lost.
  - If a module is loaded after the class definition and its other
  categories have already been loaded, we wouldn't see any categories
  in the newly-loaded module.

llvm-svn: 149112
2012-01-27 01:47:08 +00:00
Douglas Gregor 360a66e3d9 Don't separately serialize the list of instance variables in an
Objective-C class. The AST reader just throws away this data anyway!

llvm-svn: 149067
2012-01-26 17:31:14 +00:00
Douglas Gregor 41dc6ff524 When collecting all of the redeclarations of a declaration loaded from
a module file, be sure to also add the first (potentially canonical)
declarations to the chain. This isn't guaranteed to occur because the
first declaration is not listed in the stored redeclaration chain.

llvm-svn: 148314
2012-01-17 18:13:45 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
Douglas Gregor 3a5ae564b8 Now that deserializing a definition of a C++ class/Objective-C
class/Objective-C protocol suffices get all of the redeclarations of
that declaration wired to the definition, we no longer need to record
the identity of the definition in every declaration. Instead, just
record a bit to indicate whether a particular declaration is the
definition.

llvm-svn: 148224
2012-01-15 18:17:48 +00:00
Douglas Gregor c03c52ea01 When deserializing the definition of a C++ class/ObjC class/ObjC
protocol, record the definition pointer in the canonical declaration
for that entity, and then propagate that definition pointer from the
canonical declaration to all other deserialized declarations. This
approach works well even when deserializing declarations that didn't
know about the original definition, which can occur with modules.

A nice bonus from this definition-deserialization approach is that we
no longer need update records when a definition is added, because the
redeclaration chains ensure that the if any declaration is loaded, the
definition will also get loaded.

llvm-svn: 148223
2012-01-15 18:08:05 +00:00
Douglas Gregor 358cd44170 Completely re-implement (de-)serialization of redeclaration
chains, again. The prior implementation was very linked-list oriented, and
the list-splicing logic was both fairly convoluted (when loading from
multiple modules) and failed to preserve a reasonable ordering for the
redeclaration chains.

This new implementation uses a simpler strategy, where we store the
ordered redeclaration chains in an array-like structure (indexed based
on the first declaration), and use that ordering to add individual
deserialized declarations to the end of the existing chain. That way,
the chain mimics the ordering from its modules, and a bug somewhere is
far less likely to result in a broken linked list.

llvm-svn: 148222
2012-01-15 16:58:34 +00:00
Douglas Gregor ec9fd13c77 De-virtualize getPreviousDecl() and getMostRecentDecl() when we know
we have a redeclarable type, and only use the new virtual versions
(getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have
that type information. This keeps us from penalizing users with strict
type information (and is the moral equivalent of a "final" method).

Plus, settle on the names getPreviousDecl() and getMostRecentDecl()
throughout.

llvm-svn: 148187
2012-01-14 16:38:05 +00:00
Douglas Gregor 0bc8a21dba Introduce Decl::getPreviousDecl() and Decl::getMostRecentDecl(),
virtual functions that provide previous/most recent redeclaration
information for any declaration. Use this to eliminate the redundant,
less efficient getPreviousDecl() functions.

llvm-svn: 148184
2012-01-14 15:55:47 +00:00
Douglas Gregor 68444de354 Reimplement RedeclarableTemplateDecl in terms of
Redeclarable<RedeclarableTemplateDecl>, eliminating a bunch of
redeclaration-chain logic both in RedeclarableTemplateDecl and
especially in its (de-)serialization.

As part of this, eliminate the RedeclarableTemplate<> class template,
which was an abstraction that didn't actually save anything.

llvm-svn: 148181
2012-01-14 15:13:49 +00:00
Douglas Gregor 87ea58f5cd (Implicit) parameters deserialized as part of a function type must not
get added to the identifier chains as part of deserialization, because
they should not be visible to name lookup.

llvm-svn: 148159
2012-01-13 23:49:34 +00:00
Douglas Gregor 540fd8135e When deserializing an anonymous namespace from a module, do not attach
the anonymous namespace to its parent. Semantically, this means that
the anonymous namespaces defined in one module are distinct from the
anonymous namespaces defined in another module.

llvm-svn: 147782
2012-01-09 18:07:24 +00:00
Douglas Gregor 9b47f94133 Implement merging of namespace-scope declarations across modules, so
that we can merge, for example, two occurrences of

  namespace N { void f(); }

in two disjoint modules.

llvm-svn: 147780
2012-01-09 17:38:47 +00:00
Douglas Gregor cfe7dc6b2f Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the
merged DeclContexts as well as the (now-primary) DeclContext. This
supports the common case where two different modules put something
into the same namespace.

llvm-svn: 147778
2012-01-09 17:30:44 +00:00
Benjamin Kramer e78f8ee57f Pack UsingDecl more.
88 -> 80 bytes on x86_64.

llvm-svn: 147736
2012-01-07 19:09:05 +00:00
Douglas Gregor e57e752b71 Switch NamespaceDecl from its own hand-rolled redeclaration chain over
to Redeclarable<NamespaceDecl>, so that we benefit from the improveed
redeclaration deserialization and merging logic provided by
Redeclarable<T>. Otherwise, no functionality change.

As a drive-by fix, collapse the "inline" bit into the low bit of the
original namespace/anonymous namespace, saving 8 bytes per
NamespaceDecl on x86_64.

llvm-svn: 147729
2012-01-07 09:11:48 +00:00
Douglas Gregor 5407920f82 During name lookup, use redecl_iterator to walk over the redeclaration
chain to determine whether any declaration of the given entity is
visible, eliminating the redundant (and less efficient)
getPreviousDeclaration() implementation.

This tweak uncovered an omission in the handling of
RedeclarableTemplateDecl, where we weren't making sure to search for
additional redeclarations of a template in other module files. Things
would be cleaner if RedeclarableTemplateDecl actually used Redeclarable.

llvm-svn: 147687
2012-01-06 22:05:37 +00:00
Eli Friedman 48fd89ad14 Revert r147664; it's breaking clang regression tests.
llvm-svn: 147681
2012-01-06 20:42:20 +00:00
Jakub Staszak a78c20d734 Silence GCC warnings.
llvm-svn: 147664
2012-01-06 17:44:30 +00:00
Douglas Gregor 781f713deb Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bits
into the two unused lower bits of the NextDeclInContext link, dropping
the number of bits in Decl down to 32, and saving 8 bytes per
declaration on x86-64.

llvm-svn: 147660
2012-01-06 16:59:53 +00:00
Douglas Gregor 768e5b1e9a Introduce a "Hidden" bit into Decl, to track whether that declaration
is hidden from name lookup. The previous hack of tweaking the
ModulePrivate bit when loading a declaration from a hidden submodule
was brittle.

Note that we now have 34 bits in Decl. I'll fix that next.

llvm-svn: 147658
2012-01-06 16:22:39 +00:00
Douglas Gregor 64af53c364 When we deserialize a declaration from a module file, allocate extra
storage for the global declaration ID. Declarations that are parsed
(rather than deserialized) are unaffected, so the number of
declarations that pay this cost tends to be relatively small (since
relatively few declarations are ever deserialized).

This replaces a largish DenseMap within the AST reader. It's not
strictly a win in terms of memory use---not every declaration was
added to that DenseMap in the first place---but it's cleaner to have
this information available for every deserialized declaration, so that
future clients can rely on it.

llvm-svn: 147617
2012-01-05 22:27:05 +00:00
Douglas Gregor 72172e9009 When creating declarations that are deserialized from an module file,
go through a central allocation routine
Decl::AllocateDeserializedDecl(). No actual functionality change (yet).

llvm-svn: 147614
2012-01-05 21:55:30 +00:00
Douglas Gregor b8c6f1e950 Implement declaration merging for variables in disjoint modules.
llvm-svn: 147535
2012-01-04 17:21:36 +00:00
Douglas Gregor b258569405 Implement declaration merging for non-template functions from
different modules. This implementation is a first approximation of
what we want, using only the function type to determine
equivalence. Later, we'll want to deal with some of the more subtle
issues, including:

  - C allows a prototyped declaration and a non-prototyped declaration
    to be merged, which we should support
  - We may want to ignore the return type when merging, then
    complain if the return types differ. Or, we may want to leave it
    as it us, so that we only complain if overload resolution
    eventually fails.
  - C++ non-static member functions need to consider cv-qualifiers
    and ref-qualifiers.
  - Function templates need to consider the template parameters and
    return type.
  - Function template specializations will have special rules.
  - We can now (accidentally!) end up overloading in C, even without
    the "overloadable" attribute, and will need to detect this at some
    point.
  
The actual detection of "is this an overload?" is implemented by
Sema::IsOverload(), which will need to be moved into the AST library
for re-use here. That will be a future refactor.

llvm-svn: 147534
2012-01-04 17:13:46 +00:00
Douglas Gregor 9b7b39116e Implement declaration merging for typedefs loaded from disjoint
modules, so long as the typedefs refer to the same underlying
type. This ensures that the typedefs end up in the same redeclaration
chain.

To test this, fix name lookup for C/Objective-C to properly deal with
multiple declarations with the same name in the same scope.

llvm-svn: 147533
2012-01-04 16:44:10 +00:00
Douglas Gregor 2009ceed82 Implement cross-module declaration merging for tag declarations, so
that if two modules A and B both contain a declaration of a tag such
as

  struct X;

and those two modules are unrelated, the two declarations of X will be
merged into a single redeclaration chain.

llvm-svn: 147488
2012-01-03 22:46:00 +00:00
Douglas Gregor e097d4ba26 Don't attempt to merge a deserialized declaration with existing
declarations in the AST unless modules are enabled. This case doesn't
come up with precompiled headers, and it isn't cheap.

llvm-svn: 147451
2012-01-03 17:31:38 +00:00
Douglas Gregor 2c46b5bd07 Factor the merging of declarations in the AST reader out to a separate
member function template, since the behavior is identical for
ObjCInterfaceDecl and ObjCProtocolDecl. It's expected that all
redeclarable entities will have the same behavior.

llvm-svn: 147450
2012-01-03 17:27:13 +00:00
Douglas Gregor fe620daefa Eliminate ObjCProtocolDecl's end-of-definition location. It is not
used anywhere.

llvm-svn: 147422
2012-01-02 02:22:52 +00:00
Douglas Gregor 1bd9617671 Move ObjCProtocolDecl::EndLoc into its DefinitionData, and give
ObjCProtocolDecl proper source-range information.

llvm-svn: 147420
2012-01-02 01:18:16 +00:00
Douglas Gregor 05a1f4d60b Eliminate the ForwardDecl/InitiallyForwardDecl bits from ObjCProtocolDecl. They are no longer needed
llvm-svn: 147419
2012-01-01 22:06:18 +00:00
Douglas Gregor da38930cf3 Implement declaration merging for Objective-C protocols across
multiple, disjoint modules. There is far too much duplicating with the
ObjCInterfaceDecl case here, which I'll eliminate shortly.

llvm-svn: 147417
2012-01-01 21:47:52 +00:00
Douglas Gregor f610267581 Eliminate ObjCForwardProtocolDecl, which is redundant now that
ObjCProtocolDecl modules forward declarations properly.

llvm-svn: 147415
2012-01-01 21:23:57 +00:00
Douglas Gregor 32c1757730 Wire up redeclaration chains for Objective-C protocols, so that both
forward declarations and definitions of an Objective-C protocol are
represented within a single chain of ObjCProtocolDecls.

llvm-svn: 147412
2012-01-01 20:30:41 +00:00
Douglas Gregor a715bfff98 Introduce the core infrastructure needed to model redeclaration chains
for Objective-C protocols, including:
  - Using the first declaration as the canonical declaration
  - Using the definition as the primary DeclContext
  - Making sure that all declarations have a pointer to the definition
  data, and that we know which declaration is the definition
  - Serialization support for redeclaration chains and for adding
  definitions to already-serialized declarations.

However, note that we're not taking advantage of much of this code
yet, because we're still re-using ObjCProtocolDecls.

llvm-svn: 147410
2012-01-01 19:51:50 +00:00
Douglas Gregor e6e48b1490 Move the data that corresponds to the definition of a protocol into a
separately-allocated DefinitionData structure. Introduce various
functions that will help with the separation of declarations from
definitions (isThisDeclarationADefinition(), hasDefinition(),
getDefinition()).

llvm-svn: 147408
2012-01-01 19:29:29 +00:00
Douglas Gregor deafd0b2a4 Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDecl
covers both declarations (@class) and definitions (@interface) of an
Objective-C class.

llvm-svn: 147299
2011-12-27 22:43:10 +00:00
Douglas Gregor 852e6b7316 Make a note for an optimization that I'd like to implement, when the ASTs for local externs are sound
llvm-svn: 147185
2011-12-22 22:05:07 +00:00
Douglas Gregor 464b0ca61a Serialize the AST reader's mapping from canonical declarations to the
set of (previously-canonical) declaration IDs to the module file, so
that future AST reader instances that load the module know which
declarations are merged. This is important in the fairly tricky case
where a declaration of an entity, e.g.,

  @class X;

occurs before the import of a module that also declares that
entity. We merge the declarations, and record the fact that the
declaration of X loaded from the module was merged into the (now
canonical) declaration of X that we parsed.

llvm-svn: 147181
2011-12-22 21:40:42 +00:00
Douglas Gregor 0475cd88c9 If we end up merging an Objective-C class with an existing Objective-C
class that comes from a different module file, make sure that we load
all of the pending declarations for the original declaration.

llvm-svn: 147168
2011-12-22 19:44:59 +00:00
Douglas Gregor 022857e03d When deserializing an Objective-C class, check whether we have another
declaration of that same class that either came from some other module
or occurred in the translation unit loading the module. In this case,
we need to merge the two redeclaration chains immediately so that all
such declarations have the same canonical declaration in the resulting
AST (even though they don't in the module files we've imported).

Focusing on Objective-C classes until I'm happy with the design, then
I'll both (1) extend this notion to other kinds of declarations, and
(2) optimize away this extra checking when we're not dealing with
modules. For now, doing this checking for PCH files/preambles gives us
better testing coverage.

llvm-svn: 147123
2011-12-22 01:48:48 +00:00
Douglas Gregor 596b7cbc19 Implement a trivial, obvious optimization for deserialization of
redeclaration chains: only ever have the reader search for
redeclarations of the first (canonical) declaration, since we only
ever record redeclaration ranges for the that declaration. Searching
for redeclarations of non-canonical declarations will never find
anything, so it's a complete waste of time.

llvm-svn: 147055
2011-12-21 15:12:03 +00:00
Douglas Gregor c1a61fe113 Remove ASTReader's PendingForwardRefs, which is now handled by the
(more general) fix-up of definition data pointers.

llvm-svn: 146903
2011-12-19 20:51:16 +00:00
Douglas Gregor e80b31f7f9 Once we have fully deserialized a redeclaration chain for something
with a definition pointer (e.g., C++ and Objective-C classes), zip
through the redeclaration chain to make sure that all of the
declarations point to the definition data. 

As part of this, realized again why the first redeclaration of an
entity in a file is important, and brought back that idea.

llvm-svn: 146886
2011-12-19 19:00:47 +00:00
Douglas Gregor 074a409622 Re-implement (de-)serialization of redeclaration chains for
redeclaration templates (RedeclarableTemplateDecl), similarly to the
way (de-)serialization is implemented for Redeclarable<T>. In the
process, found a simpler formulation for handling redeclaration
chains and implemented that in both places.

The new test establishes that we're building the redeclaration chains
properly. However, the FIXME indicates where we're tickling a
different bug that has to do with us not setting the DefinitionData
pointer properly in redeclarations that we detected after the
definition itself was deserialized. The (separable) fix for that bug
is forthcoming.

llvm-svn: 146883
2011-12-19 18:19:24 +00:00
Douglas Gregor 9f562c8d9e Optimize serialized representation of redeclarable declarations for
which there are no redeclarations. This reduced by size of the PCH
file for Cocoa.h by ~650k: ~536k of that was in the new
LOCAL_REDECLARATIONS table, which went from a ridiculous 540k down to
an acceptable 3.5k, while the rest was due to the more compact
abbreviated representation of redeclarable declaration kinds (which no
longer need to store the 'first' declaration ID).

llvm-svn: 146869
2011-12-19 15:27:36 +00:00
Douglas Gregor 1f179064b0 Combine common (de-)serialization logic for typedefs and type aliases
into operations on TypedefNameDecl. No functionality change.

llvm-svn: 146866
2011-12-19 14:40:25 +00:00
Richard Smith d0b4dd656d constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'
variable is initialized by a non-constant expression, and pass in the variable
being declared so that earlier-initialized fields' values can be used.

Rearrange VarDecl init evaluation to make this possible, and in so doing fix a
long-standing issue in our C++ constant expression handling, where we would
mishandle cases like:

  extern const int a;
  const int n = a;
  const int a = 5;
  int arr[n];

Here, n is not initialized by a constant expression, so can't be used in an ICE,
even though the initialization expression would be an ICE if it appeared later
in the TU. This requires computing whether the initializer is an ICE eagerly,
and saving that information in PCH files.

llvm-svn: 146856
2011-12-19 06:19:21 +00:00
Douglas Gregor 05f10357a9 Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.

The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed). 

As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.

This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.

llvm-svn: 146841
2011-12-17 23:38:30 +00:00
Douglas Gregor ab1ec82e04 Fix chaining of ObjCInterfaceDecl redeclarations
llvm-svn: 146722
2011-12-16 03:12:41 +00:00
Douglas Gregor 16408325af Move ObjCInterfaceDecl's "EndLoc" into DefinitionData, since it only
applies to an actual definition. Plus, clarify the purpose of this
field and give the accessor a different name, since getLocEnd() is
supposed to be the same as getSourceRange().getEnd().

llvm-svn: 146694
2011-12-15 22:34:59 +00:00
Douglas Gregor dc9166c8e1 Keep track of all declarations of an Objective-C class (both forward
declarations and definitions) as ObjCInterfaceDecls within the same
redeclaration chain. This new representation matches what we do for
C/C++ variables/functions/classes/templates/etc., and makes it
possible to answer the query "where are all of the declarations of
this class?"

llvm-svn: 146679
2011-12-15 20:29:51 +00:00