diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 15 | ||||
-rw-r--r-- | clang/lib/AST/Type.cpp | 6 |
2 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 44ff94e3584..384164167db 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4142,6 +4142,21 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const { } QualType ASTContext::getAdjustedParameterType(QualType T) const { + // In ARC, infer a lifetime qualifier for appropriate parameter types. + if (getLangOpts().ObjCAutoRefCount && + T.getObjCLifetime() == Qualifiers::OCL_None && + T->isObjCLifetimeType()) { + // Special cases for arrays: + // - if it's const, use __unsafe_unretained + // - otherwise, it's an error + Qualifiers::ObjCLifetime lifetime; + if (T->isArrayType()) + lifetime = Qualifiers::OCL_ExplicitNone; + else + lifetime = T->getObjCARCImplicitLifetime(); + T = getLifetimeQualifiedType(T, lifetime); + } + // C99 6.7.5.3p7: // A declaration of a parameter as "array of type" shall be // adjusted to "qualified pointer to type", where the type diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index c32df11b667..2c5233bce67 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1781,8 +1781,10 @@ bool TypeOfExprType::isSugared() const { } QualType TypeOfExprType::desugar() const { - if (isSugared()) - return getUnderlyingExpr()->getType(); + if (isSugared()) { + Expr *E = getUnderlyingExpr(); + return E->getType(); + } return QualType(this, 0); } |