Commit Graph

185 Commits

Author SHA1 Message Date
Douglas Gregor ad8a336b40 Implement AST, semantics, and CodeGen for C++ pseudo-destructor
expressions, e.g.,

  p->~T()

when p is a pointer to a scalar type. 

We don't currently diagnose errors when pseudo-destructor expressions
are used in any way other than by forming a call.

llvm-svn: 81009
2009-09-04 17:36:40 +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
Douglas Gregor 2b6ca46c6b Improve template instantiation for member access expressions that
involve qualified names, e.g., x->Base::f. We now maintain enough
information in the AST to compare the results of the name lookup of
"Base" in the scope of the postfix-expression (determined at template
definition time) and in the type of the object expression.

llvm-svn: 80953
2009-09-03 21:38:09 +00:00
Douglas Gregor b7bfe79412 Rewrite of our handling of name lookup in C++ member access expressions, e.g.,
x->Base::f

We no longer try to "enter" the context of the type that "x" points
to. Instead, we drag that object type through the parser and pass it
into the Sema routines that need to know how to perform lookup within
member access expressions.

We now implement most of the crazy name lookup rules in C++
[basic.lookup.classref] for non-templated code, including performing
lookup both in the context of the type referred to by the member
access and in the scope of the member access itself and then detecting
ambiguities when the two lookups collide (p1 and p4; p3 and p7 are
still TODO). This change also corrects our handling of name lookup
within template arguments of template-ids inside the
nested-name-specifier (p6; we used to look into the scope of the
object expression for them) and fixes PR4703.

I have disabled some tests that involve member access expressions
where the object expression has dependent type, because we don't yet
have the ability to describe dependent nested-name-specifiers starting
with an identifier.

llvm-svn: 80843
2009-09-02 22:59:36 +00:00
Anders Carlsson 6904f644e7 Add a CK_FunctionToPointerDecay cast kind.
llvm-svn: 80719
2009-09-01 20:37:18 +00:00
Douglas Gregor 84f14dd674 Preliminary AST representation and semantic analysis for
explicitly-specified template argument lists in member reference
expressions, e.g.,

  x->f<int>()

llvm-svn: 80646
2009-09-01 00:37:14 +00:00
Douglas Gregor fbc1823451 Add parsing for references to member function templates with explicit
template argument lists, e.g., x.f<int>().

Semantic analysis will be a separate commit.

llvm-svn: 80624
2009-08-31 21:16:32 +00:00
Douglas Gregor 522fbc4969 Support explicit C++ member operator syntax, from James Porter!
llvm-svn: 80608
2009-08-31 19:52:13 +00:00
Fariborz Jahanian 3df8767869 Patch for code gen. for c-style cast which ends in
using class's conversion functions [12.3.2-p2]

llvm-svn: 80433
2009-08-29 19:15:16 +00:00
Fariborz Jahanian 2fee79a9a1 path to ir-gen 12.3.1 Conversion by constructor
llvm-svn: 80398
2009-08-28 22:04:50 +00:00
Anders Carlsson 228eea36a3 Pass InOverloadResolution all the way down to IsPointerConversion.
llvm-svn: 80368
2009-08-28 15:33:32 +00:00
Fariborz Jahanian 8b899e4247 ir-gen related patch for type conversion
with class type conversion methods. WIP.

llvm-svn: 80365
2009-08-28 15:11:24 +00:00
Anders Carlsson 20d1332d76 Add an InOverloadResolution flag to TryCopyInitialization.
llvm-svn: 80261
2009-08-27 17:37:39 +00:00
Anders Carlsson 271e3a4d47 Remove more default arguments.
llvm-svn: 80260
2009-08-27 17:30:43 +00:00
Anders Carlsson ef4c72135f Remove default arguments from TryImplicitConversion and fix a bug found in the process.
llvm-svn: 80258
2009-08-27 17:24:15 +00:00
Anders Carlsson 03068aa077 Remove default argument from TryCopyInitialization.
llvm-svn: 80256
2009-08-27 17:18:13 +00:00
Anders Carlsson 5ec4abf268 Revert the flags change for now, I have a better idea for this.
llvm-svn: 80255
2009-08-27 17:14:02 +00:00
Anders Carlsson 2f7e956f16 Add a OverloadResolutionFlags and start converting some of the overload methods over to using it instead of bools arguments.
llvm-svn: 80248
2009-08-27 16:01:18 +00:00
Anders Carlsson 574315a0fa Add a BuildCXXTemporaryObjectExpr and use it so default arguments will be instantiated correctly for temporary object expressions.
llvm-svn: 80206
2009-08-27 05:08:22 +00:00
Anders Carlsson 55243168df In ActOnCXXTypeConstructExpr, check that the type is complete and non-abstract before creating any expressions. This assures that any templates are instantiated if necessary.
llvm-svn: 80200
2009-08-27 03:53:50 +00:00
Anders Carlsson d624e16833 Bye-bye old RequireCompleteType.
llvm-svn: 80182
2009-08-26 23:45:07 +00:00
Anders Carlsson 029fc690d3 Remove the PrintType argument from RequireCompleteType.
llvm-svn: 80174
2009-08-26 22:59:12 +00:00
Fariborz Jahanian d79d5053bd AST for conversion by conversion functions. WIP.
llvm-svn: 80135
2009-08-26 20:34:58 +00:00
Anders Carlsson c24fc2949e More support for pseudo dtors.
llvm-svn: 80129
2009-08-26 19:22:42 +00:00
Fariborz Jahanian 1cec0c4c94 update to CXXFunctionalCastExpr to support ir-gen for
type convesions of class objects [class.conv]. WIP.

