diff options
| author | Sean Callanan <scallanan@apple.com> | 2010-09-13 21:34:21 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2010-09-13 21:34:21 +0000 |
| commit | 9e6ed53ea51e66688dcf4d30837c6fbe4ec06f1e (patch) | |
| tree | c820006abd28b091188967ad931adb82ccf42b40 /lldb/source/Expression/IRForTarget.cpp | |
| parent | 535e8e5f6004865b6c3f1df3ddc603d57d2311b8 (diff) | |
| download | bcm5719-llvm-9e6ed53ea51e66688dcf4d30837c6fbe4ec06f1e.tar.gz bcm5719-llvm-9e6ed53ea51e66688dcf4d30837c6fbe4ec06f1e.zip | |
Bugfixes to the expression parser. Fixes include:
- If you put a semicolon at the end of an expression,
this no longer causes the expression parser to
error out. This was a two-part fix: first,
ClangExpressionDeclMap::Materialize now handles
an empty struct (such as when there is no return
value); second, ASTResultSynthesizer walks backward
from the end of the ASTs until it reaches something
that's not a NullStmt.
- ClangExpressionVariable now properly byte-swaps when
printing itself.
- ClangUtilityFunction now cleans up after itself when
it's done compiling itself.
- Utility functions can now use external functions just
like user expressions.
- If you end your expression with a statement that does
not return a value, the expression now runs correctly
anyway.
Also, added the beginnings of an Objective-C object
validator function, which is neither installed nor used
as yet.
llvm-svn: 113789
Diffstat (limited to 'lldb/source/Expression/IRForTarget.cpp')
| -rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index e220b16f00c..f368b8dc027 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -32,12 +32,14 @@ static char ID; IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, const TargetData *target_data, + bool resolve_vars, const char *func_name) : ModulePass(&ID), m_decl_map(decl_map), m_target_data(target_data), m_sel_registerName(NULL), - m_func_name(func_name) + m_func_name(func_name), + m_resolve_vars(resolve_vars) { } @@ -65,7 +67,10 @@ IRForTarget::createResultVariable(llvm::Module &M, { lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - // Find the result variable + if (!m_resolve_vars) + return true; + + // Find the result variable. If it doesn't exist, we can give up right here. Value *result_value = M.getNamedValue("___clang_expr_result"); @@ -73,9 +78,10 @@ IRForTarget::createResultVariable(llvm::Module &M, { if (log) log->PutCString("Couldn't find result variable"); - return false; + + return true; } - + if (log) log->Printf("Found result in the IR: %s", PrintValue(result_value, false).c_str()); @@ -429,6 +435,9 @@ bool IRForTarget::rewritePersistentAllocs(llvm::Module &M, llvm::BasicBlock &BB) { + if (!m_resolve_vars) + return true; + lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); BasicBlock::iterator ii; @@ -649,6 +658,17 @@ IRForTarget::MaybeHandleCall(Module &M, C->setCalledFunction(fun_addr_ptr); + ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), fun->getName()); + + Value *values[1]; + values[0] = func_name; + MDNode *func_metadata = MDNode::get(M.getContext(), values, 1); + + C->setMetadata("lldb.call.realName", func_metadata); + + if (log) + log->Printf("Set metadata for %p [%d, %s]", C, func_name->isString(), func_name->getAsString().c_str()); + return true; } @@ -667,13 +687,16 @@ IRForTarget::resolveExternals(Module &M, BasicBlock &BB) { Instruction &inst = *ii; - if (LoadInst *load = dyn_cast<LoadInst>(&inst)) - if (!MaybeHandleVariable(M, load->getPointerOperand(), false)) - return false; + if (m_resolve_vars) + { + if (LoadInst *load = dyn_cast<LoadInst>(&inst)) + if (!MaybeHandleVariable(M, load->getPointerOperand(), false)) + return false; - if (StoreInst *store = dyn_cast<StoreInst>(&inst)) - if (!MaybeHandleVariable(M, store->getPointerOperand(), true)) - return false; + if (StoreInst *store = dyn_cast<StoreInst>(&inst)) + if (!MaybeHandleVariable(M, store->getPointerOperand(), true)) + return false; + } if (CallInst *call = dyn_cast<CallInst>(&inst)) if (!MaybeHandleCall(M, call)) @@ -886,6 +909,9 @@ UnfoldConstant(Constant *C, Value *new_value, Instruction *first_entry_instructi bool IRForTarget::replaceVariables(Module &M, Function &F) { + if (!m_resolve_vars) + return true; + lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); m_decl_map->DoStructLayout(); |

