This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
//===-- ASTResultSynthesizer.cpp --------------------------------*- C++ -*-===//
|
2010-07-02 04:08:22 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
#include "clang/AST/DeclCXX.h"
|
|
|
|
#include "clang/AST/DeclGroup.h"
|
|
|
|
#include "clang/AST/Expr.h"
|
|
|
|
#include "clang/AST/Stmt.h"
|
|
|
|
#include "clang/Parse/Parser.h"
|
|
|
|
#include "llvm/Support/Casting.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
#include "lldb/Expression/ASTResultSynthesizer.h"
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace clang;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2010-11-19 10:52:21 +08:00
|
|
|
ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough,
|
|
|
|
TypeFromUser desired_type) :
|
2010-07-13 07:14:00 +08:00
|
|
|
m_ast_context (NULL),
|
|
|
|
m_passthrough (passthrough),
|
|
|
|
m_passthrough_sema (NULL),
|
2010-11-19 10:52:21 +08:00
|
|
|
m_sema (NULL),
|
|
|
|
m_desired_type (desired_type)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
if (!m_passthrough)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_passthrough_sema = dyn_cast<SemaConsumer>(passthrough);
|
|
|
|
}
|
|
|
|
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::~ASTResultSynthesizer()
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::Initialize(ASTContext &Context)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
m_ast_context = &Context;
|
|
|
|
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->Initialize(Context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::TransformTopLevelDecl(Decl* D)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
LinkageSpecDecl *linkage_spec_decl = dyn_cast<LinkageSpecDecl>(D);
|
|
|
|
|
|
|
|
if (linkage_spec_decl)
|
|
|
|
{
|
|
|
|
RecordDecl::decl_iterator decl_iterator;
|
|
|
|
|
|
|
|
for (decl_iterator = linkage_spec_decl->decls_begin();
|
|
|
|
decl_iterator != linkage_spec_decl->decls_end();
|
|
|
|
++decl_iterator)
|
|
|
|
{
|
|
|
|
TransformTopLevelDecl(*decl_iterator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionDecl *function_decl = dyn_cast<FunctionDecl>(D);
|
|
|
|
|
|
|
|
if (m_ast_context &&
|
|
|
|
function_decl &&
|
2010-10-16 06:48:33 +08:00
|
|
|
!function_decl->getNameInfo().getAsString().compare("$__lldb_expr"))
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
2010-08-17 07:01:35 +08:00
|
|
|
SynthesizeResult(function_decl);
|
2010-07-02 04:08:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
DeclGroupRef::iterator decl_iterator;
|
|
|
|
|
|
|
|
for (decl_iterator = D.begin();
|
|
|
|
decl_iterator != D.end();
|
|
|
|
++decl_iterator)
|
|
|
|
{
|
|
|
|
Decl *decl = *decl_iterator;
|
|
|
|
|
|
|
|
TransformTopLevelDecl(decl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->HandleTopLevelDecl(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::SynthesizeResult (FunctionDecl *FunDecl)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
2010-08-17 07:01:35 +08:00
|
|
|
ASTContext &Ctx(*m_ast_context);
|
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
if (!m_sema)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
FunctionDecl *function_decl = FunDecl;
|
|
|
|
|
|
|
|
if (!function_decl)
|
|
|
|
return false;
|
|
|
|
|
2010-09-14 05:34:21 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
raw_string_ostream os(s);
|
|
|
|
|
2010-09-22 08:33:31 +08:00
|
|
|
Ctx.getTranslationUnitDecl()->print(os);
|
2010-09-14 05:34:21 +08:00
|
|
|
|
|
|
|
os.flush();
|
|
|
|
|
2010-09-22 08:33:31 +08:00
|
|
|
log->Printf("AST context before transforming:\n%s", s.c_str());
|
2010-09-14 05:34:21 +08:00
|
|
|
}
|
|
|
|
|
2010-07-02 04:08:22 +08:00
|
|
|
Stmt *function_body = function_decl->getBody();
|
|
|
|
CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(function_body);
|
|
|
|
|
|
|
|
if (!compound_stmt)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (compound_stmt->body_empty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Stmt **last_stmt_ptr = compound_stmt->body_end() - 1;
|
|
|
|
Stmt *last_stmt = *last_stmt_ptr;
|
|
|
|
|
2010-09-14 05:34:21 +08:00
|
|
|
while (dyn_cast<NullStmt>(last_stmt))
|
|
|
|
{
|
|
|
|
if (last_stmt_ptr != compound_stmt->body_begin())
|
|
|
|
{
|
|
|
|
last_stmt_ptr--;
|
|
|
|
last_stmt = *last_stmt_ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-02 04:08:22 +08:00
|
|
|
Expr *last_expr = dyn_cast<Expr>(last_stmt);
|
|
|
|
|
|
|
|
if (!last_expr)
|
|
|
|
// No auxiliary variable necessary; expression returns void
|
|
|
|
return true;
|
|
|
|
|
|
|
|
QualType expr_qual_type = last_expr->getType();
|
|
|
|
clang::Type *expr_type = expr_qual_type.getTypePtr();
|
|
|
|
|
|
|
|
if (!expr_type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (expr_type->isVoidType())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string s = expr_qual_type.getAsString();
|
|
|
|
|
|
|
|
log->Printf("Last statement's type: %s", s.c_str());
|
|
|
|
}
|
|
|
|
|
2010-10-16 06:48:33 +08:00
|
|
|
IdentifierInfo &result_id = Ctx.Idents.get("$__lldb_expr_result");
|
2010-07-24 09:37:44 +08:00
|
|
|
|
2010-07-02 04:08:22 +08:00
|
|
|
clang::VarDecl *result_decl = VarDecl::Create(Ctx,
|
|
|
|
function_decl,
|
|
|
|
SourceLocation(),
|
|
|
|
&result_id,
|
|
|
|
expr_qual_type,
|
|
|
|
NULL,
|
2010-09-23 11:01:22 +08:00
|
|
|
SC_Static,
|
|
|
|
SC_Static);
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
if (!result_decl)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
function_decl->addDecl(result_decl);
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
// call AddInitializerToDecl
|
|
|
|
//
|
2010-09-23 11:01:22 +08:00
|
|
|
|
|
|
|
m_sema->AddInitializerToDecl(result_decl, last_expr);
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
/////////////////////////////////
|
|
|
|
// call ConvertDeclToDeclGroup
|
|
|
|
//
|
|
|
|
|
2010-09-23 11:01:22 +08:00
|
|
|
Sema::DeclGroupPtrTy result_decl_group_ptr;
|
2010-07-02 04:08:22 +08:00
|
|
|
|
2010-09-23 11:01:22 +08:00
|
|
|
result_decl_group_ptr = m_sema->ConvertDeclToDeclGroup(result_decl);
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// call ActOnDeclStmt
|
|
|
|
//
|
|
|
|
|
2010-09-23 11:01:22 +08:00
|
|
|
StmtResult result_initialization_stmt_result(m_sema->ActOnDeclStmt(result_decl_group_ptr,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation()));
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
// replace the old statement with the new one
|
|
|
|
//
|
|
|
|
|
2010-07-24 09:37:44 +08:00
|
|
|
*last_stmt_ptr = reinterpret_cast<Stmt*>(result_initialization_stmt_result.take());
|
2010-07-02 04:08:22 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
raw_string_ostream os(s);
|
|
|
|
|
|
|
|
function_decl->print(os);
|
|
|
|
|
|
|
|
os.flush();
|
|
|
|
|
|
|
|
log->Printf("Transformed function AST:\n%s", s.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::HandleTranslationUnit(ASTContext &Ctx)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->HandleTranslationUnit(Ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::HandleTagDeclDefinition(TagDecl *D)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->HandleTagDeclDefinition(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::CompleteTentativeDefinition(VarDecl *D)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->CompleteTentativeDefinition(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->HandleVTable(RD, DefinitionRequired);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::PrintStats()
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
if (m_passthrough)
|
|
|
|
m_passthrough->PrintStats();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::InitializeSema(Sema &S)
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
m_sema = &S;
|
|
|
|
|
|
|
|
if (m_passthrough_sema)
|
|
|
|
m_passthrough_sema->InitializeSema(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
ASTResultSynthesizer::ForgetSema()
|
2010-07-02 04:08:22 +08:00
|
|
|
{
|
|
|
|
m_sema = NULL;
|
|
|
|
|
|
|
|
if (m_passthrough_sema)
|
|
|
|
m_passthrough_sema->ForgetSema();
|
|
|
|
}
|