Commit Graph

183 Commits

Author SHA1 Message Date
Douglas Gregor d2e6a45722 When qualified lookup into the current instantiation fails (because it
finds nothing), and the current instantiation has dependent base
classes, treat the qualified lookup as if it referred to an unknown
specialization. Fixes PR6031.

llvm-svn: 93433
2010-01-14 17:47:39 +00:00
Douglas Gregor a318efd1f2 Improve key-function computation for templates. In particular:
- All classes can have a key function; templates don't change that.
  non-template classes when computing the key function.
  - We always mark all of the virtual member functions of class
  template instantiations. 
  - The vtable for an instantiation of a class template has weak
  linkage. 

We could probably use available_externally linkage for vtables of
classes instantiated by explicit instantiation declarations (extern
templates), but GCC doesn't do this and I'm not 100% that the ABI
permits it.

llvm-svn: 92753
2010-01-05 19:06:31 +00:00
Douglas Gregor 507eb87f05 Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, since the context is available in the Decl
llvm-svn: 91862
2009-12-22 00:34:07 +00:00
John McCall 90d3bb943e Patch over yet more problems with friend declarations which were provoking
problems on LLVM-Code-Syntax.  This proved remarkably easy to "fix" once
I settled on how I was going to approach it.

llvm-svn: 91633
2009-12-17 23:21:11 +00:00
Anders Carlsson 27cfc6e144 getTemplateSpecializationKind should be const.
llvm-svn: 90750
2009-12-07 06:33:48 +00:00
John McCall bcd035061d DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated variables,
but the results are imperfect.

For posterity, I did:

cat <<EOF > $cmdfile
s/DeclaratorInfo/TypeSourceInfo/g
s/DInfo/TInfo/g
s/TypeTypeSourceInfo/TypeSourceInfo/g
s/SourceTypeSourceInfo/TypeSourceInfo/g
EOF

find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \;
find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \;
find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \;

llvm-svn: 90743
2009-12-07 02:54:59 +00:00
Eli Friedman 71a26d8f82 Move helper onto CXXMethodDecl.
llvm-svn: 90716
2009-12-06 20:50:05 +00:00
Anders Carlsson f3935b4d4b Make sure that overridden method decls are always canonical.
llvm-svn: 90542
2009-12-04 05:51:56 +00:00
Fariborz Jahanian 6dfc1978ac A new helper function to set various bits in the class when
a new virtual function is declared/instantiated. it is used
in couple of places.

llvm-svn: 90470
2009-12-03 18:44:40 +00:00
Douglas Gregor c8c44b5d67 Improve source location information for C++ member initializers in a
constructor, by keeping the DeclaratorInfo* rather than just the type
and a single location.

llvm-svn: 90355
2009-12-02 22:36:29 +00:00
Anders Carlsson f98849eb8a In Sema, whenever we think that a function is going to cause a vtable to be generated, we mark any virtual implicit member functions as referenced.
llvm-svn: 90327
2009-12-02 17:15:43 +00:00
John McCall 3d988d9042 r90313, in which OverloadedFunctionDecl is removed and never spoken of again.
llvm-svn: 90313
2009-12-02 08:47:38 +00:00
Sebastian Redl a6602e9e2a Let using directives refer to namespace aliases. Fixes PR5479.
llvm-svn: 89657
2009-11-23 15:34:23 +00:00
John McCall d14a86427f "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.

llvm-svn: 89544
2009-11-21 08:51:07 +00:00
John McCall e61f2ba7e4 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.

llvm-svn: 89184
2009-11-18 02:36:19 +00:00
John McCall 3f746828d7 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.

llvm-svn: 89048
2009-11-17 05:59:44 +00:00
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