[cfe-dev] Extracting variable name from VarDecl* Clang

Dhriti Khanna via cfe-dev cfe-dev at lists.llvm.org
Sat Jun 4 05:02:37 PDT 2016


This code:

 if (IfStmt* ifS = dyn_cast<IfStmt>(st)) {
   errs() << "Found an IF statement ";
   VarDecl* var = ifS->getConditionVariable();
   errs() << var->getNameAsString();
 }

produces cannot initialize object parameter of type 'const
clang::NamedDecl' with an expression of type 'clang::VarDecl' error on errs()
<< var->getNameAsString(); line and the program crashes with a seg fault. I
can't find what's wrong with this? Please help.


-- 
Regards,
Dhriti Khanna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160604/990b3d0b/attachment.html>


More information about the cfe-dev mailing list