aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/ASTContext.h56
-rw-r--r--lib/AST/ASTContext.cpp3
-rw-r--r--lib/CodeGen/CGObjCMac.cpp4
-rw-r--r--lib/Sema/Sema.cpp3
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--lib/Sema/SemaExpr.cpp18
-rw-r--r--lib/Sema/SemaExprMember.cpp9
7 files changed, 69 insertions, 30 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index bf4586a0aa..ed8d1c9101 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -195,6 +195,12 @@ class ASTContext : public llvm::RefCountedBase<ASTContext> {
/// ObjCClassType - another pseudo built-in typedef type (set by Sema).
QualType ObjCClassTypedefType;
+ // Typedefs which may be provided defining the structure of Objective-C
+ // pseudo-builtins
+ QualType ObjCIdRedefinitionType;
+ QualType ObjCClassRedefinitionType;
+ QualType ObjCSelRedefinitionType;
+
QualType ObjCConstantStringType;
mutable RecordDecl *CFConstantStringTypeDecl;
@@ -322,7 +328,9 @@ class ASTContext : public llvm::RefCountedBase<ASTContext> {
const LangAS::Map &AddrSpaceMap;
friend class ASTDeclReader;
-
+ friend class ASTReader;
+ friend class ASTWriter;
+
public:
const TargetInfo &Target;
IdentifierTable &Idents;
@@ -333,12 +341,6 @@ public:
ASTMutationListener *Listener;
clang::PrintingPolicy PrintingPolicy;
- // Typedefs which may be provided defining the structure of Objective-C
- // pseudo-builtins
- QualType ObjCIdRedefinitionType;
- QualType ObjCClassRedefinitionType;
- QualType ObjCSelRedefinitionType;
-
SourceManager& getSourceManager() { return SourceMgr; }
const SourceManager& getSourceManager() const { return SourceMgr; }
void *Allocate(unsigned Size, unsigned Align = 8) const {
@@ -821,6 +823,46 @@ public:
return ObjCConstantStringType;
}
+ /// \brief Retrieve the type that 'id' has been defined to, which may be
+ /// different from the built-in 'id' if 'id' has been typedef'd.
+ QualType getObjCIdRedefinitionType() const {
+ if (ObjCIdRedefinitionType.isNull())
+ return getObjCIdType();
+ return ObjCIdRedefinitionType;
+ }
+
+ /// \brief Set the user-written type that redefines 'id'.
+ void setObjCIdRedefinitionType(QualType RedefType) {
+ ObjCIdRedefinitionType = RedefType;
+ }
+
+ /// \brief Retrieve the type that 'Class' has been defined to, which may be
+ /// different from the built-in 'Class' if 'Class' has been typedef'd.
+ QualType getObjCClassRedefinitionType() const {
+ if (ObjCClassRedefinitionType.isNull())
+ return getObjCClassType();
+ return ObjCClassRedefinitionType;
+ }
+
+ /// \brief Set the user-written type that redefines 'SEL'.
+ void setObjCClassRedefinitionType(QualType RedefType) {
+ ObjCClassRedefinitionType = RedefType;
+ }
+
+ /// \brief Retrieve the type that 'SEL' has been defined to, which may be
+ /// different from the built-in 'SEL' if 'SEL' has been typedef'd.
+ QualType getObjCSelRedefinitionType() const {
+ if (ObjCSelRedefinitionType.isNull())
+ return getObjCSelType();
+ return ObjCSelRedefinitionType;
+ }
+
+
+ /// \brief Set the user-written type that redefines 'SEL'.
+ void setObjCSelRedefinitionType(QualType RedefType) {
+ ObjCSelRedefinitionType = RedefType;
+ }
+
/// \brief Set the type for the C FILE type.
void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index bbc66d2636..c4955721e9 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -235,9 +235,6 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
ExternalSource(0), Listener(0), PrintingPolicy(LOpts),
LastSDM(0, 0),
UniqueBlockByRefTypeID(0) {
- ObjCIdRedefinitionType = QualType();
- ObjCClassRedefinitionType = QualType();
- ObjCSelRedefinitionType = QualType();
if (size_reserve > 0) Types.reserve(size_reserve);
TUDecl = TranslationUnitDecl::Create(*this);
InitBuiltinTypes();
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 5553b20fa5..8badec9672 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1418,12 +1418,12 @@ llvm::Constant *CGObjCMac::GetEHType(QualType T) {
if (T->isObjCIdType() ||
T->isObjCQualifiedIdType()) {
return CGM.GetAddrOfRTTIDescriptor(
- CGM.getContext().ObjCIdRedefinitionType, /*ForEH=*/true);
+ CGM.getContext().getObjCIdRedefinitionType(), /*ForEH=*/true);
}
if (T->isObjCClassType() ||
T->isObjCQualifiedClassType()) {
return CGM.GetAddrOfRTTIDescriptor(
- CGM.getContext().ObjCClassRedefinitionType, /*ForEH=*/true);
+ CGM.getContext().getObjCClassRedefinitionType(), /*ForEH=*/true);
}
if (T->isObjCObjectPointerType())
return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true);
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index fb6049b18e..7451fa4391 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -95,7 +95,6 @@ void Sema::ActOnTranslationUnitScope(Scope *S) {
&Context.Idents.get("SEL"), SelInfo);
PushOnScopeChains(SelTypedef, TUScope);
Context.setObjCSelType(Context.getTypeDeclType(SelTypedef));
- Context.ObjCSelRedefinitionType = Context.getObjCSelType();
}
// Synthesize "@class Protocol;
@@ -118,7 +117,6 @@ void Sema::ActOnTranslationUnitScope(Scope *S) {
&Context.Idents.get("id"), IdInfo);
PushOnScopeChains(IdTypedef, TUScope);
Context.setObjCIdType(Context.getTypeDeclType(IdTypedef));
- Context.ObjCIdRedefinitionType = Context.getObjCIdType();
}
// Create the built-in typedef for 'Class'.
if (Context.getObjCClassType().isNull()) {
@@ -131,7 +129,6 @@ void Sema::ActOnTranslationUnitScope(Scope *S) {
&Context.Idents.get("Class"), ClassInfo);
PushOnScopeChains(ClassTypedef, TUScope);
Context.setObjCClassType(Context.getTypeDeclType(ClassTypedef));
- Context.ObjCClassRedefinitionType = Context.getObjCClassType();
}
}
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 542614ed9e..8fe2e54400 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1324,21 +1324,21 @@ void Sema::MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls) {
case 2:
if (!TypeID->isStr("id"))
break;
- Context.ObjCIdRedefinitionType = New->getUnderlyingType();
+ Context.setObjCIdRedefinitionType(New->getUnderlyingType());
// Install the built-in type for 'id', ignoring the current definition.
New->setTypeForDecl(Context.getObjCIdType().getTypePtr());
return;
case 5:
if (!TypeID->isStr("Class"))
break;
- Context.ObjCClassRedefinitionType = New->getUnderlyingType();
+ Context.setObjCClassRedefinitionType(New->getUnderlyingType());
// Install the built-in type for 'Class', ignoring the current definition.
New->setTypeForDecl(Context.getObjCClassType().getTypePtr());
return;
case 3:
if (!TypeID->isStr("SEL"))
break;
- Context.ObjCSelRedefinitionType = New->getUnderlyingType();
+ Context.setObjCSelRedefinitionType(New->getUnderlyingType());
// Install the built-in type for 'SEL', ignoring the current definition.
New->setTypeForDecl(Context.getObjCSelType().getTypePtr());
return;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 1f0e518afe..d78c4962a4 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4728,34 +4728,34 @@ QualType Sema::FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
// to the pseudo-builtin, because that will be implicitly cast back to the
// redefinition type if an attempt is made to access its fields.
if (LHSTy->isObjCClassType() &&
- (Context.hasSameType(RHSTy, Context.ObjCClassRedefinitionType))) {
+ (Context.hasSameType(RHSTy, Context.getObjCClassRedefinitionType()))) {
RHS = ImpCastExprToType(RHS.take(), LHSTy, CK_BitCast);
return LHSTy;
}
if (RHSTy->isObjCClassType() &&
- (Context.hasSameType(LHSTy, Context.ObjCClassRedefinitionType))) {
+ (Context.hasSameType(LHSTy, Context.getObjCClassRedefinitionType()))) {
LHS = ImpCastExprToType(LHS.take(), RHSTy, CK_BitCast);
return RHSTy;
}
// And the same for struct objc_object* / id
if (LHSTy->isObjCIdType() &&
- (Context.hasSameType(RHSTy, Context.ObjCIdRedefinitionType))) {
+ (Context.hasSameType(RHSTy, Context.getObjCIdRedefinitionType()))) {
RHS = ImpCastExprToType(RHS.take(), LHSTy, CK_BitCast);
return LHSTy;
}
if (RHSTy->isObjCIdType() &&
- (Context.hasSameType(LHSTy, Context.ObjCIdRedefinitionType))) {
+ (Context.hasSameType(LHSTy, Context.getObjCIdRedefinitionType()))) {
LHS = ImpCastExprToType(LHS.take(), RHSTy, CK_BitCast);
return RHSTy;
}
// And the same for struct objc_selector* / SEL
if (Context.isObjCSelType(LHSTy) &&
- (Context.hasSameType(RHSTy, Context.ObjCSelRedefinitionType))) {
+ (Context.hasSameType(RHSTy, Context.getObjCSelRedefinitionType()))) {
RHS = ImpCastExprToType(RHS.take(), LHSTy, CK_BitCast);
return LHSTy;
}
if (Context.isObjCSelType(RHSTy) &&
- (Context.hasSameType(LHSTy, Context.ObjCSelRedefinitionType))) {
+ (Context.hasSameType(LHSTy, Context.getObjCSelRedefinitionType()))) {
LHS = ImpCastExprToType(LHS.take(), RHSTy, CK_BitCast);
return RHSTy;
}
@@ -5340,7 +5340,8 @@ Sema::CheckAssignmentConstraints(QualType lhsType, ExprResult &rhs,
// - conversions from 'Class' to the redefinition type
if (rhsType->isObjCClassType() &&
- Context.hasSameType(lhsType, Context.ObjCClassRedefinitionType)) {
+ Context.hasSameType(lhsType,
+ Context.getObjCClassRedefinitionType())) {
Kind = CK_BitCast;
return Compatible;
}
@@ -5421,7 +5422,8 @@ Sema::CheckAssignmentConstraints(QualType lhsType, ExprResult &rhs,
// - conversions to 'Class' from its redefinition type
if (lhsType->isObjCClassType() &&
- Context.hasSameType(rhsType, Context.ObjCClassRedefinitionType)) {
+ Context.hasSameType(rhsType,
+ Context.getObjCClassRedefinitionType())) {
Kind = CK_BitCast;
return Compatible;
}
diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp
index cde29f5b4c..0fd654b479 100644
--- a/lib/Sema/SemaExprMember.cpp
+++ b/lib/Sema/SemaExprMember.cpp
@@ -953,9 +953,9 @@ static bool ShouldTryAgainWithRedefinitionType(Sema &S, ExprResult &base) {
QualType redef;
if (ty->isObjCId()) {
- redef = S.Context.ObjCIdRedefinitionType;
+ redef = S.Context.getObjCIdRedefinitionType();
} else if (ty->isObjCClass()) {
- redef = S.Context.ObjCClassRedefinitionType;
+ redef = S.Context.getObjCClassRedefinitionType();
} else {
return false;
}
@@ -1322,8 +1322,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
// not just a pointer to builtin-sel again.
if (IsArrow &&
BaseType->isSpecificBuiltinType(BuiltinType::ObjCSel) &&
- !Context.ObjCSelRedefinitionType->isObjCSelType()) {
- BaseExpr = ImpCastExprToType(BaseExpr.take(), Context.ObjCSelRedefinitionType,
+ !Context.getObjCSelRedefinitionType()->isObjCSelType()) {
+ BaseExpr = ImpCastExprToType(BaseExpr.take(),
+ Context.getObjCSelRedefinitionType(),
CK_BitCast);
return LookupMemberExpr(R, BaseExpr, IsArrow, OpLoc, SS,
ObjCImpDecl, HasTemplateArgs);