Workaround multiple DeclCollector instances.
This commit is contained in:
parent
d6e2f85d1c
commit
1d06b2725b
@ -375,8 +375,8 @@ namespace cling {
|
||||
///
|
||||
bool empty() const {
|
||||
return m_DeclQueue.empty() && m_DeserializedDeclQueue.empty()
|
||||
&& (!m_NestedTransactions || m_NestedTransactions->empty()
|
||||
&& m_MacroDirectiveInfoQueue.empty());
|
||||
&& (!m_NestedTransactions || m_NestedTransactions->empty())
|
||||
&& m_MacroDirectiveInfoQueue.empty();
|
||||
}
|
||||
|
||||
///\brief Appends a declaration group and source from which consumer
|
||||
|
@ -155,7 +155,7 @@ namespace cling {
|
||||
///\param[in] MD - The MacroDecl containing the IdentifierInfo and
|
||||
/// MacroDirective to forward.
|
||||
///
|
||||
void PreVisitMacro(const Transaction::MacroDirective* MD);
|
||||
void PreVisitMacro(const clang::MacroDirective* MD);
|
||||
|
||||
///\brief Remove the macro from the Preprocessor.
|
||||
/// @param[in] MD - The MacroDirectiveInfo containing the IdentifierInfo and
|
||||
@ -695,7 +695,7 @@ namespace cling {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MacroReverter::PreVisitMacro(const Transaction::MacroDirective* MD) {
|
||||
void DeclReverter::PreVisitMacro(const clang::MacroDirective* MD) {
|
||||
const SourceLocation Loc = MD->getLocation();
|
||||
const SourceManager& SM = m_Sema->getSourceManager();
|
||||
FileID FID = SM.getFileID(SM.getSpellingLoc(Loc));
|
||||
@ -705,7 +705,7 @@ namespace cling {
|
||||
|
||||
bool DeclReverter::VisitMacro(const Transaction::MacroDirectiveInfo MacroD) {
|
||||
assert(&MacroD && "The Macro is null");
|
||||
PreVisitDecl(MacroD.m_MD);
|
||||
PreVisitMacro(MacroD.m_MD);
|
||||
|
||||
Preprocessor& PP = m_Sema->getPreprocessor();
|
||||
#ifndef NDEBUG
|
||||
|
@ -282,7 +282,7 @@ namespace cling {
|
||||
CI->setASTConsumer(collector);
|
||||
|
||||
// Add the callback keeping track of the macro definitions
|
||||
PP.addPPCallbacks(collector);
|
||||
PP.addPPCallbacks(static_cast<PPCallbacks*>(collector));
|
||||
|
||||
// Set up Sema
|
||||
CodeCompleteConsumer* CCC = 0;
|
||||
|
@ -82,9 +82,9 @@ namespace cling {
|
||||
m_CurTransaction->append(DCI);
|
||||
}
|
||||
|
||||
void DeclCollector::MacroDefined (const clang::Token &MacroNameTok,
|
||||
const clang::MacroDirective *MD) {
|
||||
Transaction::MacroDecl MDE(MacroNameTok.getIdentifierInfo(), MD);
|
||||
void DeclCollector::MacroDefined(const clang::Token &MacroNameTok,
|
||||
const clang::MacroDirective *MD) {
|
||||
Transaction::MacroDirectiveInfo MDE(MacroNameTok.getIdentifierInfo(), MD);
|
||||
m_CurTransaction->append(MDE);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace cling {
|
||||
/// cling::DeclCollector is responsible for appending all the declarations
|
||||
/// seen by clang.
|
||||
///
|
||||
class DeclCollector: public clang::ASTConsumer, public clang::PPCallbacks {
|
||||
class DeclCollector: public clang::PPCallbacks, public clang::ASTConsumer {
|
||||
private:
|
||||
Transaction* m_CurTransaction;
|
||||
|
||||
@ -69,8 +69,8 @@ namespace cling {
|
||||
/// \}
|
||||
|
||||
/// Macro support
|
||||
void MacroDefined (const clang::Token &MacroNameTok,
|
||||
const clang::MacroDirective *MD);
|
||||
virtual void MacroDefined (const clang::Token &MacroNameTok,
|
||||
const clang::MacroDirective *MD);
|
||||
// dyn_cast/isa support
|
||||
static bool classof(const clang::ASTConsumer*) { return true; }
|
||||
};
|
||||
|
@ -178,6 +178,8 @@ namespace cling {
|
||||
bool* fromJIT = 0) const;
|
||||
|
||||
llvm::ExecutionEngine* getExecutionEngine() const {
|
||||
if (!m_engine)
|
||||
return 0;
|
||||
return m_engine.get();
|
||||
}
|
||||
|
||||
|
@ -173,20 +173,20 @@ namespace cling {
|
||||
forceAppend(DelayCallInfo(DeclGroupRef(D), kCCIHandleTopLevelDecl));
|
||||
}
|
||||
|
||||
void Transaction::append(MacroDecl MDE) {
|
||||
assert(!MDE.m_II && "Appending null IdentifierInfo?!");
|
||||
assert(!MDE.m_MD && "Appending null MacroDirective?!");
|
||||
void Transaction::append(MacroDirectiveInfo MDE) {
|
||||
assert(MDE.m_II && "Appending null IdentifierInfo?!");
|
||||
assert(MDE.m_MD && "Appending null MacroDirective?!");
|
||||
assert(getState() == kCollecting
|
||||
&& "Cannot append declarations in current state.");
|
||||
#ifndef NDEBUG
|
||||
// Check for duplicates
|
||||
for (size_t i = 0, e = m_MacroDeclQueue.size(); i < e; ++i) {
|
||||
MacroDecl &oldMacroDecl (m_MacroDeclQueue[i]);
|
||||
assert(oldMacroDecl != MDE && "Duplicates?!");
|
||||
for (size_t i = 0, e = m_MacroDirectiveInfoQueue.size(); i < e; ++i) {
|
||||
MacroDirectiveInfo &oldMacroDirectiveInfo (m_MacroDirectiveInfoQueue[i]);
|
||||
assert(oldMacroDirectiveInfo != MDE && "Duplicates?!");
|
||||
}
|
||||
#endif
|
||||
|
||||
m_MacroDeclQueue.push_back(MDE);
|
||||
m_MacroDirectiveInfoQueue.push_back(MDE);
|
||||
}
|
||||
|
||||
void Transaction::erase(iterator pos) {
|
||||
|
Loading…
Reference in New Issue
Block a user