Use the new CodeGen debug printouts in .storeState

This commit is contained in:
Vassil Vassilev 2014-02-27 15:51:37 +01:00 committed by sftnight
parent c66118f2e2
commit 71b05e8321
3 changed files with 17 additions and 8 deletions

View File

@ -18,6 +18,7 @@
namespace clang {
class ASTContext;
class CodeGenerator;
class SourceManager;
class Preprocessor;
}
@ -42,6 +43,7 @@ namespace cling {
std::string m_MacrosFile;
clang::ASTContext& m_ASTContext;
clang::Preprocessor& m_Preprocessor;
clang::CodeGenerator* m_CodeGen;
llvm::Module* m_Module;
std::string m_DiffCommand;
std::string m_Name;
@ -50,7 +52,8 @@ namespace cling {
llvm::OwningPtr<ClangInternalState> m_DiffPair;
public:
ClangInternalState(clang::ASTContext& AC, clang::Preprocessor& PP,
llvm::Module* M, const std::string& name);
llvm::Module* M, clang::CodeGenerator* CG,
const std::string& name);
~ClangInternalState();
///\brief It is convenient the state object to be named so that can be
@ -81,7 +84,8 @@ namespace cling {
static void printIncludedFiles(llvm::raw_ostream& Out,
clang::SourceManager& SM);
static void printAST(llvm::raw_ostream& Out, clang::ASTContext& C);
static void printLLVMModule(llvm::raw_ostream& Out, llvm::Module& M);
static void printLLVMModule(llvm::raw_ostream& Out, llvm::Module& M,
clang::CodeGenerator& CG);
static void printMacroDefinitions(llvm::raw_ostream& Out,
clang::Preprocessor& PP);
private:

View File

@ -14,6 +14,7 @@
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/Module.h"
@ -37,9 +38,9 @@ using namespace clang;
namespace cling {
ClangInternalState::ClangInternalState(ASTContext& AC, Preprocessor& PP,
llvm::Module* M,
llvm::Module* M, CodeGenerator* CG,
const std::string& name)
: m_ASTContext(AC), m_Preprocessor(PP), m_Module(M),
: m_ASTContext(AC), m_Preprocessor(PP), m_Module(M), m_CodeGen(CG),
m_DiffCommand("diff -u --text "), m_Name(name), m_DiffPair(0) {
store();
}
@ -74,7 +75,7 @@ namespace cling {
m_ASTContext.getSourceManager());
printAST(*m_ASTOS.get(), m_ASTContext);
if (m_Module)
printLLVMModule(*m_LLVMModuleOS.get(), *m_Module);
printLLVMModule(*m_LLVMModuleOS.get(), *m_Module, *m_CodeGen);
printMacroDefinitions(*m_MacrosOS.get(), m_Preprocessor);
}
namespace {
@ -131,7 +132,7 @@ namespace cling {
void ClangInternalState::compare(const std::string& name) {
assert(name == m_Name && "Different names!?");
m_DiffPair.reset(new ClangInternalState(m_ASTContext, m_Preprocessor,
m_Module, name));
m_Module, m_CodeGen, name));
std::string differences = "";
// Ignore the builtins
typedef llvm::SmallVector<const char*, 1024> Builtins;
@ -165,6 +166,7 @@ namespace cling {
differences = "";
}
if (m_Module) {
assert(m_CodeGen && "Must have CodeGen set");
// We want to skip the intrinsics
builtinNames.clear();
for (llvm::Module::const_iterator I = m_Module->begin(),
@ -277,8 +279,10 @@ namespace cling {
}
void ClangInternalState::printLLVMModule(llvm::raw_ostream& Out,
llvm::Module& M) {
llvm::Module& M,
CodeGenerator& CG) {
M.print(Out, /*AssemblyAnnotationWriter*/ 0);
CG.print(Out);
}
void ClangInternalState::printMacroDefinitions(llvm::raw_ostream& Out,

View File

@ -310,7 +310,8 @@ namespace cling {
PushTransactionRAII RAII(this);
ClangInternalState* state
= new ClangInternalState(getCI()->getASTContext(),
getCI()->getPreprocessor(), getModule(), name);
getCI()->getPreprocessor(), getModule(),
getCodeGenerator(), name);
m_StoredStates.push_back(state);
}