<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Jonathan,<br><br>Something is failing. I have this:<br><br>ArrayRef<ast_type_traits::DynTypedNode> pv = Context->getParents<MemberExpr>(*member);<br><br>size_t size = pv.size();<br> <br>if(size > 0){<br> if (const auto* MD = llvm::dyn_cast<CXXMethodDecl>(&pv[size-1])) {}<br>}<br><br>The compiler says:<br><br>/usr/lib/llvm-3.6/include/llvm/Support/Casting.h:56:24: error: cannot initialize a parameter of type 'const clang::Decl *' with an rvalue of<br> type 'const clang::ast_type_traits::DynTypedNode *'<br> return To::classof(&Val);<br> ^~~~<br><br><br><div>> Subject: Re: [cfe-dev] How to use clang::ast_type_traits::DynTypedNode?<br>> To: pedretti_86@hotmail.com; klimek@google.com; cfe-dev@lists.llvm.org<br>> From: jonathan@codesourcery.com<br>> Date: Tue, 23 Feb 2016 09:13:21 -0700<br>> <br>> <br>> <br>> On 2/23/16 9:07 AM, victor via cfe-dev wrote:<br>> > Thanks for answering, Manuel.<br>> ><br>> > However, your code didn't work:<br>> ><br>> > clases_file.cpp:35:22: error: variable 'MD' with type 'const auto *'<br>> > has incompatible initializer of type 'const clang::CXXMethodDecl'<br>> > if (const auto* MD = llvm::dyn_cast<CXXMethodDecl>(pv[size-1])) {<br>> ><br>> > ^<br>> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>> <br>> You need to take the address of it as dyn_cast works on pointers, not <br>> references:<br>> <br>> if (const auto* MD = llvm::dyn_cast<CXXMethodDecl>(&pv[size-1])) {<br>> <br>> <br>> Jon<br>> <br>> -- <br>> Jon Roelofs<br>> jonathan@codesourcery.com<br>> CodeSourcery / Mentor Embedded<br></div> </div></body>
</html>