diff options
author | Sean Callanan <scallanan@apple.com> | 2010-06-23 23:18:04 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2010-06-23 23:18:04 +0000 |
commit | 1d389c4b024416ef843bcebf6309dd0c377aafd8 (patch) | |
tree | 5619cc22835c5d23acc08764d13caf5b6852ef1c /lldb/source/Expression/ClangExpression.cpp | |
parent | f470747a365a5edac817c27359e020fa006b7d69 (diff) | |
download | bcm5719-llvm-1d389c4b024416ef843bcebf6309dd0c377aafd8.tar.gz bcm5719-llvm-1d389c4b024416ef843bcebf6309dd0c377aafd8.zip |
Added the temporary -i option to expr, which
switches the expression parsing over to use the
LLVM IR as opposed to Clang ASTs. Right now,
that functionality only logs.
llvm-svn: 106695
Diffstat (limited to 'lldb/source/Expression/ClangExpression.cpp')
-rw-r--r-- | lldb/source/Expression/ClangExpression.cpp | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/lldb/source/Expression/ClangExpression.cpp b/lldb/source/Expression/ClangExpression.cpp index 626418b7ea4..b5846356652 100644 --- a/lldb/source/Expression/ClangExpression.cpp +++ b/lldb/source/Expression/ClangExpression.cpp @@ -50,6 +50,7 @@ #include "llvm/Target/TargetSelect.h" // Project includes +#include "lldb/Core/Log.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangStmtVisitor.h" @@ -354,7 +355,7 @@ ClangExpression::ParseBareExpression (llvm::StringRef expr_text, Stream &stream) // - Call clang::ParseAST (in lib/Sema/ParseAST.cpp) to parse the buffer. The CodeGenerator will generate code for __dbg_expr. // - Once ParseAST completes, you can grab the llvm::Module from the CodeGenerator, which will have an llvm::Function you can hand off to the JIT. ParseAST(m_clang_ap->getPreprocessor(), m_code_generator_ptr, m_clang_ap->getASTContext()); - + text_diagnostic_buffer.EndSourceFile(); //compiler_instance->getASTContext().getTranslationUnitDecl()->dump(); @@ -454,6 +455,58 @@ ClangExpression::ConvertExpressionToDWARF (ClangExpressionVariableList& expr_loc return 0; } +unsigned +ClangExpression::ConvertIRToDWARF (ClangExpressionVariableList &excpr_local_variable_list, + StreamString &dwarf_opcode_strm) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + llvm::Module *module = m_code_generator_ptr->GetModule(); + + if (!module) + { + if (log) + log->Printf("IR doesn't contain a module"); + + return 1; + } + + llvm::Module::iterator fi; + + for (fi = module->begin(); + fi != module->end(); + ++fi) + { + llvm::Function &function = *fi; + + if (log) + log->Printf("IR for %s:", function.getName().str().c_str()); + + llvm::Function::iterator bbi; + + for (bbi = function.begin(); + bbi != function.end(); + ++bbi) + { + llvm::BasicBlock &bb = *bbi; + + llvm::BasicBlock::iterator ii; + + for (ii = bb.begin(); + ii != bb.end(); + ++ii) + { + llvm::Instruction &inst = *ii; + + if (log) + log->Printf(" %s", inst.getOpcodeName()); + } + } + } + + return 0; +} + bool ClangExpression::JITFunction (const ExecutionContext &exc_context, const char *name) { |