[cfe-commits] r135001 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Sema/SemaObjCProperty.cpp test/SemaObjCXX/property-type-mismatch.mm
Eli Friedman
eli.friedman at gmail.com
Tue Jul 12 15:59:39 PDT 2011
On Tue, Jul 12, 2011 at 3:54 PM, jahanian <fjahanian at apple.com> wrote:
>
> On Jul 12, 2011, at 3:27 PM, Eli Friedman wrote:
>
> On Tue, Jul 12, 2011 at 3:05 PM, Fariborz Jahanian <fjahanian at apple.com>
> wrote:
>
> Author: fjahanian
>
> Date: Tue Jul 12 17:05:16 2011
>
> New Revision: 135001
>
> URL: http://llvm.org/viewvc/llvm-project?rev=135001&view=rev
>
> Log:
>
> objc++: Some level of covariance is allowed in ObjC properties.
>
> Make it also available in ObjC++ propeties. // rdar://9740328
>
> Added:
>
> cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm
>
> Modified:
>
> cfe/trunk/include/clang/AST/ASTContext.h
>
> cfe/trunk/lib/AST/ASTContext.cpp
>
> cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=135001&r1=135000&r2=135001&view=diff
>
> ==============================================================================
>
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>
> +++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jul 12 17:05:16 2011
>
> @@ -1417,6 +1417,7 @@
>
> bool typesAreCompatible(QualType T1, QualType T2,
>
> bool CompareUnqualified = false); // C99 6.2.7p1
>
> + bool propertyTypesAreCompatible(QualType, QualType);
>
> bool typesAreBlockPointerCompatible(QualType, QualType);
>
> bool isObjCIdType(QualType T) const {
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
>
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=135001&r1=135000&r2=135001&view=diff
>
> ==============================================================================
>
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>
> +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 12 17:05:16 2011
>
> @@ -5441,6 +5441,10 @@
>
> return !mergeTypes(LHS, RHS, false, CompareUnqualified).isNull();
>
> }
>
> +bool ASTContext::propertyTypesAreCompatible(QualType LHS, QualType RHS) {
>
> + return !mergeTypes(LHS, RHS, false, false).isNull();
>
> +}
>
> Using mergeTypes in C++ is generally a bad idea... it's fundamentally
> implementing C semantics that don't make sense in C++, and it has
> assertions which are easy to trigger in C++.
>
> It is being used in several places for c and c++. Comment at the very top of
> that routine suggests that caller
> may come from c++ land.
Ancient history, from before we had proper C++ semantics. At least in
the regression tests, the only use I can find is the test you just
committed. It'd be a good idea to add an assertion at the top of
mergeTypes.
> Properties are in the domain of objective-c. So, I
> doubt any c++ specific type
> can trigger an assert and be usable as a property type. But, I can be
> convinced with an example.
class CC;
@protocol P1;
@interface NSObject
@end
@interface A : NSObject
@property (assign) int CC::* prop;
@end
@protocol P2 <P1>
@end
@interface B : A
@property (assign) long CC::* prop;
@end
-Eli
More information about the cfe-commits
mailing list