summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp13
-rw-r--r--clang/lib/Sema/SemaExpr.cpp2
2 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 2c2e4d3c0f1..c5099319ddb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -64,7 +64,7 @@ static bool isFunctionOrMethodOrBlock(Decl *d) {
QualType Ty = V->getType();
return Ty->isBlockPointerType();
}
- return false;
+ return isa<BlockDecl>(d);
}
/// hasFunctionProto - Return true if the given decl has a argument
@@ -74,7 +74,7 @@ static bool hasFunctionProto(Decl *d) {
if (const FunctionType *FnTy = getFunctionType(d))
return isa<FunctionProtoType>(FnTy);
else {
- assert(isa<ObjCMethodDecl>(d));
+ assert(isa<ObjCMethodDecl>(d) || isa<BlockDecl>(d));
return true;
}
}
@@ -85,13 +85,16 @@ static bool hasFunctionProto(Decl *d) {
static unsigned getFunctionOrMethodNumArgs(Decl *d) {
if (const FunctionType *FnTy = getFunctionType(d))
return cast<FunctionProtoType>(FnTy)->getNumArgs();
+ if (const BlockDecl *BD = dyn_cast<BlockDecl>(d))
+ return BD->getNumParams();
return cast<ObjCMethodDecl>(d)->param_size();
}
static QualType getFunctionOrMethodArgType(Decl *d, unsigned Idx) {
if (const FunctionType *FnTy = getFunctionType(d))
return cast<FunctionProtoType>(FnTy)->getArgType(Idx);
-
+ if (const BlockDecl *BD = dyn_cast<BlockDecl>(d))
+ return BD->getParamDecl(Idx)->getType();
return cast<ObjCMethodDecl>(d)->param_begin()[Idx]->getType();
}
@@ -100,7 +103,9 @@ static bool isFunctionOrMethodVariadic(Decl *d) {
if (const FunctionType *FnTy = getFunctionType(d)) {
const FunctionProtoType *proto = cast<FunctionProtoType>(FnTy);
return proto->isVariadic();
- } else {
+ } else if (const BlockDecl *BD = dyn_cast<BlockDecl>(d))
+ return BD->IsVariadic();
+ else {
return cast<ObjCMethodDecl>(d)->isVariadic();
}
}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ed62b254d56..3f99c684b89 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5140,7 +5140,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
}
CurBlock->TheDecl->setParams(Context, &CurBlock->Params[0],
CurBlock->Params.size());
-
+ CurBlock->TheDecl->setIsVariadic(CurBlock->isVariadic);
ProcessDeclAttributes(CurBlock->TheDecl, ParamInfo);
for (BlockDecl::param_iterator AI = CurBlock->TheDecl->param_begin(),
E = CurBlock->TheDecl->param_end(); AI != E; ++AI)
OpenPOWER on IntegriCloud