From 0944f060ece6ccba9a7bc9b6748b969008399b71 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Wed, 29 Jan 2014 15:23:49 +0100 Subject: [PATCH] In -fsyntax-only mode we don't have llvm::Module. --- include/cling/Interpreter/ClangInternalState.h | 4 ++-- lib/Interpreter/ClangInternalState.cpp | 9 +++++---- lib/Interpreter/Interpreter.cpp | 16 +++++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/cling/Interpreter/ClangInternalState.h b/include/cling/Interpreter/ClangInternalState.h index b95993bb..b8002e0b 100644 --- a/include/cling/Interpreter/ClangInternalState.h +++ b/include/cling/Interpreter/ClangInternalState.h @@ -42,12 +42,12 @@ namespace cling { std::string m_MacrosFile; clang::ASTContext& m_ASTContext; clang::Preprocessor& m_Preprocessor; - llvm::Module& m_Module; + llvm::Module* m_Module; std::string m_DiffCommand; std::string m_Name; public: ClangInternalState(clang::ASTContext& AC, clang::Preprocessor& PP, - llvm::Module& M, const std::string& name); + llvm::Module* M, const std::string& name); ~ClangInternalState(); ///\brief It is convenient the state object to be named so that can be diff --git a/lib/Interpreter/ClangInternalState.cpp b/lib/Interpreter/ClangInternalState.cpp index b2e9758e..594d1f37 100644 --- a/lib/Interpreter/ClangInternalState.cpp +++ b/lib/Interpreter/ClangInternalState.cpp @@ -36,8 +36,8 @@ using namespace clang; namespace cling { ClangInternalState::ClangInternalState(ASTContext& AC, Preprocessor& PP, - llvm::Module& M, const std::string& name) - : m_ASTContext(AC), m_Preprocessor(PP), m_Module(M), + llvm::Module* M, const std::string& name) + : m_ASTContext(AC), m_Preprocessor(PP), m_Module(M), m_DiffCommand("diff -u --text "), m_Name(name) { store(); } @@ -68,10 +68,11 @@ namespace cling { m_MacrosOS.reset(createOutputFile("macros", &m_MacrosFile)); printLookupTables(*m_LookupTablesOS.get(), m_ASTContext); - printIncludedFiles(*m_IncludedFilesOS.get(), + printIncludedFiles(*m_IncludedFilesOS.get(), m_ASTContext.getSourceManager()); printAST(*m_ASTOS.get(), m_ASTContext); - printLLVMModule(*m_LLVMModuleOS.get(), m_Module); + if (m_Module) + printLLVMModule(*m_LLVMModuleOS.get(), *m_Module); printMacroDefinitions(*m_MacrosOS.get(), m_Preprocessor); } namespace { diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index abc1f81d..1d8bb0ad 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -154,7 +154,7 @@ namespace cling { Interpreter::Interpreter(int argc, const char* const *argv, const char* llvmdir /*= 0*/) : - m_UniqueCounter(0), m_PrintAST(false), m_PrintIR(false), + m_UniqueCounter(0), m_PrintAST(false), m_PrintIR(false), m_DynamicLookupEnabled(false), m_RawInputEnabled(false) { m_LLVMContext.reset(new llvm::LLVMContext); @@ -172,8 +172,8 @@ namespace cling { &LeftoverArgs[0], llvmdir)); Sema& SemaRef = getSema(); - m_LookupHelper.reset(new LookupHelper(new Parser(SemaRef.getPreprocessor(), - SemaRef, + m_LookupHelper.reset(new LookupHelper(new Parser(SemaRef.getPreprocessor(), + SemaRef, /*SkipFunctionBodies*/false, /*isTemp*/true), this)); @@ -300,9 +300,9 @@ namespace cling { void Interpreter::storeInterpreterState(const std::string& name) const { // This may induce deserialization PushTransactionRAII RAII(this); - ClangInternalState* state + ClangInternalState* state = new ClangInternalState(getCI()->getASTContext(), - getCI()->getPreprocessor(), *getModule(), name); + getCI()->getPreprocessor(), getModule(), name); m_StoredStates.push_back(state); } @@ -310,7 +310,7 @@ namespace cling { // This may induce deserialization PushTransactionRAII RAII(this); ClangInternalState state(getCI()->getASTContext(), - getCI()->getPreprocessor(), *getModule(), name); + getCI()->getPreprocessor(), getModule(), name); for (unsigned i = 0, e = m_StoredStates.size(); i != e; ++i) { if (m_StoredStates[i]->getName() == name) { m_StoredStates[i]->compare(state); @@ -429,7 +429,9 @@ namespace cling { } llvm::Module* Interpreter::getModule() const { - return m_IncrParser->getCodeGenerator()->GetModule(); + if (m_IncrParser->hasCodeGenerator()) + return m_IncrParser->getCodeGenerator()->GetModule(); + return 0; } ///\brief Maybe transform the input line to implement cint command line