Commit Graph

83 Commits

Author SHA1 Message Date
Douglas Gregor ad8b22269e If we have a C-style cast, functional cast, or a static_cast to a
class type, don't perform the array-to-pointer or function-to-pointer
conversions, because we may end up binding a reference to a function
or array.

With this change, FileCheck now passes -fsyntax-only!

llvm-svn: 86211
2009-11-06 01:14:41 +00:00
Douglas Gregor 3ec1bf240d 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!

llvm-svn: 86129
2009-11-05 13:06:35 +00:00
Anders Carlsson 3f0db2beb1 Add a CK_DerivedToBaseMemberPointer cast kind and use it in Sema (Still no codegen).
llvm-svn: 85552
2009-10-30 00:46:35 +00:00
Sebastian Redl 802f14ccde Try to instantiate templates before doing hierarchy checks in static_cast. Fixes PR5261.
llvm-svn: 84860
2009-10-22 15:07:22 +00:00
Anders Carlsson 027732b5b9 Set the cast kind to CK_NoOp for C-style casts that are really const casts. Fixes PR5248.
llvm-svn: 84514
2009-10-19 18:14:28 +00:00
Anders Carlsson 9500ad13b0 Use CK_BitCast for member function pointer casts. Fixes PR5138.
llvm-svn: 84438
2009-10-18 20:31:03 +00:00
Douglas Gregor 36d1b14dde 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.

llvm-svn: 83396
2009-10-06 17:59:45 +00:00
Fariborz Jahanian b3c44f9ee9 Patch to implement static casting which requires one
user-defined type conversion. Fixes PR5040.

llvm-svn: 83211
2009-10-01 20:39:51 +00:00
Anders Carlsson 9d1b34ba81 Cast cleanup.
llvm-svn: 82826
2009-09-26 00:12:34 +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
Douglas Gregor c809cc2efa Improve diagnostic location information when checking the initialization of a reference
llvm-svn: 82666
2009-09-23 23:04:10 +00:00
Anders Carlsson 570af5d426 Improve handling of vector casts in C++.
llvm-svn: 82072
2009-09-16 19:19:43 +00:00
Anders Carlsson 7cd39e0721 Handle reinterpret_cast between integral types and pointer types.
llvm-svn: 81837
2009-09-15 04:48:33 +00:00
Anders Carlsson e9766d559b If a cast expression needs either a conversion function or a constructor to be called, generate implicit child expressions that call them.
llvm-svn: 81383
2009-09-09 21:33:21 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Anders Carlsson 85ec4ffaf5 Check that the destination type of a static_cast expression is a complete type.
llvm-svn: 81151
2009-09-07 18:25:47 +00:00
Anders Carlsson f1ae6d45dd Use the correct cast kinds for bit casts and function to pointer decay. Fixes PR4827.
llvm-svn: 80720
2009-09-01 20:52:42 +00:00
Anders Carlsson f2bc7c386e Allow explicit ctors for casts.
llvm-svn: 80374
2009-08-28 16:22:20 +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 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 d624e16833 Bye-bye old RequireCompleteType.
llvm-svn: 80182
2009-08-26 23:45:07 +00:00
Fariborz Jahanian c71f094c08 ir-gen for type convesion of class objects. WIP.
llvm-svn: 80178
2009-08-26 23:31:30 +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
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
Anders Carlsson f10e414e4e More CastKind work.
llvm-svn: 78415
2009-08-07 22:21:05 +00:00
Anders Carlsson 4ab4f7f416 Use the correct cast kind for dynamic_cast.
llvm-svn: 77905
2009-08-02 19:07:59 +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
Sebastian Redl 9f831dbbcd Implement C++ semantics for C-style and functional-style casts. This regresses Clang extension conversions, like vectors, but allows conversions via constructors and conversion operators.
Add custom conversions to static_cast.

llvm-svn: 77076
2009-07-25 15:41:38 +00:00
Sebastian Redl 3a0ae12162 Rename file in preparation of properly implementing C-style casts in C++.
llvm-svn: 76318
2009-07-18 15:08:18 +00:00