In -fsyntax-only mode we don't have llvm::Module.

This commit is contained in:
Vassil Vassilev 2014-01-29 15:23:49 +01:00 committed by sftnight
parent e0bc9916ab
commit 0944f060ec
3 changed files with 16 additions and 13 deletions

View File

@ -42,12 +42,12 @@ namespace cling {
std::string m_MacrosFile; std::string m_MacrosFile;
clang::ASTContext& m_ASTContext; clang::ASTContext& m_ASTContext;
clang::Preprocessor& m_Preprocessor; clang::Preprocessor& m_Preprocessor;
llvm::Module& m_Module; llvm::Module* m_Module;
std::string m_DiffCommand; std::string m_DiffCommand;
std::string m_Name; std::string m_Name;
public: public:
ClangInternalState(clang::ASTContext& AC, clang::Preprocessor& PP, ClangInternalState(clang::ASTContext& AC, clang::Preprocessor& PP,
llvm::Module& M, const std::string& name); llvm::Module* M, const std::string& name);
~ClangInternalState(); ~ClangInternalState();
///\brief It is convenient the state object to be named so that can be ///\brief It is convenient the state object to be named so that can be

View File

@ -36,7 +36,7 @@ using namespace clang;
namespace cling { namespace cling {
ClangInternalState::ClangInternalState(ASTContext& AC, Preprocessor& PP, ClangInternalState::ClangInternalState(ASTContext& AC, Preprocessor& PP,
llvm::Module& M, const std::string& name) llvm::Module* M, const std::string& name)
: m_ASTContext(AC), m_Preprocessor(PP), m_Module(M), : m_ASTContext(AC), m_Preprocessor(PP), m_Module(M),
m_DiffCommand("diff -u --text "), m_Name(name) { m_DiffCommand("diff -u --text "), m_Name(name) {
store(); store();
@ -71,7 +71,8 @@ namespace cling {
printIncludedFiles(*m_IncludedFilesOS.get(), printIncludedFiles(*m_IncludedFilesOS.get(),
m_ASTContext.getSourceManager()); m_ASTContext.getSourceManager());
printAST(*m_ASTOS.get(), m_ASTContext); 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); printMacroDefinitions(*m_MacrosOS.get(), m_Preprocessor);
} }
namespace { namespace {

View File

@ -302,7 +302,7 @@ namespace cling {
PushTransactionRAII RAII(this); PushTransactionRAII RAII(this);
ClangInternalState* state ClangInternalState* state
= new ClangInternalState(getCI()->getASTContext(), = new ClangInternalState(getCI()->getASTContext(),
getCI()->getPreprocessor(), *getModule(), name); getCI()->getPreprocessor(), getModule(), name);
m_StoredStates.push_back(state); m_StoredStates.push_back(state);
} }
@ -310,7 +310,7 @@ namespace cling {
// This may induce deserialization // This may induce deserialization
PushTransactionRAII RAII(this); PushTransactionRAII RAII(this);
ClangInternalState state(getCI()->getASTContext(), ClangInternalState state(getCI()->getASTContext(),
getCI()->getPreprocessor(), *getModule(), name); getCI()->getPreprocessor(), getModule(), name);
for (unsigned i = 0, e = m_StoredStates.size(); i != e; ++i) { for (unsigned i = 0, e = m_StoredStates.size(); i != e; ++i) {
if (m_StoredStates[i]->getName() == name) { if (m_StoredStates[i]->getName() == name) {
m_StoredStates[i]->compare(state); m_StoredStates[i]->compare(state);
@ -429,7 +429,9 @@ namespace cling {
} }
llvm::Module* Interpreter::getModule() const { llvm::Module* Interpreter::getModule() const {
if (m_IncrParser->hasCodeGenerator())
return m_IncrParser->getCodeGenerator()->GetModule(); return m_IncrParser->getCodeGenerator()->GetModule();
return 0;
} }
///\brief Maybe transform the input line to implement cint command line ///\brief Maybe transform the input line to implement cint command line