summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-06-08 17:28:56 +0000
committerReid Kleckner <reid@kleckner.net>2013-06-08 17:28:56 +0000
commit4c124ffd5b05cf6a5c77a966a5e0b0df91274c1b (patch)
treedae935e3c824a870373e1e7a8b86f8d53c61bf08 /clang/lib/AST/ASTContext.cpp
parent7dae9ce02132c1472db3e8a0cde56412ba39324c (diff)
downloadbcm5719-llvm-4c124ffd5b05cf6a5c77a966a5e0b0df91274c1b.tar.gz
bcm5719-llvm-4c124ffd5b05cf6a5c77a966a5e0b0df91274c1b.zip
[Sema] Make FunctionType's TSI use unadjusted argument types
This helps preserve the type-as-written in the AST, which we need for MSVC mangling. In particular, we need to preserve the types of array parameters in function pointer types. The essence of this change is: - QualType ArgTy = Param->getType(); + QualType ArgTy = Param->getTypeSourceInfo()->getType(); ... followed by the adjustment in ActOnFunctionDeclarator(). Differential Revision: http://llvm-reviews.chandlerc.com/D883 llvm-svn: 183614
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp15
1 files changed, 15 insertions, 0 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
OpenPOWER on IntegriCloud