Commit Graph

167 Commits

Author SHA1 Message Date
Anders Carlsson dee9a30204 Unify the way destructor epilogues are generated for synthesized and regular destructors. Also fix PR5529.
llvm-svn: 89034
2009-11-17 04:44:12 +00:00
Douglas Gregor 1b8fe5b716 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)

llvm-svn: 88969
2009-11-16 21:35:15 +00:00
Douglas Gregor ffe14e3712 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).

llvm-svn: 88733
2009-11-14 01:20:54 +00:00
Douglas Gregor ff7028a55e Revert r88718, which does NOT solve the constructor-template-as-copy-constructor issue. Big thanks to John for finding this
llvm-svn: 88724
2009-11-13 23:59:09 +00:00
Douglas Gregor 5f235a21eb A constructor template cannot be instantiated to a copy
constructor. Make sure that such declarations can never be formed.

llvm-svn: 88718
2009-11-13 23:14:53 +00:00
Eli Friedman 01cad4c6b0 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.

llvm-svn: 86307
2009-11-07 00:02:45 +00:00
Douglas Gregor 62b885d43c When looking for a copy-assignment operator to determine the cv-qualifiers on its argument type, ignore assignment operator templates
llvm-svn: 85629
2009-10-30 22:48:49 +00:00
Sebastian Redl 1054faed32 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.
llvm-svn: 85055
2009-10-25 17:03:50 +00:00
Douglas Gregor a14b43bba8 Member function templates (and instantiations/specializations thereof)
are never copy constructors or copy assignment operators.

llvm-svn: 84057
2009-10-13 23:45:19 +00:00
Douglas Gregor 06db9f50a2 Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.

llvm-svn: 83890
2009-10-12 20:18:28 +00:00
Fariborz Jahanian 65694b413d Use CanQualType (instead of QualType) to store collection of visible
canonical conversion types.

llvm-svn: 83869
2009-10-12 18:36:50 +00:00
Fariborz Jahanian 4ff5f05782 Refactoring to further simplify collection of visible conversion
functions.

llvm-svn: 83552
2009-10-08 16:33:37 +00:00
Douglas Gregor bbe8f46621 Improve checking for specializations of member classes of class
templates, and keep track of how those member classes were
instantiated or specialized. 

Make sure that we don't try to instantiate an explicitly-specialized
member class of a class template, when that explicit specialization
was a declaration rather than a definition.

llvm-svn: 83547
2009-10-08 15:14:33 +00:00
Fariborz Jahanian 3ee21f1b91 Fixes problem in finding visible convertion functions of a class
where matching conversion types in base classes were still visible.
Plus refactoring and cleanup.
Added a test case.

llvm-svn: 83485
2009-10-07 20:43:36 +00:00
Douglas Gregor bb3e12fc0b Handle C++ delete expressions when the overloaded delete operator is a
"usual deallocation function" with two arguments. CodeGen will have to
handle this case specifically, since the value for the second argument
(the size of the allocated object) may have to be computed at run
time.

Fixes the Sema part of PR4782.

llvm-svn: 83080
2009-09-29 18:16:17 +00:00
John McCall 8ccfcb51ee 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.

llvm-svn: 82705
2009-09-24 19:53:00 +00:00
John McCall 9dd450bb78 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.

llvm-svn: 82501
2009-09-21 23:43:11 +00:00
Fariborz Jahanian a9c4041471 In building list of visible conversion functions, use
result type of template convesion functions.

llvm-svn: 81943
2009-09-15 23:02:16 +00:00
Fariborz Jahanian adcea10410 1) don't do overload resolution in selecting conversion
to pointer function for delete expression. 2)
Treat type conversion function and its 'const' version
as identical in building the visible conversion list.

llvm-svn: 81930
2009-09-15 22:15:23 +00:00
Douglas Gregor f70b2b4f38 Make sure we're comparing the canonical types when we determine
whether a constructor is a copy constructor.

Sadly, I wasn't able to get down to a test case smaller than libstdc++'s
<string>.

llvm-svn: 81913
2009-09-15 20:50:23 +00:00
Fariborz Jahanian a954049875 More improvement in building list of visible conversion
functions for a class when needed.

llvm-svn: 81624
2009-09-12 19:52:10 +00:00
Fariborz Jahanian edca0bcf48 Removed Context argument from couple of methods which don't
need them.

llvm-svn: 81621
2009-09-12 19:02:34 +00:00
Fariborz Jahanian b394f50ac9 More work toward having an access method for visible
conversion functions.

llvm-svn: 81618
2009-09-12 18:26:03 +00:00
Fariborz Jahanian a31472def0 No need to build the visible conversionfunction list for root class.
llvm-svn: 81583
2009-09-11 22:27:50 +00:00
Fariborz Jahanian b54ccb2782 Patch to build visible conversion function list lazily and make its
first use in calling the conversion function on delete statements.

