r209970 - Support C++11 scoped enums in NamedDecl::isCXXClassMember()

Alp Toker alp at nuanti.com
Fri May 30 23:32:30 PDT 2014


On 31/05/2014 09:11, Alp Toker wrote:
> Author: alp
> Date: Sat May 31 01:11:09 2014
> New Revision: 209970
>
> URL: http://llvm.org/viewvc/llvm-project?rev=209970&view=rev
> Log:
> Support C++11 scoped enums in NamedDecl::isCXXClassMember()
>
> Resolves an old FIXME.
>
> No callers depend on this giving the right answer so I haven't been able to
> cook up a useful test case.
>
> Modified:
>      cfe/trunk/include/clang/AST/Decl.h
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=209970&r1=209969&r2=209970&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Sat May 31 01:11:09 2014
> @@ -204,9 +204,8 @@ public:
>       // C++0x [class.mem]p1:
>       //   The enumerators of an unscoped enumeration defined in
>       //   the class are members of the class.
> -    // FIXME: support C++0x scoped enumerations.
>       if (isa<EnumDecl>(DC))
> -      DC = DC->getParent();
> +      DC = DC->getRedeclContext();
>   
>       return DC->isRecord();
>     }

This function can actually be simplified further to:

   bool isCXXClassMember() const {
     return getDeclContext()->getRedeclContext()->isRecord();
   }

But I've kept the isa<EnumDecl>() special-case to avoid any performance 
hit -- feedback from optimizer folks welcome.

Alp.


-- 
http://www.nuanti.com
the browser experts




More information about the cfe-commits mailing list