This patch adds a new ExecutionPolicy, eExecutionPolicyTopLevel, which tells the expression parser that the expression should be JITted as top level code but nothing (except static initializers) should be run. I have modified the Clang expression parser to recognize this execution policy. On top of the existing patches that support storing IR and maintaining a map of arbitrary Decls, this is mainly just patching up a few places in the expression parser. I intend to submit a patch for review that exposes this functionality through the "expression" command and through the SB API. That patch also includes a testcase for all of this. <rdar://problem/22864976> llvm-svn: 264095
83 lines
2.5 KiB
C++
83 lines
2.5 KiB
C++
//===-- ClangExpression.h ---------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_ClangExpression_h_
|
|
#define liblldb_ClangExpression_h_
|
|
|
|
// C Includes
|
|
// C++ Includes
|
|
#include <string>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
// Other libraries and framework includes
|
|
// Project includes
|
|
|
|
#include "lldb/lldb-forward.h"
|
|
#include "lldb/lldb-private.h"
|
|
#include "lldb/Core/ClangForward.h"
|
|
#include "lldb/Expression/ExpressionTypeSystemHelper.h"
|
|
|
|
namespace lldb_private {
|
|
|
|
class RecordingMemoryManager;
|
|
|
|
//----------------------------------------------------------------------
|
|
// ClangExpressionHelper
|
|
//----------------------------------------------------------------------
|
|
class ClangExpressionHelper : public ExpressionTypeSystemHelper
|
|
{
|
|
public:
|
|
static bool classof(const ExpressionTypeSystemHelper *ts)
|
|
{
|
|
return ts->getKind() == eKindClangHelper;
|
|
}
|
|
|
|
ClangExpressionHelper () :
|
|
ExpressionTypeSystemHelper(ExpressionTypeSystemHelper::LLVMCastKind::eKindClangHelper)
|
|
{
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
/// Destructor
|
|
//------------------------------------------------------------------
|
|
virtual ~ClangExpressionHelper ()
|
|
{
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
/// Return the object that the parser should use when resolving external
|
|
/// values. May be NULL if everything should be self-contained.
|
|
//------------------------------------------------------------------
|
|
virtual ClangExpressionDeclMap *
|
|
DeclMap () = 0;
|
|
|
|
//------------------------------------------------------------------
|
|
/// Return the object that the parser should allow to access ASTs.
|
|
/// May be NULL if the ASTs do not need to be transformed.
|
|
///
|
|
/// @param[in] passthrough
|
|
/// The ASTConsumer that the returned transformer should send
|
|
/// the ASTs to after transformation.
|
|
//------------------------------------------------------------------
|
|
virtual clang::ASTConsumer *
|
|
ASTTransformer(clang::ASTConsumer *passthrough) = 0;
|
|
|
|
virtual void
|
|
CommitPersistentDecls()
|
|
{
|
|
}
|
|
|
|
protected:
|
|
};
|
|
|
|
} // namespace lldb_private
|
|
|
|
#endif // liblldb_ClangExpression_h_
|