virtual bool HandleTopLevelDecl( clang::DeclGroupRef d)
	{
		
		for (auto i =  d.begin();i != d.end();i++) {
                  
			if (auto  fd = llvm::dyn_cast<clang::FunctionDecl>(*i)) {
				std::cout << "function: " << fd->getDeclName().getAsString();
				std::cout << " (isGlobl?:" << fd->isGlobal();
				std::cout << " isStatic?:" << !(fd->isGlobal());
				std::cout << " isInline?:" << fd->isInlined() << ")";
				std::cout << std::endl;

			}
		}

		for (auto i =  d.begin();i != d.end();i++) {
			if (auto  vd = llvm::dyn_cast<clang::VarDecl>(*i)) {
				std::cout << "variable: " << vd->getDeclName().getAsString();
				std::cout << " (isGlobl?:" << vd->hasGlobalStorage();
				std::cout << " isStatic?:" << !(vd->isExternC());
				std::cout << " isExtern?:" << vd->hasExternalStorage();
				std::cout << ")" << std::endl;
			}
		}
		return true;
	}
bool MyASTConsumer::HandleTopLevelDecl(clang::DeclGroupRef d) {
  MyRecursiveASTVisitor rv;
  typedef clang::DeclGroupRef::iterator iter;
  for (iter b = d.begin(), e = d.end(); b != e; ++b) {
    rv.TraverseDecl(*b);
  }
  return true; // keep going
}
Beispiel #3
0
		virtual bool HandleTopLevelDecl(clang::DeclGroupRef D) override
		{
			for (clang::DeclGroupRef::iterator it = D.begin(); it != D.end(); ++it)
			{
				visitor.TraverseDecl(*it);
			}
			return true;
		}
Beispiel #4
0
// DECLSTMT Allows mix of decl and statements
bool SuperastCPP::TraverseDeclStmt(clang::DeclStmt* declStmt) {
  if (declStmt->isSingleDecl()) {
    TRY_TO(TraverseDecl(declStmt->getSingleDecl()));
  }
  else {
    // Group of  declStmt
    rapidjson::Value arrayValue(rapidjson::kArrayType);
    const clang::DeclGroupRef declGroup = declStmt->getDeclGroup();
    for (auto iterator = declGroup.begin(); iterator != declGroup.end(); ++iterator) {
      TRY_TO(TraverseDecl(*iterator));
      arrayValue.PushBack(sonValue, allocator);
    }
    sonValue = arrayValue;
  }
  return true;
}
Beispiel #5
0
bool MyASTConsumer::HandleTopLevelDecl(clang::DeclGroupRef d)
{
  int count = 0;
  using namespace clang;
  DeclGroupRef::iterator it;
  for( it = d.begin(); it != d.end(); it++)
  {
    count++;

    FunctionDecl *fd = llvm::dyn_cast<clang::FunctionDecl>(*it);
    /// can be extended for class declaration
    if(fd){
      PrintSourceLocation(fd);
    }
  }
return true;
}
 virtual bool HandleTopLevelDecl( clang::DeclGroupRef d)
 {
     static int count = 0;
     clang::DeclGroupRef::iterator it;
     for( it = d.begin(); it != d.end(); it++)
     {
         count++;
         clang::VarDecl *vd = llvm::dyn_cast<clang::VarDecl>(*it);
         if(!vd)
         {
             continue;
         }
         if( vd->isFileVarDecl() && !vd->hasExternalStorage() )
         {
             std::cerr << "Read top-level variable decl: '";
             std::cerr << vd->getDeclName().getAsString() ;
             std::cerr << std::endl;
         }
     }
     return true;
 }