Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions interpreter/cling/lib/Interpreter/DeclCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/Token.h"
#include "llvm/Support/Signals.h"

using namespace clang;

Expand Down Expand Up @@ -57,6 +58,15 @@ namespace {
return true;
return false;
}

/// \brief Asserts that the given transaction is not null, otherwise prints a
/// stack trace to stderr and aborts execution.
static void assertHasTransaction(const cling::Transaction* T) {
if (!T) {
llvm::sys::PrintStackTrace(llvm::errs());
llvm_unreachable("Missing transaction during deserialization!");
}
}
}

namespace cling {
Expand All @@ -67,7 +77,7 @@ namespace cling {

void MacroDirective(const clang::Token& MacroNameTok,
const clang::MacroDirective* MD) {
assert(m_Parent->m_CurTransaction && "Missing transction");
assertHasTransaction(m_Parent->m_CurTransaction);
Transaction::MacroDirectiveInfo MDE(MacroNameTok.getIdentifierInfo(), MD);
m_Parent->m_CurTransaction->append(MDE);
}
Expand Down Expand Up @@ -101,7 +111,7 @@ namespace cling {

bool DeclCollector::comesFromASTReader(DeclGroupRef DGR) const {
assert(!DGR.isNull() && "DeclGroupRef is Null!");
assert(m_CurTransaction && "No current transaction when deserializing");
assertHasTransaction(m_CurTransaction);
if (m_CurTransaction->getCompilationOpts().CodeGenerationForModule)
return true;

Expand Down Expand Up @@ -183,7 +193,7 @@ namespace cling {
if (DGR.isNull())
return true;

assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DGR, Transaction::kCCIHandleTopLevelDecl);
m_CurTransaction->append(DCI);
if (!m_Consumer
Expand Down Expand Up @@ -222,7 +232,7 @@ namespace cling {
}

void DeclCollector::HandleInterestingDecl(DeclGroupRef DGR) {
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DGR, Transaction::kCCIHandleInterestingDecl);
m_CurTransaction->append(DCI);
if (m_Consumer
Expand All @@ -231,7 +241,7 @@ namespace cling {
}

void DeclCollector::HandleTagDeclDefinition(TagDecl* TD) {
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DeclGroupRef(TD),
Transaction::kCCIHandleTagDeclDefinition);
m_CurTransaction->append(DCI);
Expand All @@ -242,7 +252,7 @@ namespace cling {
}

void DeclCollector::HandleInvalidTagDeclDefinition(clang::TagDecl *TD){
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DeclGroupRef(TD),
Transaction::kCCIHandleTagDeclDefinition);
m_CurTransaction->append(DCI);
Expand All @@ -254,7 +264,7 @@ namespace cling {
}

void DeclCollector::HandleVTable(CXXRecordDecl* RD) {
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DeclGroupRef(RD),
Transaction::kCCIHandleVTable);
m_CurTransaction->append(DCI);
Expand All @@ -272,7 +282,7 @@ namespace cling {
}

void DeclCollector::CompleteTentativeDefinition(VarDecl* VD) {
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
// C has tentative definitions which we might need to deal with when running
// in C mode.
Transaction::DelayCallInfo DCI(DeclGroupRef(VD),
Expand All @@ -290,7 +300,7 @@ namespace cling {
}

void DeclCollector::HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DeclGroupRef(D),
Transaction::kCCIHandleCXXImplicitFunctionInstantiation);
m_CurTransaction->append(DCI);
Expand All @@ -301,7 +311,7 @@ namespace cling {
}

void DeclCollector::HandleCXXStaticMemberVarInstantiation(VarDecl *D) {
assert(m_CurTransaction && "Missing transction");
assertHasTransaction(m_CurTransaction);
Transaction::DelayCallInfo DCI(DeclGroupRef(D),
Transaction::kCCIHandleCXXStaticMemberVarInstantiation);
m_CurTransaction->append(DCI);
Expand Down