llvm-svn: 80127
2009-08-26 18:55:36 +00:00
Anders Carlsson e7b9d71aab Address some of Doug's comments.
llvm-svn: 80114
2009-08-26 17:36:19 +00:00
Anders Carlsson 7e3f0e4e0d Parsing of pseudo-destructors.
llvm-svn: 80055
2009-08-25 23:46:41 +00:00
Anders Carlsson 6eb55575da BuildCXXConstructExpr now returns an OwningExprResult.
llvm-svn: 79975
2009-08-25 05:12:04 +00:00
Douglas Gregor b00b10eb2e Implement support for equality comparisons (!=, ==) of member
pointers, by extending the "composite pointer type" logic to include
member pointer types.

Introduce test cases for member pointer comparisons, including those
that involve the builtin operator candidates implemented earlier. 

llvm-svn: 79925
2009-08-24 17:42:35 +00:00
Anders Carlsson d7923c6ed7 Add CK_NullToMemberPointer and CK_BaseToDerivedMemberPointer cast kinds. Make -ast-dump print out the cast kinds of cast expressions.
llvm-svn: 79787
2009-08-22 23:33:40 +00:00
Argyrios Kyrtzidis 6032ef1aa3 Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use DeclaratorInfo to get this information.
llvm-svn: 79584
2009-08-21 00:31:54 +00:00
Argyrios Kyrtzidis c7148c974d Use Sema's LocInfoType to pass and preserve type source info through the Parser.
llvm-svn: 79395
2009-08-19 01:28:28 +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
Anders Carlsson a471db0dd4 Store the delete operator for delete expressions.
llvm-svn: 79200
2009-08-16 20:29:29 +00:00
Anders Carlsson 250aada4b9 AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and create the CXXExprWithTemporaries before setting the initializer on the VarDecl.
llvm-svn: 79176
2009-08-16 05:13:48 +00:00
Anders Carlsson f86a8d1030 BuildCXXConstructExpr doesn't need to take an ASTContext.
llvm-svn: 79149
2009-08-15 23:41:35 +00:00
Argyrios Kyrtzidis ae438f8c03 Check whether a tag was defined in a C++ condition declaration using GetTypeForDeclarator.
llvm-svn: 78644
2009-08-11 05:20:41 +00:00
Anders Carlsson 2c101b3cd1 Use CastExpr::CK_ArrayToPointerDecay and fix an assert.
llvm-svn: 78502
2009-08-08 21:04:35 +00:00
Anders Carlsson f10e414e4e More CastKind work.
llvm-svn: 78415
2009-08-07 22:21:05 +00:00
Fariborz Jahanian 001309371e Set and use Elidable in elimination of copy ctors.
llvm-svn: 78331
2009-08-06 19:12:38 +00:00
Fariborz Jahanian aa890bf2f3 Patch to improve ir-gen for constructors with default argument
expressions and a test case.

llvm-svn: 78213
2009-08-05 17:03:54 +00:00
Douglas Gregor 2211d345d2 Introduce the canonical type smart pointers, and use them in a few places to
tighten up the static type system.

llvm-svn: 78164
2009-08-05 05:36:45 +00:00
Mike Stump 12b8ce168d Canonicalize else.
llvm-svn: 78102
2009-08-04 21:02:39 +00:00
Fariborz Jahanian 6782844874 Minor renaming/refactoring. No change in functionality.
llvm-svn: 77985
2009-08-03 19:13:25 +00:00
Anders Carlsson a076d14514 Add CK_DerivedToBase and use it PerformObjectMemberConversion.
llvm-svn: 77652
2009-07-31 01:23:52 +00:00
Anders Carlsson a26159261c Add a CastKind enum to CastExpr. Right now it's not used for much but it will be :)
llvm-svn: 77650
2009-07-31 00:48:10 +00:00
Ted Kremenek c23c7e6a51 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.

llvm-svn: 77510
2009-07-29 21:53:49 +00:00
Sebastian Redl 955a067bdd Make functional-style casts emit correct messages, and fix a crash-on-invalid.
llvm-svn: 77451
2009-07-29 13:50:23 +00:00
Ted Kremenek 8a286fbdb9 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.

llvm-svn: 76193
2009-07-17 17:50:17 +00:00
Ted Kremenek b825c0ddc5 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
llvm-svn: 76139
2009-07-17 01:20:38 +00:00