[cfe-commits] r49547 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/AST/DeclObjC.h lib/AST/Decl.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Fri Apr 11 16:19:33 PDT 2008


Just a tiny suggestion, If I may..

> +#define CASE(KIND) case KIND: cast<KIND##Decl>(this)->~KIND##Decl(); break
> +
>  void Decl::Destroy(ASTContext& C) const {
> +  switch (getKind()) {
> +  CASE(Field);
> +  CASE(ObjCIvar);
> +  CASE(ObjCCategory);
>   

Since you check 'Kind', you are safe to cast using static_cast:

+#define CASE(KIND) case KIND: static_cast<KIND##Decl*>(this)->~KIND##Decl(); break

avoids using the extra check from the cast<> template.
The same for:

> +  case Struct: case Union: case Class:
> +    cast<RecordDecl>(this)->~RecordDecl();
> +    break;

-Argiris



More information about the cfe-commits mailing list