summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CastsAwayConstness shouldn't care if member pointers point into different ↵Sebastian Redl2009-11-181-1/+25
| | | | | | classes. Fixes PR5545. llvm-svn: 89215
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Set the cast kind for a few more code paths.Eli Friedman2009-11-161-2/+8
| | | | llvm-svn: 88893
* When performing a static downcast as part of a static_cast, make sureDouglas Gregor2009-11-151-12/+17
| | | | | | | | | | that we're dealing with canonical types like the documentation say (yay, CanQualType). Alas, this is another instance where using getQualifiers() on a non-canonical QualType got us in trouble. Good news: with this fix, Clang can now parse all of its own headers! llvm-svn: 88848
* - Have TryStaticImplicitCast set the cast kind to NoOp when binding a ↵Sebastian Redl2009-11-141-36/+39
| | | | | | | | | 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. llvm-svn: 88809
* When type-checking a static cast (or the static_cast part of a C-styleDouglas Gregor2009-11-141-0/+13
| | | | | | | | 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. llvm-svn: 88751
* Set CK_BaseToDerived in TryStaticDowncast.Anders Carlsson2009-11-121-10/+17
| | | | llvm-svn: 86996
* If we have a C-style cast, functional cast, or a static_cast to aDouglas Gregor2009-11-061-2/+2
| | | | | | | | | | 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
* Fixed two places where we needed to force completion of a typeDouglas Gregor2009-11-051-1/+2
| | | | | | | | | | | | (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
* Add a CK_DerivedToBaseMemberPointer cast kind and use it in Sema (Still no ↵Anders Carlsson2009-10-301-3/+5
| | | | | | codegen). llvm-svn: 85552
* Try to instantiate templates before doing hierarchy checks in static_cast. ↵Sebastian Redl2009-10-221-1/+6
| | | | | | Fixes PR5261. llvm-svn: 84860
* Set the cast kind to CK_NoOp for C-style casts that are really const casts. ↵Anders Carlsson2009-10-191-0/+3
| | | | | | Fixes PR5248. llvm-svn: 84514
* Use CK_BitCast for member function pointer casts. Fixes PR5138.Anders Carlsson2009-10-181-1/+5
| | | | llvm-svn: 84438
* Refactor the code that walks a C++ inheritance hierarchy, searchingDouglas Gregor2009-10-061-6/+7
| | | | | | | | | 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
* Patch to implement static casting which requires one Fariborz Jahanian2009-10-011-1/+2
| | | | | | user-defined type conversion. Fixes PR5040. llvm-svn: 83211
* Cast cleanup.Anders Carlsson2009-09-261-29/+31
| | | | llvm-svn: 82826
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-9/+10
| | | | | | | | 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
* Improve diagnostic location information when checking the initialization of ↵Douglas Gregor2009-09-231-0/+1
| | | | | | a reference llvm-svn: 82666
* Improve handling of vector casts in C++.Anders Carlsson2009-09-161-0/+26
| | | | llvm-svn: 82072
* Handle reinterpret_cast between integral types and pointer types.Anders Carlsson2009-09-151-7/+12
| | | | llvm-svn: 81837
* If a cast expression needs either a conversion function or a constructor to ↵Anders Carlsson2009-09-091-8/+32
| | | | | | be called, generate implicit child expressions that call them. llvm-svn: 81383
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-40/+27
| | | | llvm-svn: 81346
* Check that the destination type of a static_cast expression is a complete type.Anders Carlsson2009-09-071-0/+8
| | | | llvm-svn: 81151
* Use the correct cast kinds for bit casts and function to pointer decay. ↵Anders Carlsson2009-09-011-10/+17
| | | | | | Fixes PR4827. llvm-svn: 80720
* Allow explicit ctors for casts.Anders Carlsson2009-08-281-1/+1
| | | | llvm-svn: 80374
* Pass InOverloadResolution all the way down to IsPointerConversion.Anders Carlsson2009-08-281-1/+2
| | | | llvm-svn: 80368
* ir-gen related patch for type conversionFariborz Jahanian2009-08-281-14/+3
| | | | | | with class type conversion methods. WIP. llvm-svn: 80365
* Remove more default arguments.Anders Carlsson2009-08-271-1/+5
| | | | llvm-svn: 80260
* Remove default arguments from TryImplicitConversion and fix a bug found in ↵Anders Carlsson2009-08-271-2/+6
| | | | | | the process. llvm-svn: 80258
* Bye-bye old RequireCompleteType.Anders Carlsson2009-08-261-4/+5
| | | | llvm-svn: 80182
* ir-gen for type convesion of class objects. WIP.Fariborz Jahanian2009-08-261-0/+4
| | | | llvm-svn: 80178
* update to CXXFunctionalCastExpr to support ir-gen forFariborz Jahanian2009-08-261-11/+20
| | | | | | type convesions of class objects [class.conv]. WIP. llvm-svn: 80127
* Use Sema's LocInfoType to pass and preserve type source info through the Parser.Argyrios Kyrtzidis2009-08-191-1/+2
| | | | llvm-svn: 79395
* More CastKind work.Anders Carlsson2009-08-071-12/+14
| | | | llvm-svn: 78415
* Use the correct cast kind for dynamic_cast.Anders Carlsson2009-08-021-8/+11
| | | | llvm-svn: 77905
* Add a CastKind enum to CastExpr. Right now it's not used for much but it ↵Anders Carlsson2009-07-311-2/+4
| | | | | | will be :) llvm-svn: 77650
* Change uses of:Ted Kremenek2009-07-291-17/+17
| | | | | | | | | | | | | | | | | | | | 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
* Make functional-style casts emit correct messages, and fix a crash-on-invalid.Sebastian Redl2009-07-291-3/+3
| | | | llvm-svn: 77451
* Implement C++ semantics for C-style and functional-style casts. This ↵Sebastian Redl2009-07-251-507/+620
| | | | | | | | regresses Clang extension conversions, like vectors, but allows conversions via constructors and conversion operators. Add custom conversions to static_cast. llvm-svn: 77076
* Rename file in preparation of properly implementing C-style casts in C++.Sebastian Redl2009-07-181-0/+932
llvm-svn: 76318
OpenPOWER on IntegriCloud