Fixed a bug where named constants were being
treated as externals, causing problems when we
tried to look their locations up in the debug
info. For example:
expr char c[] = "foo"; c[0]
would terminate when trying to find c in the
debug information, despite the fact that c was
defined inside the expression.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136629 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index dd73c51..b5e5c56 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -1236,7 +1236,7 @@
if (log)
log->Printf("MaybeHandleVariable (%s)", PrintValue(llvm_value_ptr).c_str());
-
+
if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(llvm_value_ptr))
{
switch (constant_expr->getOpcode())
@@ -1324,7 +1324,12 @@
llvm_value_ptr,
value_size,
value_alignment))
- return false;
+ {
+ if (!global_variable->hasExternalLinkage())
+ return true;
+ else
+ return false;
+ }
}
else if (dyn_cast<llvm::Function>(llvm_value_ptr))
{
@@ -1403,6 +1408,9 @@
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Function *fun = llvm_call_inst->getCalledFunction();
+
+ // If the call is to something other than a plain llvm::Function, resolve which
+ // Function is meant or give up.
if (fun == NULL)
{
@@ -1440,6 +1448,9 @@
}
}
+ // Determine the name of the called function, which is needed to find the address.
+ // Intrinsics are special-cased.
+
lldb_private::ConstString str;
if (fun->isIntrinsic())
@@ -1472,6 +1483,8 @@
str.SetCStringWithLength (fun->getName().data(), fun->getName().size());
}
+ // Find the address of the function, and the type if possible.
+
clang::NamedDecl *fun_decl = DeclForGlobal (fun);
lldb::addr_t fun_addr = LLDB_INVALID_ADDRESS;
Value **fun_value_ptr = NULL;
@@ -1511,6 +1524,8 @@
if (log)
log->Printf("Found \"%s\" at 0x%llx", str.GetCString(), fun_addr);
+ // Construct the typed pointer to the function.
+
Value *fun_addr_ptr = NULL;
if (!fun_value_ptr || !*fun_value_ptr)