[cfe-commits] r89895 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp test/CodeGenObjC/sel-as-builtin-type.m
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 25 15:07:43 PST 2009
Author: fjahanian
Date: Wed Nov 25 17:07:42 2009
New Revision: 89895
URL: http://llvm.org/viewvc/llvm-project?rev=89895&view=rev
Log:
Allow user re-definition of SEL as well as accessing its fields.
This fixes pr5611.
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenObjC/sel-as-builtin-type.m
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Nov 25 17:07:42 2009
@@ -243,7 +243,7 @@
// pseudo-builtins
QualType ObjCIdRedefinitionType;
QualType ObjCClassRedefinitionType;
- QualType ObjCSELRedefinitionType;
+ QualType ObjCSelRedefinitionType;
/// \brief Source ranges for all of the comments in the source file,
/// sorted in order of appearance in the translation unit.
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Nov 25 17:07:42 2009
@@ -48,7 +48,7 @@
BuiltinInfo(builtins), ExternalSource(0), PrintingPolicy(LOpts) {
ObjCIdRedefinitionType = QualType();
ObjCClassRedefinitionType = QualType();
- ObjCSELRedefinitionType = QualType();
+ ObjCSelRedefinitionType = QualType();
if (size_reserve > 0) Types.reserve(size_reserve);
TUDecl = TranslationUnitDecl::Create(*this);
InitBuiltinTypes();
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Nov 25 17:07:42 2009
@@ -1558,7 +1558,7 @@
// FIXME. Accommodate for this in several PCH/Index tests
if (unsigned ObjCSelRedef
= SpecialTypes[pch::SPECIAL_TYPE_OBJC_SEL_REDEFINITION])
- Context->ObjCSELRedefinitionType = GetType(ObjCSelRedef);
+ Context->ObjCSelRedefinitionType = GetType(ObjCSelRedef);
#endif
if (unsigned String = SpecialTypes[pch::SPECIAL_TYPE_BLOCK_DESCRIPTOR])
Context->setBlockDescriptorType(GetType(String));
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Nov 25 17:07:42 2009
@@ -1997,7 +1997,7 @@
AddTypeRef(Context.ObjCClassRedefinitionType, Record);
#if 0
// FIXME. Accommodate for this in several PCH/Indexer tests
- AddTypeRef(Context.ObjCSELRedefinitionType, Record);
+ AddTypeRef(Context.ObjCSelRedefinitionType, Record);
#endif
AddTypeRef(Context.getRawBlockdescriptorType(), Record);
AddTypeRef(Context.getRawBlockdescriptorExtendedType(), Record);
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Nov 25 17:07:42 2009
@@ -307,7 +307,7 @@
&Context.Idents.get("SEL"), SelInfo);
PushOnScopeChains(SelTypedef, TUScope);
Context.setObjCSelType(Context.getTypeDeclType(SelTypedef));
- Context.ObjCSELRedefinitionType = Context.getObjCSelType();
+ Context.ObjCSelRedefinitionType = Context.getObjCSelType();
}
// Synthesize "@class Protocol;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 25 17:07:42 2009
@@ -681,7 +681,7 @@
case 3:
if (!TypeID->isStr("SEL"))
break;
- Context.ObjCSELRedefinitionType = New->getUnderlyingType();
+ Context.ObjCSelRedefinitionType = New->getUnderlyingType();
// Install the built-in type for 'SEL', ignoring the current definition.
New->setTypeForDecl(Context.getObjCSelType().getTypePtr());
return;
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 25 17:07:42 2009
@@ -1937,6 +1937,16 @@
ImpCastExprToType(BaseExpr, BaseType, CastExpr::CK_BitCast);
}
}
+ // If this is an Objective-C pseudo-builtin and a definition is provided then
+ // use that.
+ if (Context.isObjCSelType(BaseType)) {
+ // We have an 'SEL' type. Rather than fall through, we check if this
+ // is a reference to 'sel_id'.
+ if (BaseType != Context.ObjCSelRedefinitionType) {
+ BaseType = Context.ObjCSelRedefinitionType;
+ ImpCastExprToType(BaseExpr, BaseType, CastExpr::CK_BitCast);
+ }
+ }
assert(!BaseType.isNull() && "no type for member expression");
// Handle properties on ObjC 'Class' types.
@@ -3440,6 +3450,17 @@
ImpCastExprToType(LHS, RHSTy, CastExpr::CK_BitCast);
return RHSTy;
}
+ // And the same for struct objc_selector* / SEL
+ if (Context.isObjCSelType(LHSTy) &&
+ (RHSTy.getDesugaredType() == Context.ObjCSelRedefinitionType)) {
+ ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast);
+ return LHSTy;
+ }
+ if (Context.isObjCSelType(RHSTy) &&
+ (LHSTy.getDesugaredType() == Context.ObjCSelRedefinitionType)) {
+ ImpCastExprToType(LHS, RHSTy, CastExpr::CK_BitCast);
+ return RHSTy;
+ }
// Handle block pointer types.
if (LHSTy->isBlockPointerType() || RHSTy->isBlockPointerType()) {
if (!LHSTy->isBlockPointerType() || !RHSTy->isBlockPointerType()) {
Modified: cfe/trunk/test/CodeGenObjC/sel-as-builtin-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/sel-as-builtin-type.m?rev=89895&r1=89894&r2=89895&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/sel-as-builtin-type.m (original)
+++ cfe/trunk/test/CodeGenObjC/sel-as-builtin-type.m Wed Nov 25 17:07:42 2009
@@ -17,3 +17,7 @@
}
@end
+int func(SEL s1, SEL s2)
+{
+ return s1->sel_id == s2->sel_id;
+}
More information about the cfe-commits
mailing list