[cfe-dev] How to use clang::ast_type_traits::DynTypedNode?

Jonathan Roelofs via cfe-dev cfe-dev at lists.llvm.org
Tue Feb 23 08:13:21 PST 2016



On 2/23/16 9:07 AM, victor via cfe-dev wrote:
> Thanks for answering, Manuel.
>
> However, your code didn't work:
>
>     clases_file.cpp:35:22: error: variable 'MD' with type 'const auto *'
>     has incompatible initializer of type 'const clang::CXXMethodDecl'
>     if (const auto* MD = llvm::dyn_cast<CXXMethodDecl>(pv[size-1])) {
>
>                                  ^
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You need to take the address of it as dyn_cast works on pointers, not 
references:

   if (const auto* MD = llvm::dyn_cast<CXXMethodDecl>(&pv[size-1])) {


Jon

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-dev mailing list