[Lldb-commits] [lldb] r119779 - in /lldb/trunk: include/lldb/Expression/ASTResultSynthesizer.h include/lldb/Expression/ClangUserExpression.h include/lldb/Symbol/ClangASTContext.h source/Breakpoint/BreakpointOptions.cpp source/Expression/ASTResultSynthesizer.cpp source/Expression/ClangUserExpression.cpp source/Symbol/ClangASTContext.cpp
Sean Callanan
scallanan at apple.com
Thu Nov 18 18:52:21 PST 2010
Author: spyffe
Date: Thu Nov 18 20:52:21 2010
New Revision: 119779
URL: http://llvm.org/viewvc/llvm-project?rev=119779&view=rev
Log:
Added support for indicating to the expression parser
that the result of an expression should be coerced to
a specific type. Also made breakpoint conditions pass
in the bool type for this type.
The expression parser ignores this indication for now.
Modified:
lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h
lldb/trunk/include/lldb/Expression/ClangUserExpression.h
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
Modified: lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h (original)
+++ lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h Thu Nov 18 20:52:21 2010
@@ -12,6 +12,7 @@
#include "clang/Sema/SemaConsumer.h"
#include "lldb/Core/ClangForward.h"
+#include "lldb/Symbol/TaggedASTType.h"
namespace lldb_private {
@@ -39,8 +40,13 @@
/// in order to produce LLVM IR, this SemaConsumer must allow them to
/// pass to the next step in the chain after processing. Passthrough is
/// the next ASTConsumer, or NULL if none is required.
+ ///
+ /// @param[in] desired_type
+ /// The type that the result should have. May be initialized with a
+ /// NULL type, in which case the type is inferred.
//----------------------------------------------------------------------
- ASTResultSynthesizer(clang::ASTConsumer *passthrough);
+ ASTResultSynthesizer(clang::ASTConsumer *passthrough,
+ TypeFromUser desired_type);
//----------------------------------------------------------------------
/// Destructor
@@ -128,6 +134,7 @@
clang::ASTConsumer *m_passthrough; ///< The ASTConsumer down the chain, for passthrough. NULL if it's a SemaConsumer.
clang::SemaConsumer *m_passthrough_sema; ///< The SemaConsumer down the chain, for passthrough. NULL if it's an ASTConsumer.
clang::Sema *m_sema; ///< The Sema to use.
+ TypeFromUser m_desired_type; ///< If non-NULL, the type to coerce the result to.
};
}
Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Thu Nov 18 20:52:21 2010
@@ -25,6 +25,7 @@
#include "lldb/Core/ClangForward.h"
#include "lldb/Expression/ClangExpression.h"
#include "lldb/Expression/ClangExpressionVariable.h"
+#include "lldb/Symbol/TaggedASTType.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
@@ -73,11 +74,17 @@
/// are needed for parsing (locations of functions, types of
/// variables, persistent variables, etc.)
///
+ /// @param[in] desired_type
+ /// The type that the expression should be coerced to. If NULL,
+ /// inferred from the expression itself.
+ ///
/// @return
/// True on success (no errors); false otherwise.
//------------------------------------------------------------------
bool
- Parse (Stream &error_stream, ExecutionContext &exe_ctx);
+ Parse (Stream &error_stream,
+ ExecutionContext &exe_ctx,
+ TypeFromUser desired_type);
//------------------------------------------------------------------
/// Execute the parsed expression
@@ -238,6 +245,7 @@
std::string m_expr_text; ///< The text of the expression, as typed by the user
std::string m_expr_prefix; ///< The text of the translation-level definitions, as provided by the user
std::string m_transformed_text; ///< The text of the expression, as send to the parser
+ TypeFromUser m_desired_type; ///< The type to coerce the expression's result to. If NULL, inferred from the expression.
std::auto_ptr<ClangExpressionDeclMap> m_expr_decl_map; ///< The map to use when parsing and materializing the expression.
std::auto_ptr<ClangExpressionVariableStore> m_local_variables; ///< The local expression variables, if the expression is DWARF.
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Nov 18 20:52:21 2010
@@ -126,6 +126,9 @@
{
return GetBuiltInType_void(getASTContext());
}
+
+ lldb::clang_type_t
+ GetBuiltInType_bool();
lldb::clang_type_t
GetBuiltInType_objc_id();
Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Thu Nov 18 20:52:21 2010
@@ -18,6 +18,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
#include "lldb/Target/ThreadPlanTestCondition.h"
@@ -193,8 +194,12 @@
exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
}
+
+ // Get the boolean type from the process's scratch AST context
+ ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+ TypeFromUser bool_type(ast_context->GetBuiltInType_bool(), ast_context->getASTContext());
- if (!m_condition_ap->Parse (error_stream, exe_ctx))
+ if (!m_condition_ap->Parse (error_stream, exe_ctx, bool_type))
{
// Errors mean we should stop.
return NULL;
Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Thu Nov 18 20:52:21 2010
@@ -24,11 +24,13 @@
using namespace clang;
using namespace lldb_private;
-ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough) :
+ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough,
+ TypeFromUser desired_type) :
m_ast_context (NULL),
m_passthrough (passthrough),
m_passthrough_sema (NULL),
- m_sema (NULL)
+ m_sema (NULL),
+ m_desired_type (desired_type)
{
if (!m_passthrough)
return;
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Thu Nov 18 20:52:21 2010
@@ -44,7 +44,8 @@
m_jit_addr(LLDB_INVALID_ADDRESS),
m_cplusplus(false),
m_objectivec(false),
- m_needs_object_ptr(false)
+ m_needs_object_ptr(false),
+ m_desired_type(NULL, NULL)
{
}
@@ -55,7 +56,8 @@
clang::ASTConsumer *
ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough)
{
- return new ASTResultSynthesizer(passthrough);
+ return new ASTResultSynthesizer(passthrough,
+ m_desired_type);
}
void
@@ -115,7 +117,9 @@
}
bool
-ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx)
+ClangUserExpression::Parse (Stream &error_stream,
+ ExecutionContext &exe_ctx,
+ TypeFromUser desired_type)
{
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -194,6 +198,8 @@
// Parse the expression
//
+ m_desired_type = desired_type;
+
m_expr_decl_map.reset(new ClangExpressionDeclMap(&exe_ctx));
ClangExpressionParser parser(target_triple.GetCString(), *this);
@@ -452,7 +458,7 @@
StreamString error_stream;
- if (!user_expression.Parse (error_stream, exe_ctx))
+ if (!user_expression.Parse (error_stream, exe_ctx, TypeFromUser(NULL, NULL)))
{
if (error_stream.GetString().empty())
error.SetErrorString ("expression failed to parse, unknown error");
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=119779&r1=119778&r2=119779&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Nov 18 20:52:21 2010
@@ -671,6 +671,12 @@
}
clang_type_t
+ClangASTContext::GetBuiltInType_bool()
+{
+ return getASTContext()->BoolTy.getAsOpaquePtr();
+}
+
+clang_type_t
ClangASTContext::GetBuiltInType_objc_id()
{
return getASTContext()->ObjCBuiltinIdTy.getAsOpaquePtr();
More information about the lldb-commits
mailing list