[cfe-commits] r57298 - in /cfe/trunk: Driver/RewriteBlocks.cpp include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/AST/Expr.h lib/AST/Decl.cpp lib/AST/DeclBase.cpp lib/AST/DeclSerialization.cpp lib/AST/Expr.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtSerialization.cpp lib/Sema/SemaExpr.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Wed Oct 8 14:17:29 PDT 2008
Hi Steve,
Here's a couple of things needed so that BlockDecl <-> DeclContext
conversions work properly.
Steve Naroff wrote:
> + // Implement isa/cast/dyncast/etc.
> + static bool classof(const Decl *D) { return D->getKind() == Block; }
> + static bool classof(const TranslationUnitDecl *D) { return true; }
>
The second method should have BlockDecl parameter.
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=57298&r1=57297&r2=57298&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Wed Oct 8 12:01:13 2008
> @@ -27,6 +27,7 @@
> class EnumDecl;
> class ObjCMethodDecl;
> class ObjCInterfaceDecl;
> +class BlockDecl;
>
> /// Decl - This represents one declaration (or definition), e.g. a variable,
> /// typedef, function, struct, etc.
> @@ -81,6 +82,7 @@
> ObjCPropertyImpl,
> LinkageSpec,
> FileScopeAsm,
> + Block, // [DeclContext]
>
> // For each non-leaf class, we now define a mapping to the first/last member
> // of the class, to allow efficient classof.
> @@ -243,6 +245,7 @@
> /// EnumDecl
> /// ObjCMethodDecl
> /// ObjCInterfaceDecl
> +/// BlockDecl
> ///
> class DeclContext {
> /// DeclKind - This indicates which class this is.
> @@ -295,6 +298,7 @@
>
> bool isFunctionOrMethod() const {
> switch (DeclKind) {
> + case Decl::Block:
> case Decl::Function:
> case Decl::CXXMethod:
> case Decl::ObjCMethod:
> @@ -320,6 +324,7 @@
> case Decl::Enum:
> case Decl::ObjCMethod:
> case Decl::ObjCInterface:
> + case Decl::Block:
> return true;
> default:
> if (D->getKind() >= Decl::FunctionFirst &&
> @@ -339,6 +344,7 @@
> static bool classof(const EnumDecl *D) { return true; }
> static bool classof(const ObjCMethodDecl *D) { return true; }
> static bool classof(const ObjCInterfaceDecl *D) { return true; }
> + static bool classof(const BlockDecl *D) { return true; }
>
You should also add this line to the DeclContext::CastTo() template:
case Decl::Block:
return static_cast<BlockDecl*>(const_cast<From*>(D));
-Argiris
More information about the cfe-commits
mailing list