llvm-svn: 81576
2009-09-11 21:44:33 +00:00
Douglas Gregor 6411b92ee6 Tweak the semantics of FunctionDecl::isOutOfLine to consider an
instantiation of a member function template or member function of a
class template to be out-of-line if the definition of that function
template or member function was defined out-of-line. This ensures that
we get the correct linkage for explicit instantiations of out-of-line
definitions. 

llvm-svn: 81562
2009-09-11 20:15:17 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Douglas Gregor 2d2282e8f9 When searching for a default constructor or copy constructor, skip constructor templates
llvm-svn: 81002
2009-09-04 14:46:39 +00:00
Fariborz Jahanian 37d065680b Patch to instantiate destructors used to destruct
base and data members when they are needed.

llvm-svn: 80967
2009-09-03 23:18:17 +00:00
Fariborz Jahanian 3501bcec7d Issue diagnostics in variety of situations involving
reference/const data members when user has declared
the constructor. This necessitated some non-minor
refactoring.

llvm-svn: 80934
2009-09-03 19:36:46 +00:00
Fariborz Jahanian 5083e2623b After a conversation with Doug. I added a fix me to
where we build the constructor's initializer list.

llvm-svn: 80735
2009-09-01 23:08:16 +00:00
Douglas Gregor a3a3f6fecd In CXXBaseOrMemberInitializer, don't confuse CtorTocall with
AnonUnionMember. Fixes PR4826.

llvm-svn: 80721
2009-09-01 21:04:42 +00:00
Douglas Gregor 32e2c8472e Fix a crasher involving template instantiation of non-dependent
expressions making use of an overloaded operator. Thanks for the test
case, Anders!

llvm-svn: 80679
2009-09-01 16:58:52 +00:00
Daniel Dunbar 6733a7ec15 Fix a -Asserts warning.
llvm-svn: 80606
2009-08-31 19:16:38 +00:00
Eli Friedman 15e05261d4 Make instantiating initializers for classes with a dependent base type
work correctly.

The change in lib/AST/DeclCXX.cpp is mostly a large reindentation; I 
couldn't figure out a good way to avoid it.

llvm-svn: 80446
2009-08-29 22:22:07 +00:00
Anders Carlsson 1e172e068f Store the SourceLocation of right parentheses in member initializers. Patch by Anders Johnsen!
llvm-svn: 80416
2009-08-29 01:31:33 +00:00
Anders Carlsson d20e795a5b Fix this for real.
llvm-svn: 80377
2009-08-28 16:57:08 +00:00
John McCall aa74a0c3b5 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.

llvm-svn: 80353
2009-08-28 07:59:38 +00:00
Anders Carlsson 8305c1fa97 Check in UnresolvedUsingDecl.
llvm-svn: 80336
2009-08-28 05:30:28 +00:00
Fariborz Jahanian 797cf62703 Skip over bases/fields with dependent types.
Fixes pr4771.

llvm-svn: 79999
2009-08-25 16:37:49 +00:00
Anders Carlsson 6eb55575da BuildCXXConstructExpr now returns an OwningExprResult.
llvm-svn: 79975
2009-08-25 05:12:04 +00:00
Fariborz Jahanian 20464fba70 Fixes pr4763.
llvm-svn: 79923
2009-08-24 17:19:23 +00:00
Douglas Gregor 05155d8d7b Implement conversion function templates, along with the ability to use
template argument deduction from a conversion function (C++
[temp.deduct.conv]) with implicit conversions.

llvm-svn: 79693
2009-08-21 23:19:43 +00:00
Douglas Gregor 5ed5ae476e 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.

llvm-svn: 79658
2009-08-21 18:42:58 +00:00
Mike Stump a002945a20 We now support overriding base functions in vtables. WIP.
llvm-svn: 79587
2009-08-21 01:45:00 +00:00
Argyrios Kyrtzidis 60ed560428 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.

llvm-svn: 79392
2009-08-19 01:27:57 +00:00
Eli Friedman c80ca68423 Fix test failure due to uninitialized member.
llvm-svn: 79145
2009-08-15 22:23:00 +00:00
Fariborz Jahanian bbd5e8c2cf More toward synthesizing copy assignments. SWIP.
llvm-svn: 78861
2009-08-12 23:34:46 +00:00
John McCall 2658c4e2d9 Add a FriendClassDecl type for holding declarations of friend types in
the AST, and create such declarations.

llvm-svn: 78719
2009-08-11 21:13:21 +00:00
Fariborz Jahanian b2197042b8 ir-gen support for anonymous union data member
copying in copy constructors and used in
default constructor's initializer list.

llvm-svn: 78700
2009-08-11 18:49:54 +00:00