Use the new CodeGen debug printouts in .storeState
This commit is contained in:
parent
c66118f2e2
commit
71b05e8321
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class ASTContext;
|
class ASTContext;
|
||||||
|
class CodeGenerator;
|
||||||
class SourceManager;
|
class SourceManager;
|
||||||
class Preprocessor;
|
class Preprocessor;
|
||||||
}
|
}
|
||||||
@ -42,6 +43,7 @@ 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;
|
||||||
|
clang::CodeGenerator* m_CodeGen;
|
||||||
llvm::Module* m_Module;
|
llvm::Module* m_Module;
|
||||||
std::string m_DiffCommand;
|
std::string m_DiffCommand;
|
||||||
std::string m_Name;
|
std::string m_Name;
|
||||||
@ -50,7 +52,8 @@ namespace cling {
|
|||||||
llvm::OwningPtr<ClangInternalState> m_DiffPair;
|
llvm::OwningPtr<ClangInternalState> m_DiffPair;
|
||||||
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, clang::CodeGenerator* CG,
|
||||||
|
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
|
||||||
@ -81,7 +84,8 @@ namespace cling {
|
|||||||
static void printIncludedFiles(llvm::raw_ostream& Out,
|
static void printIncludedFiles(llvm::raw_ostream& Out,
|
||||||
clang::SourceManager& SM);
|
clang::SourceManager& SM);
|
||||||
static void printAST(llvm::raw_ostream& Out, clang::ASTContext& C);
|
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,
|
static void printMacroDefinitions(llvm::raw_ostream& Out,
|
||||||
clang::Preprocessor& PP);
|
clang::Preprocessor& PP);
|
||||||
private:
|
private:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "clang/AST/RecursiveASTVisitor.h"
|
#include "clang/AST/RecursiveASTVisitor.h"
|
||||||
#include "clang/Basic/Builtins.h"
|
#include "clang/Basic/Builtins.h"
|
||||||
#include "clang/Basic/SourceManager.h"
|
#include "clang/Basic/SourceManager.h"
|
||||||
|
#include "clang/CodeGen/ModuleBuilder.h"
|
||||||
|
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
@ -37,9 +38,9 @@ using namespace clang;
|
|||||||
namespace cling {
|
namespace cling {
|
||||||
|
|
||||||
ClangInternalState::ClangInternalState(ASTContext& AC, Preprocessor& PP,
|
ClangInternalState::ClangInternalState(ASTContext& AC, Preprocessor& PP,
|
||||||
llvm::Module* M,
|
llvm::Module* M, CodeGenerator* CG,
|
||||||
const std::string& name)
|
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) {
|
m_DiffCommand("diff -u --text "), m_Name(name), m_DiffPair(0) {
|
||||||
store();
|
store();
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ namespace cling {
|
|||||||
m_ASTContext.getSourceManager());
|
m_ASTContext.getSourceManager());
|
||||||
printAST(*m_ASTOS.get(), m_ASTContext);
|
printAST(*m_ASTOS.get(), m_ASTContext);
|
||||||
if (m_Module)
|
if (m_Module)
|
||||||
printLLVMModule(*m_LLVMModuleOS.get(), *m_Module);
|
printLLVMModule(*m_LLVMModuleOS.get(), *m_Module, *m_CodeGen);
|
||||||
printMacroDefinitions(*m_MacrosOS.get(), m_Preprocessor);
|
printMacroDefinitions(*m_MacrosOS.get(), m_Preprocessor);
|
||||||
}
|
}
|
||||||
namespace {
|
namespace {
|
||||||
@ -131,7 +132,7 @@ namespace cling {
|
|||||||
void ClangInternalState::compare(const std::string& name) {
|
void ClangInternalState::compare(const std::string& name) {
|
||||||
assert(name == m_Name && "Different names!?");
|
assert(name == m_Name && "Different names!?");
|
||||||
m_DiffPair.reset(new ClangInternalState(m_ASTContext, m_Preprocessor,
|
m_DiffPair.reset(new ClangInternalState(m_ASTContext, m_Preprocessor,
|
||||||
m_Module, name));
|
m_Module, m_CodeGen, name));
|
||||||
std::string differences = "";
|
std::string differences = "";
|
||||||
// Ignore the builtins
|
// Ignore the builtins
|
||||||
typedef llvm::SmallVector<const char*, 1024> Builtins;
|
typedef llvm::SmallVector<const char*, 1024> Builtins;
|
||||||
@ -165,6 +166,7 @@ namespace cling {
|
|||||||
differences = "";
|
differences = "";
|
||||||
}
|
}
|
||||||
if (m_Module) {
|
if (m_Module) {
|
||||||
|
assert(m_CodeGen && "Must have CodeGen set");
|
||||||
// We want to skip the intrinsics
|
// We want to skip the intrinsics
|
||||||
builtinNames.clear();
|
builtinNames.clear();
|
||||||
for (llvm::Module::const_iterator I = m_Module->begin(),
|
for (llvm::Module::const_iterator I = m_Module->begin(),
|
||||||
@ -277,8 +279,10 @@ namespace cling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClangInternalState::printLLVMModule(llvm::raw_ostream& Out,
|
void ClangInternalState::printLLVMModule(llvm::raw_ostream& Out,
|
||||||
llvm::Module& M) {
|
llvm::Module& M,
|
||||||
|
CodeGenerator& CG) {
|
||||||
M.print(Out, /*AssemblyAnnotationWriter*/ 0);
|
M.print(Out, /*AssemblyAnnotationWriter*/ 0);
|
||||||
|
CG.print(Out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangInternalState::printMacroDefinitions(llvm::raw_ostream& Out,
|
void ClangInternalState::printMacroDefinitions(llvm::raw_ostream& Out,
|
||||||
|
@ -310,7 +310,8 @@ 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(),
|
||||||
|
getCodeGenerator(), name);
|
||||||
m_StoredStates.push_back(state);
|
m_StoredStates.push_back(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user