Граф коммитов

664 Коммитов

Автор SHA1 Сообщение Дата
Sean Hunt 0486d74601 Add Parser support for C++0x literal operators ('operator "" i').
DeclarationName can't handle them yet, so right now Parser just errors out on them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28 04:44:28 +00:00
Anders Carlsson d5a942b911 When adding an implicit destructor, make sure to mark it as virtual if it overrides existing destructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89967 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-26 21:25:09 +00:00
Fariborz Jahanian 6a587cbd69 Better diagnostic on deleted constructor when no
initializer name is available.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25 21:53:11 +00:00
Douglas Gregor 5b6d70e2de Diagnose ill-formed uses of default template arguments in
function templates (in C++98), friend function templates, and
out-of-line definitions of members of class templates.

Also handles merging of default template arguments from previous
declarations of function templates, for C++0x. However, we don't yet
make use of those default template arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89872 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25 17:50:39 +00:00
Douglas Gregor 99e9b4d172 Eliminate CXXConditionDeclExpr with extreme prejudice.
All statements that involve conditions can now hold on to a separate
condition declaration (a VarDecl), and will use a DeclRefExpr
referring to that VarDecl for the condition expression. ForStmts now
have such a VarDecl (I'd missed those in previous commits).

Also, since this change reworks the Action interface for
if/while/switch/for, use FullExprArg for the full expressions in those
expressions, to ensure that we're emitting

Note that we are (still) not generating the right cleanups for
condition variables in for statements. That will be a follow-on
commit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89817 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25 00:27:52 +00:00
Sebastian Redl d1a7846699 Have the parser tell sema whether a member declaration is a function definition. This allows sema to not emit spurious diagnostics in some invalid code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89816 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-24 23:38:44 +00:00
Fariborz Jahanian 2fe168fc89 Refactor argument collection of constructor calls using
the common routine.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89802 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-24 21:37:28 +00:00
Sebastian Redl eb0d8c95b4 Let using directives refer to namespace aliases. Fixes PR5479.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89657 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-23 15:34:23 +00:00
Douglas Gregor 7edfb69ae1 Do not mark declarations as used when performing overload resolution. Fixes PR5541
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89652 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-23 12:27:39 +00:00
John McCall d5532b6cff Encapsulate "an array of TemplateArgumentLocs and two angle bracket locations" into
a new class.  Use it pervasively throughout Sema.

My fingers hurt.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-23 01:53:49 +00:00
John McCall ba13543329 "Incremental" progress on using expressions, by which I mean totally ripping
into pretty much everything about overload resolution in order to wean
BuildDeclarationNameExpr off LookupResult::getAsSingleDecl().  Replace  
UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the
idea of a non-member lookup that we haven't totally resolved yet, whether by
overloading, argument-dependent lookup, or (eventually) the presence of   
a function template in the lookup results.  

Incidentally fixes a problem with argument-dependent lookup where we were 
still performing ADL even when the lookup results contained something from
a block scope.  

Incidentally improves a diagnostic when using an ObjC ivar from a class method.
This just fell out from rewriting BuildDeclarationNameExpr's interaction with
lookup, and I'm too apathetic to break it out.

The only remaining uses of OverloadedFunctionDecl that I know of are in
TemplateName and MemberExpr.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89544 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-21 08:51:07 +00:00
Sean Hunt bbd37c62e3 Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute
lists (and in GNU ones as well):
 - align() - semantics believed to be conformant to n3000, except for
   redeclarations and what entities it may apply to
 - final - semantics believed to be conformant to CWG issue 817's proposed
   wording, except for redeclarations
 - noreturn - semantics believed to be conformant to n3000, except for
   redeclarations
 - carries_dependency - currently ignored (this is an optimization hint)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89543 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-21 08:43:09 +00:00
John McCall 6826314938 Overhaul previous-declaration and overload checking to work on lookup results
rather than NamedDecl*.  This is a major step towards eliminating
OverloadedFunctionDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89263 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 22:49:29 +00:00
John McCall 7d384dd5ac Split LookupResult into its own header.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 07:57:50 +00:00
John McCall 7ba107a186 Incremental progress on using declarations. Split UnresolvedUsingDecl into
two classes, one for typenames and one for values;  this seems to have some
support from Doug if not necessarily from the extremely-vague-on-this-point
standard.  Track the location of the 'typename' keyword in a using-typename
decl.  Make a new lookup result for unresolved values and deal with it in
most places.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18 02:36:19 +00:00
Douglas Gregor 6490ae5003 Silence some warnings produced by Clang, and add a missing header
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89051 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 06:14:37 +00:00
John McCall 9488ea120e Instead of hanging a using declaration's target decls directly off the using
decl, create shadow declarations and put them in scope like normal.
Work in progress.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89048 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 05:59:44 +00:00
Anders Carlsson 9f853df0d3 Unify the way destructor epilogues are generated for synthesized and regular destructors. Also fix PR5529.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89034 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 04:44:12 +00:00
John McCall a24dc2e38c Carry lookup configuration throughout lookup on the LookupResult. Give
LookupResult RAII powers to diagnose ambiguity in the results.  Other diagnostics
(e.g. access control and deprecation) will be moved to automatically trigger
during lookup as part of this same mechanism.

This abstraction makes it much easier to encapsulate aliasing declarations
(e.g. using declarations) inside the lookup system:  eventually, lookup will
just produce the aliases in the LookupResult, and the standard access methods
will naturally strip the aliases off.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 02:14:36 +00:00
Eli Friedman e73d3bc991 Simplify the AST a bit by skipping creating member initializers for members
with a trivial constructor.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 23:07:59 +00:00
Douglas Gregor a4923eb7c4 First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:

  typedef const int CInt;
  typedef CInt Self;

Self.isConstQualified() currently returns false!

Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions: 

  - the "local" version only returns qualifiers on this particular
    QualType instance
  - the "normal" version that will eventually combine qualifiers from this
    QualType instance with the qualifiers on the canonical type to
    produce the full set of qualifiers.

This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
  
  Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()

expressions over to 

  Context.hasSameUnqualifiedType(T1, T2)




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 21:35:15 +00:00
Anders Carlsson 6d7013940a Make sure that virtual destructors have delete operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88877 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 22:49:34 +00:00
Douglas Gregor c07a494b37 Don't gratuitously mark the default constructors of base or member initializers as used
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 08:51:10 +00:00
Sebastian Redl a82e4ae149 - Have TryStaticImplicitCast set the cast kind to NoOp when binding a reference. CheckReferenceInit already inserts implicit casts to the necessary types. This fixes an assertion in CodeGen for some casts and brings a fix for PR5453 close, if I understand that bug correctly.
- Also, perform calculated implicit cast sequences if they're determined to work. This finally diagnoses static_cast to ambiguous or implicit bases and fixes two long-standing fixmes in the test case. For the C-style cast, this requires propagating the access check suppression pretty deep into other functions.
- Pass the expressions for TryStaticCast and TryStaticImplicitCast by reference. This should lead to a better AST being emitted for such casts, and also fixes a memory leak, because CheckReferenceInit and PerformImplicitConversion wrap the node passed to them. These wrappers were previously lost.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88809 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 21:15:49 +00:00
Douglas Gregor 19aeac6ea4 When type-checking a static cast (or the static_cast part of a C-style
cast) that is converting to a class type, enumerate its constructors
as in any other direct initialization. This ensures that we get the
proper conversion sequence.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88751 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 03:27:21 +00:00
Douglas Gregor 66724ea67d If we attempt to add a constructor template specialization that looks
like a copy constructor to the overload set, just ignore it. This
ensures that we don't try to use such a constructor as a copy
constructor *without* triggering diagnostics at the point of
declaration.

Note that we *do* diagnose such copy constructors when explicitly
written by the user (e.g., as an explicit specialization).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88733 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-14 01:20:54 +00:00
Anders Carlsson 8db68da430 Clear temporaries in more places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88687 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 20:11:49 +00:00
Anders Carlsson f8a9a797a4 Fix bug Doug noticed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88679 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 19:21:49 +00:00
Douglas Gregor afe7ec28b1 When transforming an expression statement (e.g., for template
instantiation), be sure to finish the expression statement by
providing a FullExprArg, making sure that temporaries get
destroyed. Fixes an obscure failure when parsing
llvm/LinkAllPasses.h.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88668 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 18:34:26 +00:00
Douglas Gregor cffecd08f1 Give CanQual<T> an implicit conversion to bool, so that it can be used
in "if" statements like:

  if (CanQual<ReferenceType> RefType = T.getAs<ReferenceType>())

Thanks to Clang for pointing out this mistake :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86995 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 16:49:45 +00:00
John McCall af8e6ed61b Random const correctness, and incidentally use computeDeclContext when building
a using declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86942 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-12 03:15:40 +00:00
Fariborz Jahanian b03bfa55d0 Diagnose illegally typed operator new/new[].
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86755 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 23:47:18 +00:00
Douglas Gregor 314b97f8c5 Improve parsing of template arguments to lay the foundation for
handling template template parameters properly. This refactoring:

  - Parses template template arguments as id-expressions, representing
    the result of the parse as a template name (Action::TemplateTy)
    rather than as an expression (lame!).

  - Represents all parsed template arguments via a new parser-specific
    type, ParsedTemplateArgument, which stores the kind of template
    argument (type, non-type, template) along with all of the source
    information about the template argument. This replaces an ad hoc
    set of 3 vectors (one for a void*, which was either a type or an
    expression; one for a bit telling whether the first was a type or
    an expression; and one for a single source location pointing at
    the template argument).

  - Moves TemplateIdAnnotation into the new Parse/Template.h. It never
    belonged in the Basic library anyway.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86708 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 19:49:08 +00:00
Anders Carlsson 4881b99bc8 Use PP.getLocForEndOfToken as suggested by John.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 03:32:44 +00:00
Anders Carlsson ad26b7376b If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 03:24:44 +00:00
Eli Friedman 80c30dad6c Add additional note to mark the cause of synthesized constructors. Mark
declaration invalid if the constructor can't be properly built.  Addresses
remaining review comments from Fariborz for r86500.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86579 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 19:20:36 +00:00
Eli Friedman f8db4771d4 Remove a useless variable that got left behind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 01:11:03 +00:00
Eli Friedman 49c16da71b Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors.  This has a number of benefits:

1. Less code.

2. Explicit and implicit constructors get the same diagnostics.

3. The AST explicitly contains constructor calls from implicit default
constructors.  This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 01:05:47 +00:00
Douglas Gregor 3eaa9ffa17 Always make sure we're using an unqualified type when building a
constructor name.  Fixes PR5418.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86441 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 07:12:55 +00:00
Eli Friedman 88fad6310d Make sure isCopyAssignment is only true for actual copy assignment operators,
instead of all assignment operators.  The mistake messes up IRGen because
it ends up assuming that the assignment operator is actually the implicit
copy assignment operator, and therefore tries to emit the RHS as an lvalue.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 00:02:45 +00:00
Fariborz Jahanian 966256afd4 This patch implements Sema for clause 13.3.3.1p4.
It has to do with vararg constructors used as conversion
functions. Code gen needs work. This is WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86207 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:23:08 +00:00
Douglas Gregor 393896f49d Fixed two places where we needed to force completion of a type
(without complaining if it fails) to get proper semantics: reference
binding with a derived-to-base conversion and the enumeration of
constructors for user-defined conversions. There are probably more
cases to fix, but my prior attempt at statically ensuring that
complete-type checking always happens failed. Perhaps I'll try again.

With this change, Clang can parse include/llvm/*.h!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86129 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 13:06:35 +00:00
John McCall 6aee621291 Comments, formatting. Based on patch by Brandon Pearcy!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86065 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 23:13:52 +00:00
John McCall b41900410f Diagnose using a field to initialize itself. Patch by Brandon Pearcy!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86061 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 23:02:40 +00:00
Douglas Gregor 1fe6b919f7 Don't try to check the initialization of fields with dependent
types. Fixes PR5352.

Fariborz, please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86031 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 17:16:11 +00:00
Douglas Gregor 12c118a8ff Switch parsing of using declarations over to ParseUnqualifiedId.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 16:30:06 +00:00
Douglas Gregor 3f9a0566e6 Introduce a new class, UnqualifiedId, that provides a parsed
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.

Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 01:35:08 +00:00
Anders Carlsson 0ebb6d391d Make sure to call CompleteConstructorCall for bases and members that are initialized implicitly in constructors so that default arguments etc are set correctly. Fixes PR5283.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 15:46:07 +00:00
Fariborz Jahanian 680a3f3581 Use array's base element type in getting to its
constructor. WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 19:04:36 +00:00
Fariborz Jahanian c0fcce4614 Removed an unnecessary arguement passed to InitializeVarWithConstructor
which should come from the variable and wasn't correct for arrays in any case.
No change in functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 18:41:06 +00:00
Chris Lattner 5a597a9d1c remove a nonsensical todo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85067 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 21:19:07 +00:00
Chris Lattner c7f1904474 change Sema::ActOnFriendTypeDecl to use GetTypeForDeclarator instead
of ConvertDeclSpecToType, which I'd like to keep private to SemaType.cpp.
We do this by cons'ing up a trivial Declarator for the type.

John, please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:47:27 +00:00
Sebastian Redl 9994a34f6c Audit the code for places where it is assumed that every base specifier refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:03:50 +00:00
John McCall 54e14c4db7 When building types from declarators, instead of building two types (one for
the DeclaratorInfo, one for semantic analysis), just build a single type whose
canonical type will reflect the semantic analysis (assuming the type is
well-formed, of course).

To make that work, make a few changes to the type system:
* allow the nominal pointee type of a reference type to be a (possibly sugared)
  reference type.  Also, preserve the original spelling of the reference type.
  Both of these can be ignored on canonical reference types.
* Remove ObjCProtocolListType and preserve the associated source information on
  the various ObjC TypeLocs.  Preserve the spelling of protocol lists except in
  the canonical form.
* Preserve some level of source type structure on parameter types, but
  canonicalize on the canonical function type.  This is still a WIP.

Drops code size, makes strides towards accurate source location representation,
slight (~1.7%) progression on Cocoa.h because of complexity drop.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84907 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 22:37:11 +00:00
Douglas Gregor 573d9c3252 Don't (directly) call RequireCompleteType with an invalid source location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 23:19:44 +00:00
Anders Carlsson 96ad5337a4 Change FixOverloadedFunctionReference to return a (possibly new) expression. Substitute TemplateIdRefExprs with DeclRefExprs. Doug, plz review :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84763 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 17:16:23 +00:00
Anders Carlsson 2782302961 It's OK for a pure virtual function to override another pure virtual function. Fixes PR5222.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 19:34:08 +00:00
Douglas Gregor 663b5a0be7 Testing and some minor fixes for explicit template instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84129 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 20:14:33 +00:00
Fariborz Jahanian d9290cb5ad Handle ambiguity of reference initialization.
Removes a FIXME.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84068 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 00:52:43 +00:00
Douglas Gregor 8c638ab9e7 Remove some non-ASCII characters
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 23:52:38 +00:00
Douglas Gregor 3f09327b26 Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 21:16:44 +00:00
Douglas Gregor 096ebfda90 Diagnose attempts to add default function arguments to a
specialization. This completes C++ [temp.expl.spec]!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83980 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 17:02:54 +00:00
Douglas Gregor a735b206fd Improve the internal representation and semantic analysis of friend
function templates.

This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation. 

Oh, and make sure that explicit specialization declarations are not
friends.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83970 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 14:39:41 +00:00
Sebastian Redl dced226e37 Test exception spec compatibility on return type and parameters.
Along the way, use RequireCompleteType when testing exception spec types.
Separate all the ugly spec stuff into its own file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 09:03:14 +00:00
Sebastian Redl 2c7588f126 Implement the core checking for compatible exception specifications in assignment and initialization.
The exception specification of the assignee must be the same or a subset of the target. In addition, exception specifications on arguments and return types must be equivalent, but this is not implemented yet.
This currently produces two diagnostics for every invalid assignment/initialization, due to the diagnostic produced outside PerformImplicitConversion, e.g. in CheckSingleInitializer. I don't know how to suppress this; in any case I think it is the wrong place for a diagnostic, since there are other diagnostics produced inside the function. So I'm leaving it as it is for the moment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-10 12:04:10 +00:00
John McCall f36e02d4af Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines.  Call out uses which assume a single
result.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83674 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-09 21:13:30 +00:00
Fariborz Jahanian 0c728f1eb2 Fix up error reporting when object cannot be constructed
because of missing default constructor of a member.
Fixes pr5154.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83583 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 22:15:49 +00:00
John McCall e3af0235ce Refactoring around friend class templates. Better error message for friend enums.
Don't create a new declaration for friend classes if a declaration already exists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83505 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-07 23:34:25 +00:00
Douglas Gregor a8f32e0965 Refactor the code that walks a C++ inheritance hierarchy, searching
for bases, members, overridden virtual methods, etc. The operations
isDerivedFrom and lookupInBases are now provided by CXXRecordDecl,
rather than by Sema, so that CodeGen and other clients can use them
directly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-06 17:59:45 +00:00
John McCall 9aeed32282 Anonymous namespaces, sema + codegen. A lot of semantics are still broken,
apparently because using directives aren't quite working correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-01 00:25:31 +00:00
Fariborz Jahanian 893f955321 Issue good diagnostics when initializing a refernce type with
a bad initializer. Fixes pr4274.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83169 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 21:23:30 +00:00
John McCall bf1cc05907 Desugaring optimizations. Add single-step desugaring methods to all
concrete types.  Use unqualified desugaring for getAs<> and sundry.
Fix a few users to either not desugar or use qualified desugar, as seemed
appropriate.  Removed Type's qualified desugar method, as it was easy
to accidentally use instead of QualType's.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83116 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-29 23:03:30 +00:00
Argyrios Kyrtzidis f352bddf01 Introduce ObjCProtocolListLoc for keeping source location information for protocol references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83094 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-29 19:43:35 +00:00
Fariborz Jahanian 82ad87b872 Minor API change. No change in functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83022 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 22:03:07 +00:00
Douglas Gregor 182ddf0e5d Improve handling of friend function templates somewhat
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82950 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 00:08:27 +00:00
Douglas Gregor d85bea2aff Rework the Parse-Sema interaction for friends to better support friend
class templates. We now treat friend class templates much more like
normal class templates, except that they still get special name lookup
rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in
<iostream>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82848 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 06:47:28 +00:00
John McCall 0953e767ff Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82705 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 19:53:00 +00:00
Fariborz Jahanian 7ad2d562e8 Use Doug's DeclLoc to pinpoint location of the declaration
in a reference initialization diagnostic.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82671 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 00:42:43 +00:00
Douglas Gregor 739d828314 Improve diagnostic location information when checking the initialization of a reference
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82666 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 23:04:10 +00:00
Fariborz Jahanian 8f489d692f patch to ir-gen conversion function call used in
initializing a reference class.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82664 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 22:34:00 +00:00
Fariborz Jahanian 2b51138433 Remove the FIXME as I said.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82650 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 20:56:34 +00:00
Fariborz Jahanian 51bebc83e7 This patch addresses a few issues related to 8.5.3 [dcl.init.ref]
It uses a recent API to find inherited conversion functions to do
the initializer to reference lvalue conversion (and removes a FIXME).
It issues the ambiguity diagnostics when multiple conversions are found.
WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 20:55:32 +00:00
John McCall 183700f494 Change all the Type::getAsFoo() methods to specializations of Type::getAs().
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely.  Several more 'leaf'
optimizations were introduced.

The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 23:43:11 +00:00
Douglas Gregor d85cef5a54 Merge uninstantiated default arguments more carefully, and try not to
complain about specializations of member functions that are not
definitions. Fixes PR4995.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82159 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-17 19:51:30 +00:00
John McCall dd4a3b0065 Improved representation and support for friend class templates. Angst about same.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82088 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-16 22:47:08 +00:00
Douglas Gregor 7adb10fa31 When implicitly declaring operators new, new[], delete, and delete[],
give them the appropriate exception specifications. This,
unfortunately, requires us to maintain and/or implicitly generate
handles to namespace "std" and the class "std::bad_alloc". However,
every other approach I've come up with was more hackish, and this
standard requirement itself is quite the hack.

Fixes PR4829.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81939 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 22:30:29 +00:00
Anders Carlsson 7171011353 Add back the workaround since it lead to constructor conversion bugs :(
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81917 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 21:14:33 +00:00
Anders Carlsson f6c213a931 When performing an user defined conversion sequence, perform the initial standard conversion sequence. This lets us remove a workaround in SemaCompleteConstructorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 06:28:28 +00:00
John McCall 05b23ea211 Skeletal support for friend class templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81801 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-14 21:59:20 +00:00
Fariborz Jahanian debc629300 Removed Context argument from couple of methods which don't
need them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-12 19:02:34 +00:00
John McCall bbbcdd9cc0 Alter Action's friend interface to prepare for templated friend declarations and
to stop making promises we can't currently keep.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81571 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-11 21:02:39 +00:00
Douglas Gregor 6cc1518b9f Cleanup and test C++ default arguments. Improvements include:
- Diagnose attempts to add default arguments to templates (or member
    functions of templates) after the initial declaration (DR217).
  - Improve diagnostics when a default argument is redefined. Now, the
    note will always point at the place where the default argument was
    previously defined, rather than pointing to the most recent
    declaration of the function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81548 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-11 18:44:32 +00:00
Douglas Gregor 1cdcc579df When re-entering a template scope, we may be entering a class template
partial specialization rather than a subclass of TemplateDecl. Fixes a
crash in libstdc++ 4.2's <map>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81407 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-10 00:12:48 +00:00
Douglas Gregor 39da0b8145 Improve handling of initialization by constructor, by ensuring that
such initializations properly convert constructor arguments and fill
in default arguments where necessary. This also makes the ownership
model more clear.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81394 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 23:08:42 +00:00
Mike Stump 1eb4433ac4 Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 15:08:12 +00:00
John McCall 6b2becfc43 Support templateids in friend declarations. Fixes bug 4859.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81233 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-08 17:47:29 +00:00
Anders Carlsson d74d4149f7 Handle variadic constructors better. Share code between BuildCXXConstructExpr and BuildCXXTemporaryObjectExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-08 01:48:42 +00:00
Anders Carlsson f47511ab05 BuildCXXConstructExpr now takes a MultiExprArg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81160 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-07 22:23:31 +00:00
Anders Carlsson 21e1c4ea0a Reapply 81096, now with a fix. Spot the bug:
for (unsigned i = numargs; i < NumArgs; ++i)
        Args[0] = 0;

;)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81123 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-06 16:54:02 +00:00
Daniel Dunbar 4355be0758 Revert "Initialize default CXXConstructExpr arguments to 0. Fixes a crash when
destroying the CXXConstructExpr.", this is causing test failures across the
board.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81100 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-06 01:31:23 +00:00
Anders Carlsson 657bff7ff3 Initialize default CXXConstructExpr arguments to 0. Fixes a crash when destroying the CXXConstructExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81096 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-05 22:51:06 +00:00
Anders Carlsson ec8e5ea799 Pass the ConstructLoc to BuildCXXConstructExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81068 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-05 07:40:38 +00:00
Douglas Gregor 4fe95f99a2 Don't generate any code for an explicit call to a trivial destructor.
Now that parsing, semantic analysis, and (I think) code generation of
pseudo-destructor expressions and explicit destructor calls works,
update the example-dynarray.cpp test to destroy the objects it
allocates and update the test to actually compile + link.
The code seems correct, but the Clang-compiled version dies with a
malloc error. Time to debug!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-04 19:04:08 +00:00
Fariborz Jahanian 34374e6ce5 Patch to instantiate destructors used to destruct
base and data members when they are needed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80967 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 23:18:17 +00:00
Fariborz Jahanian 9d436205be Mark constructors used in initialization of base(s) and fields
as referecned with location where they are used. Still
need to look at destructor aspects of them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80950 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 21:32:41 +00:00
Fariborz Jahanian 80545ad0f9 Issue diagnostics in variety of situations involving
reference/const data members when user has declared
the constructor. This necessitated some non-minor
refactoring.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 19:36:46 +00:00
Fariborz Jahanian 916a5ed560 Minor refactoring of my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 23:11:48 +00:00
Fariborz Jahanian cf1b9c790a Referenced instatiated default constructors
must be defined. Fixed pr4853.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 23:02:57 +00:00
Fariborz Jahanian 636a0ffbd2 Allow null initialization of scalara data members
in constructors's initializer list. pr4854



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80802 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 17:10:17 +00:00
Anders Carlsson cdc83c7779 Don't assume that a base is always a RecordType, it can also be a TemplateSpecializationType. Also, make sure to get the instantiated union member.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80662 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-01 06:22:14 +00:00
John McCall ab88d97734 Fix bug 4784 and allow friend declarations to properly extend
existing declaration chains.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80636 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-31 22:39:49 +00:00
Anders Carlsson 05180afbf4 Use DiagnoseMissingMember for UsingDecls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80470 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-30 00:58:45 +00:00
Anders Carlsson f4d84b663e Improve diagnostics for missing members. This renames the err_typecheck_no_member to err_typecheck_no_member_deprecated. The idea is that err_typecheck_no_member_deprecated should be phased out and any call sites that reference it should call DiagnoseMissingMember instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80469 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-30 00:54:35 +00:00
Anders Carlsson 595adc1795 Set the access specifier for using decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80435 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-29 19:54:19 +00:00
John McCall 5fee110ac1 For consistency, just make friend declarations AS_public.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-29 03:50:18 +00:00
Anders Carlsson 8c57a66a2a Store the SourceLocation of right parentheses in member initializers. Patch by Anders Johnsen!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80416 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-29 01:31:33 +00:00
Anders Carlsson faccd72e24 Fix this for real.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80377 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 16:57:08 +00:00
Anders Carlsson 08972924fa Pass InOverloadResolution all the way down to IsPointerConversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80368 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 15:33:32 +00:00
Anders Carlsson 0dde18e5a7 Instantiate unresolved using declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 15:18:15 +00:00
John McCall 02cace78cf Omnibus friend decl refactoring. Instead of cloning AST classes for friend
declarations of same, introduce a single AST class and add appropriate bits
(encoded in the namespace) for whether a decl is "real" or not.  Much hackery
about previously-declared / not-previously-declared, but it's essentially
mandated by the standard that friends alter lookup, and this is at least
fairly non-intrusive.

Refactor the Sema methods specific to friends for cleaner flow and less nesting.

Incidentally solve a few bugs, but I remain confident that we can put them back.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80353 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 07:59:38 +00:00
Anders Carlsson 550b14b410 Create UnresolvedUsingDecls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 05:49:21 +00:00
Anders Carlsson c72160ba4c Factor declaration building out to Sema::BuildUsingDeclaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80337 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 05:40:36 +00:00
Anders Carlsson 73b39cf02e More work on using declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80333 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 03:35:18 +00:00
Anders Carlsson cf9f921268 Many improvements to using declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80332 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 03:16:11 +00:00
Anders Carlsson 2de3aced4c Remove more default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80260 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 17:30:43 +00:00
Anders Carlsson da7a18be8f Remove default arguments from TryImplicitConversion and fix a bug found in the process.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80258 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 17:24:15 +00:00
Anders Carlsson 2974b5cd26 Revert the flags change for now, I have a better idea for this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80255 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 17:14:02 +00:00
Anders Carlsson 1937738953 Add a OverloadResolutionFlags and start converting some of the overload methods over to using it instead of bools arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 16:01:18 +00:00
Anders Carlsson 8d4c5ea0ee Don't check member and base initializers if the constructor is dependent.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80211 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 05:57:30 +00:00
Anders Carlsson 5c36fb22d9 Use early returns to avoid indentation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 05:45:01 +00:00
Eli Friedman 2a16a13881 Stub out an error so we don't crash.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80207 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 05:09:36 +00:00
Anders Carlsson e7624a75b7 Add a BuildCXXTemporaryObjectExpr and use it so default arguments will be instantiated correctly for temporary object expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80206 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 05:08:22 +00:00
Anders Carlsson a6ec7ad25a New RequireNonAbstractType function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80183 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 00:13:57 +00:00
Anders Carlsson b790661a15 Bye-bye old RequireCompleteType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80182 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-26 23:45:07 +00:00
Douglas Gregor 83ddad3ab5 Implement support for C++ direct initializers that involve dependent
types or type-dependent expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-26 21:14:46 +00:00
Anders Carlsson 5653ca5088 If a parameter has a default argument expression, make sure to instantiate the parameter type before checking that the expression is a valid initializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79986 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 13:46:13 +00:00
Anders Carlsson 8644aecd43 Improved support for default arguments in constructors for class templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 13:07:08 +00:00
Anders Carlsson fe2de492d0 InitializeVarWithConstructor now returns true on failure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 05:18:00 +00:00
Anders Carlsson da3f4e2dd5 BuildCXXConstructExpr now returns an OwningExprResult.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79975 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 05:12:04 +00:00
Anders Carlsson 9351c173cd Basic support for default argument expressions for function templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79972 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 03:18:48 +00:00
Anders Carlsson ed961f989e Factor setting default arguments out into SetParamDefaultArgument.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79970 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 02:29:20 +00:00
Anders Carlsson 5f49a0c693 Use hasDefaultArg instead of getDefaultArg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79967 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 01:23:32 +00:00
Anders Carlsson 66e3067d98 Check that the default argument is well-formed before checking the initializer types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79964 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 01:02:06 +00:00
Douglas Gregor 5842ba9fd4 Try to complete a type before looking for conversion functions within
that type. Note that we do not produce a diagnostic if the type is
incomplete; rather, we just don't look for conversion functions. Fixes PR4660.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79919 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 15:23:48 +00:00
Douglas Gregor efd5bdad3c Make sure to adjust function template declarations to their templated
declarations (e.g., FunctionTemplateDecl -> CXXConstructorDecl) before
performing semantic analysis on the declarations. Fixes PR4761.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79911 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 11:57:43 +00:00
Douglas Gregor 65ec1fda47 Implement conversion function templates, along with the ability to use
template argument deduction from a conversion function (C++
[temp.deduct.conv]) with implicit conversions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79693 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 23:19:43 +00:00
Douglas Gregor ac373c4ca5 Fix parsing for out-of-line definitions of constructors and
destructors of class templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79678 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 22:16:40 +00:00
Douglas Gregor dec06664a1 Introduce support for constructor templates, which can now be declared
and will participate in overload resolution. Unify the instantiation
of CXXMethodDecls and CXXConstructorDecls, which had already gotten
out-of-sync.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79658 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 18:42:58 +00:00
Argyrios Kyrtzidis a5d82000f7 Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use DeclaratorInfo to get this information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 00:31:54 +00:00
Douglas Gregor 37b372b76a Initial support for parsing and representation of member function templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79570 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-20 22:52:58 +00:00
John McCall f18970d1dd Add syntax examples for the friend declaration types.
Remove an assert trivialized by dominating code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79520 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-20 07:19:42 +00:00
Argyrios Kyrtzidis e8661906d4 Use Sema's LocInfoType to pass and preserve type source info through the Parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79395 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 01:28:28 +00:00
Argyrios Kyrtzidis a1d5662d96 Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema interfaces.
DeclaratorDecl contains a DeclaratorInfo* to keep type source info.
Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl.
EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo.

Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79392 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 01:27:57 +00:00
John McCall 88232aadbe Teach Sema how to pop out of friend function definitions in nested classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79291 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-18 00:00:49 +00:00
Anders Carlsson 9abf2aedae AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and create the CXXExprWithTemporaries before setting the initializer on the VarDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 05:13:48 +00:00
Anders Carlsson 089c2602eb BuildCXXConstructExpr doesn't need to take an ASTContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79149 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 23:41:35 +00:00
Eli Friedman 1d954f6a00 Implement __is_empty. Patch by Sean Hunt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 21:55:26 +00:00
Anders Carlsson f1480eee38 Make the CXXDefaultArgExpr constructor protected and add a static Create function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79013 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-14 18:30:22 +00:00
Fariborz Jahanian ad25883a64 Patch to force synthesis of copy assignment operator
function in the order according to c++03. ir-gen 
for copy assignment in the trivial case and the first
test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78938 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 21:09:41 +00:00
Fariborz Jahanian 0270b8aa3f More toward synthesizing copy assignments. SWIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78861 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 23:34:46 +00:00
Fariborz Jahanian 2198ba12b7 Patch for synthesizing copy assignment operator.
WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78841 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-12 21:14:35 +00:00
John McCall c48fbdfb83 Add a FriendClassDecl type for holding declarations of friend types in
the AST, and create such declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78719 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 21:13:21 +00:00
Fariborz Jahanian e649412808 ir-gen support for anonymous union data member
copying in copy constructors and used in
default constructor's initializer list.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 18:49:54 +00:00
John McCall 3f9a8a6061 Argument-dependent lookup for friend declarations. Add a new decl type,
FriendFunctionDecl, and create instances as appropriate.

The design of FriendFunctionDecl is still somewhat up in the air;  you can
befriend arbitrary types of functions --- methods, constructors, etc. ---
and it's not clear that this representation captures that very well.
We'll have a better picture when we start consuming this data in access
control.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78653 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 06:59:38 +00:00
John McCall 470c2a9ab6 Drop the friend-inner-class diagnostic from an extwarn to an ext and don't
guard its report on GNUMode.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78338 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 21:21:21 +00:00
John McCall 7f27d92006 Permit a class to friend its members in C++0x, without restriction.
Permit a class to friend its class members in C++ 98, as long as extensions
are enabled (and even when they aren't, only give an extwarn about it).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78332 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 20:49:32 +00:00
John McCall 67d1a67f3d First pass at friend semantics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78274 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 02:15:43 +00:00
Eli Friedman 33a3138a08 Get rid of "smart" quotes. Per report on cfe-dev.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78230 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 19:21:58 +00:00
Fariborz Jahanian caa499b50b Handle destruction of temporaries used in default argument
construction of constructor calls.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78222 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 18:17:32 +00:00
Fariborz Jahanian b2c352ed55 Patch to improve ir-gen for constructors with default argument
expressions and a test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78213 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 17:03:54 +00:00
Douglas Gregor 50d62d1b4a Introduce the canonical type smart pointers, and use them in a few places to
tighten up the static type system.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 05:36:45 +00:00
Fariborz Jahanian 2eeed7bc4f Support for use of default argument in constructors.
work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78132 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 00:26:10 +00:00
Mike Stump ac5fc7c6bc Canonicalize else.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 21:02:39 +00:00
Fariborz Jahanian a83f7ed3de Minor renaming/refactoring. No change in functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-03 19:13:25 +00:00
Anders Carlsson 3503d041ca Add CK_DerivedToBase and use it PerformObjectMemberConversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77652 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 01:23:52 +00:00
Ted Kremenek 6217b80b7a Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 21:53:49 +00:00
Eli Friedman 59c04373c6 Refactor base/member initializers, and construct them correctly in cases
with dependent types.  Fixes PR4621 and PR4627.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 19:44:27 +00:00
Fariborz Jahanian 7252f5110d More Sema check for constructor's member initializer along
with type conversion to fix ir-gen crash.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-24 20:28:49 +00:00
Fariborz Jahanian 87595e46cc Diagnose when base classes and members to be intialized
with constructors don't have a matching constructor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 23:32:59 +00:00
Fariborz Jahanian d7b27e1c17 Add constructor used to initialize base/member in
CXXBaseOrMemberInitializer AST node. Needed by
its clients to do the initialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76826 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 00:42:24 +00:00
Douglas Gregor 2aef06d344 Fix some memory allocation/deallocation issues
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76783 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 20:55:49 +00:00
Douglas Gregor 1f2023ab8b "This patch implements the restrictions on union members detailed in
[class.union]p1", from John McCall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76766 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 18:25:24 +00:00
Fariborz Jahanian 71c6e71477 Allocate BaseOrMemberInitializers and CXXBaseSpecifier nodes
via ASTContext.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 17:41:53 +00:00
Fariborz Jahanian 393612e6c7 Patch to accomodate Doug's comment on default
destruction of base/members for each destructor AST.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76663 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 22:36:06 +00:00
Eli Friedman 6347f420ee Misc fixes for -Wreorder:
1. Make it work correctly with anonymous unions.
2. Don't compute it if the warning isn't enabled.
3. Optimize the algorithm slightly to make it linear time in the 
case where we don't produce any warnings.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76630 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 19:28:10 +00:00
Ted Kremenek 35366a67ba Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 17:50:17 +00:00
Ted Kremenek 5cad1f7446 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76139 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 01:20:38 +00:00
Ted Kremenek 808825cd08 Replace Type::getAsReferenceType() with Type::getAs<ReferenceType>().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76132 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 01:01:15 +00:00
Ted Kremenek 1a1a6e2bd4 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 19:58:26 +00:00
Fariborz Jahanian 560de45ccb Added ASTs to destructor decl AST for default destruction of object's
base/members.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75849 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 22:34:08 +00:00
Fariborz Jahanian d01c915dda Patch to build AST for ctor's initializer list according to
semantics of order of construction [class.init].



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 18:24:21 +00:00
Fariborz Jahanian 40c072f44f Patch to build list of inherited virtual base classes
in their order of construction for each class and use it 
to to check on propery order of base class construction 
under -Wreorder option.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75270 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 20:13:23 +00:00
Fariborz Jahanian eb96e12752 Sema check on out of order object initialization of
class object's base and members under -Wreorder flag.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75168 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 19:59:47 +00:00
Anders Carlsson 5e09d4c96d Use getDeclName in DefineImplicitOverloadedAssign as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75152 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 17:47:25 +00:00
Anders Carlsson 5eda81624f Pass the DeclName to the diagnostic builder so that member names will be quoted correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75150 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 17:37:12 +00:00
Sebastian Redl 23c7d06136 Implement checking of exception spec compatibility for overriding virtual functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74943 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 20:29:57 +00:00
Sebastian Redl 4994d2d50c Catch function redeclarations with incompatible exception specifications.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74787 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-04 11:39:00 +00:00
Fariborz Jahanian 5ffcd7b1ba Patch to allocate list of bases in CXXRecordDecl
using ASTContxt allocation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74717 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 18:26:15 +00:00
Fariborz Jahanian 73b85f3d7c Use Destroy for member initializer list clean up.
Per Doug's comments. Doug please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74666 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 23:35:25 +00:00
Fariborz Jahanian 961743326f Patch to implement template types in ctor-initializer list.
Also has fix for bugzilla-4469.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74631 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 19:21:19 +00:00
Fariborz Jahanian bcfad54a43 Patch to support optional nested-name-specifier in in ctor-initializer
list.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74571 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 23:26:25 +00:00
Fariborz Jahanian 5ac3dfc24b Diagnose multiple initialization of anonymous union
fields in the ctor-initializer list.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74554 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 21:52:59 +00:00
Fariborz Jahanian 9da7201ade More diagnostics related to initialization of direct bases
in ctor-initializer list.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74541 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 17:34:52 +00:00
Fariborz Jahanian 514b7b153b Compute ending of iterator in for-loop once.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 16:36:53 +00:00
Argyrios Kyrtzidis 17945a0f64 De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:36:12 +00:00
Fariborz Jahanian 16dbdce023 Take care of Chris's comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74486 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 00:17:27 +00:00
Fariborz Jahanian 47deacfa43 A more detailed diagnosis of ill-formed ctor-initializer
list.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 00:02:17 +00:00
Fariborz Jahanian 7881a05658 Diagnose multiple initialzation of data-member/base
in the ctor-initializer list. More to come.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74465 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-29 22:33:26 +00:00
Fariborz Jahanian f8d736ca54 Renamed MarcDestructorReferenced -> MarkDestructorReferenced
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 15:05:11 +00:00
Eli Friedman 5d39dee0cc Fix a bogus error overloading an operator where the only class
parameter has a dependent type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74380 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 05:59:59 +00:00
Anders Carlsson 0c6139d0c2 Make it possible for using decls to point to operators. Fixes PR4441.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 00:27:47 +00:00
Fariborz Jahanian 8d2b35630d Patch to mark destructors when they are used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74359 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 23:49:16 +00:00
Fariborz Jahanian c6249b9230 Minor change per Doug's comments.
- Fariborz


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74287 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 16:08:57 +00:00
Douglas Gregor e53060fa78 Improved semantic analysis and AST respresentation for function
templates.

For example, this now type-checks (but does not instantiate the body
of deref<int>):

  template<typename T> T& deref(T* t) { return *t; }

  void test(int *ip) {
    int &ir = deref(ip);
  }

Specific changes/additions:
  * Template argument deduction from a call to a function template.
  * Instantiation of a function template specializations (just the
  declarations) from the template arguments deduced from a call.
  * FunctionTemplateDecls are stored directly in declaration contexts
  and found via name lookup (all forms), rather than finding the
  FunctionDecl and then realizing it is a template. This is
  responsible for most of the churn, since some of the core
  declaration matching and lookup code assumes that all functions are
  FunctionDecls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74213 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 22:08:12 +00:00
Fariborz Jahanian c75bc2d1f6 Patch to diagnose and Mark use of implicit default assignment operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74205 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 21:45:19 +00:00
Duncan Sands 6887e63ff5 Explicit braces to avoid ambiguous ‘else’.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74171 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 09:03:06 +00:00
Fariborz Jahanian 220a0f3412 Some changes to accomodate Doug's comment for
implicit copy constructor definition determination.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 23:42:10 +00:00
Fariborz Jahanian 485f087407 patch to mark use of implicit copy constructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73922 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 23:34:40 +00:00
Douglas Gregor 4c4f7cb3a5 Robustify a bunch of C++-related declaration actions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73918 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 23:20:33 +00:00
Douglas Gregor d7f37bf8b9 Implement implicit instantiation of the member functions of a class template
specialization. At present, all implicit instantiations occur at the
end of the translation unit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73915 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 23:06:13 +00:00
Fariborz Jahanian 05a5c45507 Changes made per Doug's comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73897 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 20:37:23 +00:00
Fariborz Jahanian b7f4cc09ea Remove ImplicitMustBeDefined, use universal 'Used' flag
instead. Do the implicit default ctor checking in MarkDeclarationReferenced.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73888 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 17:30:33 +00:00
Fariborz Jahanian 3da83eb7bc Made improvements in c++'s object model patch on Doug's review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73833 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 20:23:38 +00:00
Douglas Gregor 9cfbe48a7a Parsing and AST support for using declarations, from John Thompson!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73812 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 00:51:54 +00:00
Douglas Gregor e0762c9211 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:52:42 +00:00
Fariborz Jahanian f8dcb866d3 Patch for implementation of C++'s object model. This is
work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73782 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 19:55:27 +00:00
Argyrios Kyrtzidis 1d1755348d Factor out some common code into Sema::EnterDeclaratorContext/ExitDeclaratorContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73655 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 23:15:40 +00:00
Argyrios Kyrtzidis 0ffd9ffb63 Implement correct name lookup inside an initializer of a C++ class static data member.
Fixes "test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp" test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73652 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 22:50:06 +00:00
Fariborz Jahanian 8bc3fa4eb6 Removed deadcode related to addition of constructor
decls to a class.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73650 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 22:44:31 +00:00
Douglas Gregor 9cdda0cf85 Support dependent extended vector types and template instantiation
thereof. Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73641 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 21:51:59 +00:00
Anders Carlsson f54741e646 Handle temporaries in default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73462 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 03:37:31 +00:00
Anders Carlsson 5e300d1a8e It's an error to use a function declared in a class definition as a default argument before the function has been declared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73234 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 16:51:40 +00:00
Anders Carlsson ae0b4e7be7 Make ParmVarDecl::getDefaultArg() more robust, it now asserts that the argument is not unparsed. Add a new hasDefaultArg() and use it in places where getDefaultArg() was called when the argument was unparsed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 04:14:07 +00:00
Anders Carlsson 8e587a15da Remove VarDecl from CXXConstructExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72633 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 20:56:46 +00:00
Douglas Gregor 6c9c940531 Pretty printing and improved representation for namespace alias declarations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72616 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 06:48:27 +00:00
Douglas Gregor 8419fa3af9 Printing for using directives, e.g.,
using namespace std::debug;

Extended UsingDirectiveDecl to store the nested-name-specifier that
precedes the nominated namespace.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72614 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 06:31:56 +00:00
Douglas Gregor 6569d68745 Reimplement much of the way that we track nested classes in the
parser. Rather than placing all of the delayed member function
declarations and inline definitions into a single bucket corresponding
to the top-level class, we instead mirror the nesting structure of the
nested classes and place the delayed member functions into their
appropriate place. Then, when we actually parse the delayed member
function declarations, set up the scope stack the same way as it was
when we originally saw the declaration, so that we can find, e.g.,
template parameters that are in scope.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72502 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 23:11:45 +00:00
Sebastian Redl 465226e23a Reintroduce the home for exception specs, and make Sema fill it. However, keep the spec out of the canonical type this time. Net effect is currently nothing, because the spec isn't checked anywhere.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 22:11:52 +00:00
Douglas Gregor 78d1583d0b When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 18:54:04 +00:00
Anders Carlsson 6865480f0c When assigning from an rvalue to a const reference, the implicit cast from T -> const T is not an lvalue cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72082 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 00:38:24 +00:00
Douglas Gregor 2f2433f2c4 Deal with an icky corner case where we were complaining that a catch
statement was using an rvalue reference during the template
definition. However, template instantiations based on an lvalue
reference type are well-formed, so we delay checking of these property
until template instantiation time.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 21:08:14 +00:00
Douglas Gregor d308e6201a Template instantiation for C++ try/catch statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72035 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 20:51:54 +00:00
Anders Carlsson 8ff8c2278c Rewrite PureVirtualMethodCollector to use the overridden methods. Fixes <rdar://problem/6854087>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71970 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 00:00:05 +00:00
Mike Stump 390b4cc8b4 Reflow some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 07:39:55 +00:00
Anders Carlsson c3a68b25cd Better diagnostics for covariance when checking overriding return types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71786 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 19:52:19 +00:00
Anders Carlsson d7ba27dc56 Add return type checking for overriding virtual functions. We currently don't check covariance but that's next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71759 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 01:09:04 +00:00
Anders Carlsson 0033836b3c Friend declarations are only valid inside class definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71489 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-11 22:55:49 +00:00
Douglas Gregor 42af25f865 Implement the notions of the "current instantiation" and "unknown
specialization" within a C++ template, and permit name lookup into the
current instantiation. For example, given:

  template<typename T, typename U>
  struct X {
    typedef T type;

    X* x1;  // current instantiation
    X<T, U> *x2; // current instantiation
    X<U, T> *x3; // not current instantiation
    ::X<type, U> *x4; // current instantiation
    X<typename X<type, U>::type, U>: *x5; // current instantiation
  };



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71471 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-11 19:58:34 +00:00
Sebastian Redl bfa2fcba54 Back out r70506 (exception spec in AST) again. We won't have exception specs until we've had a lot more discussion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71125 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 23:27:55 +00:00
Douglas Gregor 33bbbc5ec8 When determining whether an expression refers to a bit-field, look
into the left-hand side of an assignment expression. This completes
most of PR3500; the only remaining part is to deal with the
GCC-specific implementation-defined behavior for "unsigned long" (and
other) bit-fields.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-02 02:18:30 +00:00