From 420d9a7a5e7d99450947a8ac27a889eada320460 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 14 Aug 2009 20:51:58 +0000 Subject: Use 'dyn_cast' instead of a check for a function declaration followed by a 'cast'. llvm-svn: 79041 --- clang/lib/Sema/SemaDeclAttr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaDeclAttr.cpp') diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 4952e629001..e65b3aa6fdf 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -438,13 +438,14 @@ static void HandleMallocAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } - if (!isFunction(d)) { + const FunctionDecl *FD = dyn_cast(d); + + if (!FD) { S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << Attr.getName() << 0 /*function*/; return; } - const FunctionDecl *FD = cast(d); QualType RetTy = FD->getResultType(); if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) { -- cgit v1.2.3