Fixed a problem that caused LLDB to fail to execute
expressions that used function pointers. The problem
was that IRForTarget previously only scanned the IR
for the expression for call instructions; if a function
was used in another context, it was ignored.
Now LLDB scans the Module for functions that are only
declared (not also defined -- so these are externals);
it then constructs function pointers for these
functions and substitutes them wherever the function
is used.
Also made some changes so that "expr main" works just
as well as "expr &main"; they end up being the same
code, but LLDB was generating the result variable in
different ways.
llvm-svn: 136928
diff --git a/lldb/source/Expression/ASTResultSynthesizer.cpp b/lldb/source/Expression/ASTResultSynthesizer.cpp
index e4c1aa6..1125d62 100644
--- a/lldb/source/Expression/ASTResultSynthesizer.cpp
+++ b/lldb/source/Expression/ASTResultSynthesizer.cpp
@@ -311,7 +311,12 @@
if (is_lvalue)
{
- IdentifierInfo &result_ptr_id = Ctx.Idents.get("$__lldb_expr_result_ptr");
+ IdentifierInfo *result_ptr_id;
+
+ if (expr_type->isFunctionType())
+ result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result"); // functions actually should be treated like function pointers
+ else
+ result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result_ptr");
QualType ptr_qual_type = Ctx.getPointerType(expr_qual_type);
@@ -319,7 +324,7 @@
DC,
SourceLocation(),
SourceLocation(),
- &result_ptr_id,
+ result_ptr_id,
ptr_qual_type,
NULL,
SC_Static,