Transaction takes and stores the ASTContext, otherwise it is too much of an effort to get it from the DeclQueue, which might contain null DGRs.
This commit is contained in:
parent
dfe1c172b6
commit
01314c9d78
@ -15,6 +15,7 @@
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
class Decl;
|
||||
class FunctionDecl;
|
||||
struct PrintingPolicy;
|
||||
@ -110,18 +111,16 @@ namespace cling {
|
||||
///
|
||||
const Transaction* m_Next;
|
||||
|
||||
protected:
|
||||
|
||||
///\brief Sets the next transaction in the list.
|
||||
///\brief The ASTContext
|
||||
///
|
||||
void setNext(Transaction* T) { m_Next = T; }
|
||||
const clang::ASTContext& m_ASTContext;
|
||||
|
||||
public:
|
||||
|
||||
Transaction();
|
||||
Transaction(const CompilationOptions& Opts);
|
||||
Transaction(const clang::ASTContext& C);
|
||||
Transaction(const CompilationOptions& Opts, const clang::ASTContext& C);
|
||||
|
||||
void Initialize();
|
||||
void Initialize(const clang::ASTContext& C);
|
||||
|
||||
~Transaction();
|
||||
|
||||
@ -335,6 +334,11 @@ namespace cling {
|
||||
|
||||
const Transaction* getNext() const { return m_Next; }
|
||||
|
||||
clang::ASTContext& getASTContext() {
|
||||
return const_cast<clang::ASTContext&>(m_ASTContext);
|
||||
}
|
||||
const clang::ASTContext& getASTContext() const { return m_ASTContext; }
|
||||
|
||||
///\brief Erases an element at given position.
|
||||
///
|
||||
void erase(size_t pos);
|
||||
|
@ -87,7 +87,7 @@ namespace cling {
|
||||
}
|
||||
|
||||
void IncrementalParser::Initialize() {
|
||||
m_TransactionPool.reset(new TransactionPool());
|
||||
m_TransactionPool.reset(new TransactionPool(getCI()->getASTContext()));
|
||||
if (hasCodeGenerator())
|
||||
getCodeGenerator()->Initialize(getCI()->getASTContext());
|
||||
|
||||
|
@ -17,16 +17,17 @@ using namespace clang;
|
||||
|
||||
namespace cling {
|
||||
|
||||
Transaction::Transaction() {
|
||||
Initialize();
|
||||
Transaction::Transaction(const ASTContext& C) : m_ASTContext(C) {
|
||||
Initialize(C);
|
||||
}
|
||||
|
||||
Transaction::Transaction(const CompilationOptions& Opts) {
|
||||
Initialize();
|
||||
Transaction::Transaction(const CompilationOptions& Opts, const ASTContext& C)
|
||||
: m_ASTContext(C) {
|
||||
Initialize(C);
|
||||
m_Opts = Opts; // intentional copy.
|
||||
}
|
||||
|
||||
void Transaction::Initialize() {
|
||||
void Transaction::Initialize(const ASTContext& C) {
|
||||
m_NestedTransactions.reset(0);
|
||||
m_Parent = 0;
|
||||
m_State = kCollecting;
|
||||
@ -35,6 +36,7 @@ namespace cling {
|
||||
m_Module = 0;
|
||||
m_WrapperFD = 0;
|
||||
m_Next = 0;
|
||||
//m_ASTContext = C;
|
||||
}
|
||||
|
||||
Transaction::~Transaction() {
|
||||
|
@ -9,8 +9,14 @@
|
||||
|
||||
#include "cling/Interpreter/Transaction.h"
|
||||
|
||||
#include "clang/AST/ASTContext.h"
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
}
|
||||
|
||||
namespace cling {
|
||||
class TransactionPool {
|
||||
#define TRANSACTIONS_IN_BLOCK 8
|
||||
@ -22,6 +28,10 @@ namespace cling {
|
||||
//
|
||||
llvm::SmallVector<Transaction*, 2 * TRANSACTIONS_IN_BLOCK> m_Transactions;
|
||||
|
||||
///\brief The ASTContext required by cling::Transactions' ctor.
|
||||
///
|
||||
clang::ASTContext& m_ASTContext;
|
||||
|
||||
// We need to free them in blocks.
|
||||
//
|
||||
//llvm::SmallVector<Transaction*, 64> m_TransactionBlocks;
|
||||
@ -31,12 +41,12 @@ namespace cling {
|
||||
// Allocate them in one block, containing 8 transactions.
|
||||
//Transaction* arrayStart = new Transaction[TRANSACTIONS_IN_BLOCK]();
|
||||
for (size_t i = 0; i < TRANSACTIONS_IN_BLOCK; ++i)
|
||||
m_Transactions.push_back(new Transaction());
|
||||
m_Transactions.push_back(new Transaction(m_ASTContext));
|
||||
//m_TransactionBlocks.push_back(arrayStart);
|
||||
}
|
||||
|
||||
public:
|
||||
TransactionPool() {
|
||||
TransactionPool(clang::ASTContext& C) : m_ASTContext(C) {
|
||||
RefillPool();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user