summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-05-19 17:08:59 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-05-19 17:08:59 +0000
commit960910a159f79ce3b42c9bb3998849694251a979 (patch)
tree65cdadfaa2c8dc7228c2165ec48e6e141da83ea1 /clang/lib/Sema/SemaDeclAttr.cpp
parent018958d94df01cfe29ab6fec49e64cf5af73679e (diff)
downloadbcm5719-llvm-960910a159f79ce3b42c9bb3998849694251a979.tar.gz
bcm5719-llvm-960910a159f79ce3b42c9bb3998849694251a979.zip
Patch finishes off application of printf attribute on blocks.
llvm-svn: 72111
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp13
1 files changed, 9 insertions, 4 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();
}
}
OpenPOWER on IntegriCloud