summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp12
-rw-r--r--clang/lib/AST/Decl.cpp9
-rw-r--r--clang/lib/AST/DeclSerialization.cpp3
3 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d03ed41a152..791e38633b4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1638,11 +1638,17 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
// Argument types.
ParmOffset = 2 * PtrSize;
for (int i = 0; i < NumOfParams; i++) {
- QualType PType = Decl->getParamDecl(i)->getType();
+ ParmVarDecl *PVDecl = Decl->getParamDecl(i);
+ QualType PType = PVDecl->getOriginalType();
+ if (const ArrayType *AT =
+ dyn_cast<ArrayType>(PType->getCanonicalTypeInternal()))
+ // Use array's original type only if it has known number of
+ // elements.
+ if (!dyn_cast<ConstantArrayType>(AT))
+ PType = PVDecl->getType();
// Process argument qualifiers for user supplied arguments; such as,
// 'in', 'inout', etc.
- getObjCEncodingForTypeQualifier(
- Decl->getParamDecl(i)->getObjCDeclQualifier(), S);
+ getObjCEncodingForTypeQualifier(PVDecl->getObjCDeclQualifier(), S);
getObjCEncodingForType(PType, S);
S += llvm::utostr(ParmOffset);
ParmOffset += getObjCEncodingTypeSize(PType);
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 021becc85a2..3edf8a02efb 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -54,7 +54,14 @@ ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
QualType T, StorageClass S,
Expr *DefArg, ScopedDecl *PrevDecl) {
void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
- return new (Mem) ParmVarDecl(DC, L, Id, T, S, DefArg, PrevDecl);
+ return new (Mem) ParmVarDecl(ParmVar, DC, L, Id, T, S, DefArg, PrevDecl);
+}
+
+QualType ParmVarDecl::getOriginalType() const {
+ if (const ParmVarWithOriginalTypeDecl *PVD =
+ dyn_cast<ParmVarWithOriginalTypeDecl>(this))
+ return PVD->OriginalType;
+ return getType();
}
ParmVarWithOriginalTypeDecl *ParmVarWithOriginalTypeDecl::Create(
diff --git a/clang/lib/AST/DeclSerialization.cpp b/clang/lib/AST/DeclSerialization.cpp
index c09b0edca7b..7f6b50420d9 100644
--- a/clang/lib/AST/DeclSerialization.cpp
+++ b/clang/lib/AST/DeclSerialization.cpp
@@ -399,7 +399,8 @@ void ParmVarDecl::EmitImpl(llvm::Serializer& S) const {
ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
ParmVarDecl* decl = new (Mem)
- ParmVarDecl(0, SourceLocation(), NULL, QualType(), None, NULL, NULL);
+ ParmVarDecl(ParmVar,
+ 0, SourceLocation(), NULL, QualType(), None, NULL, NULL);
decl->VarDecl::ReadImpl(D, C);
decl->objcDeclQualifier = static_cast<ObjCDeclQualifier>(D.ReadInt());
OpenPOWER on IntegriCloud