2012-09-05 09:37:39 +00:00
//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
//------------------------------------------------------------------------------
# ifndef CLING_DECL_COLLECTOR_H
# define CLING_DECL_COLLECTOR_H
# include "clang/AST/ASTConsumer.h"
namespace clang {
class ASTContext ;
2013-04-04 15:40:05 +00:00
class CodeGenerator ;
2013-04-09 15:38:50 +00:00
class Decl ;
2012-09-05 09:37:39 +00:00
class DeclGroupRef ;
}
namespace cling {
class Transaction ;
///\brief Collects declarations and fills them in cling::Transaction.
///
/// cling::Transaction becomes is a main building block in the interpreter.
2013-04-04 15:40:05 +00:00
/// cling::DeclCollector is responsible for appending all the declarations
/// seen by clang.
2012-09-05 09:37:39 +00:00
///
class DeclCollector : public clang : : ASTConsumer {
private :
Transaction * m_CurTransaction ;
2013-04-04 15:40:05 +00:00
///\brief This is the fast path for the declarations which do not need
/// special handling. Eg. deserialized declarations.
clang : : CodeGenerator * m_CodeGen ; // we do not own.
2013-04-09 15:38:50 +00:00
bool comesFromASTReader ( clang : : DeclGroupRef DGR ) const ;
bool shouldIgnoreDeclFromASTReader ( const clang : : Decl * D ) const ;
2012-09-05 09:37:39 +00:00
public :
2013-04-04 15:40:05 +00:00
DeclCollector ( ) : m_CurTransaction ( 0 ) , m_CodeGen ( 0 ) { }
2012-09-05 09:37:39 +00:00
virtual ~ DeclCollector ( ) ;
2013-04-04 15:40:05 +00:00
// FIXME: Gross hack, which should disappear when we move some of the
// initialization happening in the IncrementalParser to the CIFactory.
void setCodeGen ( clang : : CodeGenerator * codeGen ) { m_CodeGen = codeGen ; }
2012-09-05 09:37:39 +00:00
/// \{
/// \name ASTConsumer overrides
virtual bool HandleTopLevelDecl ( clang : : DeclGroupRef DGR ) ;
virtual void HandleInterestingDecl ( clang : : DeclGroupRef DGR ) ;
virtual void HandleTagDeclDefinition ( clang : : TagDecl * TD ) ;
virtual void HandleVTable ( clang : : CXXRecordDecl * RD ,
bool DefinitionRequired ) ;
virtual void CompleteTentativeDefinition ( clang : : VarDecl * VD ) ;
virtual void HandleTranslationUnit ( clang : : ASTContext & Ctx ) ;
2012-12-12 08:08:56 +00:00
virtual void HandleCXXImplicitFunctionInstantiation ( clang : : FunctionDecl * D ) ;
virtual void HandleCXXStaticMemberVarInstantiation ( clang : : VarDecl * D ) ;
2012-09-05 09:37:39 +00:00
/// \}
/// \{
/// \name Transaction Support
Transaction * getTransaction ( ) { return m_CurTransaction ; }
const Transaction * getTransaction ( ) const { return m_CurTransaction ; }
void setTransaction ( Transaction * curT ) { m_CurTransaction = curT ; }
void setTransaction ( const Transaction * curT ) {
m_CurTransaction = const_cast < Transaction * > ( curT ) ;
}
/// \}
2012-10-13 15:04:49 +00:00
// dyn_cast/isa support
static bool classof ( const clang : : ASTConsumer * ) { return true ; }
2012-09-05 09:37:39 +00:00
} ;
} // namespace cling
# endif // CLING_DECL_COLLECTOR_H