blob: f40266ce358f6364f516dd81a489a049e56bb435 [file] [log] [blame]
Sean Callanan1a8d4092010-08-27 01:01:44 +00001//===-- ASTResultSynthesizer.cpp --------------------------------*- C++ -*-===//
Sean Callanan116be532010-07-01 20:08:22 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "stdlib.h"
11#include "clang/AST/ASTContext.h"
12#include "clang/AST/Decl.h"
13#include "clang/AST/DeclCXX.h"
14#include "clang/AST/DeclGroup.h"
Sean Callanan17827832010-12-13 22:46:15 +000015#include "clang/AST/DeclObjC.h"
Sean Callanan116be532010-07-01 20:08:22 +000016#include "clang/AST/Expr.h"
17#include "clang/AST/Stmt.h"
Sean Callanan116be532010-07-01 20:08:22 +000018#include "clang/Parse/Parser.h"
Sean Callanancf128622012-03-15 01:53:17 +000019#include "clang/Sema/SemaDiagnostic.h"
Sean Callanan116be532010-07-01 20:08:22 +000020#include "llvm/Support/Casting.h"
21#include "llvm/Support/raw_ostream.h"
22#include "lldb/Core/Log.h"
Sean Callananbccce812011-08-23 21:20:51 +000023#include "lldb/Expression/ClangPersistentVariables.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000024#include "lldb/Expression/ASTResultSynthesizer.h"
Sean Callananbccce812011-08-23 21:20:51 +000025#include "lldb/Symbol/ClangASTContext.h"
Sean Callanan0eed0d42011-12-06 03:41:14 +000026#include "lldb/Symbol/ClangASTImporter.h"
27#include "lldb/Target/Target.h"
Sean Callanan116be532010-07-01 20:08:22 +000028
29using namespace llvm;
30using namespace clang;
31using namespace lldb_private;
32
Sean Callananf7c3e272010-11-19 02:52:21 +000033ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough,
Sean Callanan0eed0d42011-12-06 03:41:14 +000034 Target &target) :
Greg Claytonc8e11e12010-07-12 23:14:00 +000035 m_ast_context (NULL),
36 m_passthrough (passthrough),
37 m_passthrough_sema (NULL),
Sean Callanan0eed0d42011-12-06 03:41:14 +000038 m_target (target),
Sean Callanan20bb3aa2011-12-21 22:22:58 +000039 m_sema (NULL)
Sean Callanan116be532010-07-01 20:08:22 +000040{
41 if (!m_passthrough)
42 return;
43
44 m_passthrough_sema = dyn_cast<SemaConsumer>(passthrough);
45}
46
Sean Callanan1a8d4092010-08-27 01:01:44 +000047ASTResultSynthesizer::~ASTResultSynthesizer()
Sean Callanan116be532010-07-01 20:08:22 +000048{
49}
50
51void
Sean Callanan1a8d4092010-08-27 01:01:44 +000052ASTResultSynthesizer::Initialize(ASTContext &Context)
Sean Callanan116be532010-07-01 20:08:22 +000053{
54 m_ast_context = &Context;
55
56 if (m_passthrough)
57 m_passthrough->Initialize(Context);
58}
59
60void
Sean Callanan1a8d4092010-08-27 01:01:44 +000061ASTResultSynthesizer::TransformTopLevelDecl(Decl* D)
Sean Callanan116be532010-07-01 20:08:22 +000062{
Sean Callanan17827832010-12-13 22:46:15 +000063 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
64
65 if (NamedDecl *named_decl = dyn_cast<NamedDecl>(D))
66 {
Sean Callanan7dd98122011-10-14 20:34:21 +000067 if (log && log->GetVerbose())
Sean Callanan17827832010-12-13 22:46:15 +000068 {
69 if (named_decl->getIdentifier())
70 log->Printf("TransformTopLevelDecl(%s)", named_decl->getIdentifier()->getNameStart());
71 else if (ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(D))
72 log->Printf("TransformTopLevelDecl(%s)", method_decl->getSelector().getAsString().c_str());
73 else
74 log->Printf("TransformTopLevelDecl(<complex>)");
75 }
76
77 }
Sean Callanan116be532010-07-01 20:08:22 +000078
Sean Callanan17827832010-12-13 22:46:15 +000079 if (LinkageSpecDecl *linkage_spec_decl = dyn_cast<LinkageSpecDecl>(D))
Sean Callanan116be532010-07-01 20:08:22 +000080 {
81 RecordDecl::decl_iterator decl_iterator;
82
83 for (decl_iterator = linkage_spec_decl->decls_begin();
84 decl_iterator != linkage_spec_decl->decls_end();
85 ++decl_iterator)
86 {
87 TransformTopLevelDecl(*decl_iterator);
88 }
89 }
Sean Callanan17827832010-12-13 22:46:15 +000090 else if (ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(D))
Sean Callanan116be532010-07-01 20:08:22 +000091 {
Sean Callanan17827832010-12-13 22:46:15 +000092 if (m_ast_context &&
93 !method_decl->getSelector().getAsString().compare("$__lldb_expr:"))
94 {
Sean Callananbccce812011-08-23 21:20:51 +000095 RecordPersistentTypes(method_decl);
Sean Callanan17827832010-12-13 22:46:15 +000096 SynthesizeObjCMethodResult(method_decl);
97 }
98 }
99 else if (FunctionDecl *function_decl = dyn_cast<FunctionDecl>(D))
100 {
101 if (m_ast_context &&
102 !function_decl->getNameInfo().getAsString().compare("$__lldb_expr"))
103 {
Sean Callananbccce812011-08-23 21:20:51 +0000104 RecordPersistentTypes(function_decl);
Sean Callanan17827832010-12-13 22:46:15 +0000105 SynthesizeFunctionResult(function_decl);
106 }
Sean Callanan116be532010-07-01 20:08:22 +0000107 }
108}
109
Sean Callanan7f27d602011-11-19 02:54:21 +0000110bool
Sean Callanan1a8d4092010-08-27 01:01:44 +0000111ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D)
Sean Callanan116be532010-07-01 20:08:22 +0000112{
113 DeclGroupRef::iterator decl_iterator;
114
115 for (decl_iterator = D.begin();
116 decl_iterator != D.end();
117 ++decl_iterator)
118 {
119 Decl *decl = *decl_iterator;
120
121 TransformTopLevelDecl(decl);
122 }
123
124 if (m_passthrough)
Sean Callanan7f27d602011-11-19 02:54:21 +0000125 return m_passthrough->HandleTopLevelDecl(D);
126 return true;
Sean Callanan116be532010-07-01 20:08:22 +0000127}
128
129bool
Sean Callanan17827832010-12-13 22:46:15 +0000130ASTResultSynthesizer::SynthesizeFunctionResult (FunctionDecl *FunDecl)
Sean Callanan116be532010-07-01 20:08:22 +0000131{
Greg Clayton2d4edfb2010-11-06 01:53:30 +0000132 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Sean Callanan116be532010-07-01 20:08:22 +0000133
Sean Callanan17827832010-12-13 22:46:15 +0000134 ASTContext &Ctx(*m_ast_context);
135
Sean Callanan116be532010-07-01 20:08:22 +0000136 if (!m_sema)
137 return false;
Sean Callanan17827832010-12-13 22:46:15 +0000138
Sean Callanan116be532010-07-01 20:08:22 +0000139 FunctionDecl *function_decl = FunDecl;
140
141 if (!function_decl)
142 return false;
143
Jim Inghame3be0c52011-01-22 01:25:40 +0000144 if (log && log->GetVerbose())
Sean Callanan9e6ed532010-09-13 21:34:21 +0000145 {
146 std::string s;
147 raw_string_ostream os(s);
148
Sean Callananc31ba262010-09-22 00:33:31 +0000149 Ctx.getTranslationUnitDecl()->print(os);
Sean Callanan9e6ed532010-09-13 21:34:21 +0000150
151 os.flush();
152
Sean Callananc31ba262010-09-22 00:33:31 +0000153 log->Printf("AST context before transforming:\n%s", s.c_str());
Sean Callanan9e6ed532010-09-13 21:34:21 +0000154 }
155
Sean Callanan116be532010-07-01 20:08:22 +0000156 Stmt *function_body = function_decl->getBody();
157 CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(function_body);
158
Sean Callanan17827832010-12-13 22:46:15 +0000159 bool ret = SynthesizeBodyResult (compound_stmt,
160 function_decl);
Jim Inghame3be0c52011-01-22 01:25:40 +0000161
162 if (log && log->GetVerbose())
Sean Callanan17827832010-12-13 22:46:15 +0000163 {
164 std::string s;
165 raw_string_ostream os(s);
166
167 function_decl->print(os);
168
169 os.flush();
170
Jim Inghame3be0c52011-01-22 01:25:40 +0000171 log->Printf ("Transformed function AST:\n%s", s.c_str());
Sean Callanan17827832010-12-13 22:46:15 +0000172 }
173
174 return ret;
175}
176
177bool
178ASTResultSynthesizer::SynthesizeObjCMethodResult (ObjCMethodDecl *MethodDecl)
179{
180 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
181
182 ASTContext &Ctx(*m_ast_context);
183
184 if (!m_sema)
185 return false;
186
187 if (!MethodDecl)
188 return false;
189
Jim Inghame3be0c52011-01-22 01:25:40 +0000190 if (log && log->GetVerbose())
Sean Callanan17827832010-12-13 22:46:15 +0000191 {
192 std::string s;
193 raw_string_ostream os(s);
194
195 Ctx.getTranslationUnitDecl()->print(os);
196
197 os.flush();
198
199 log->Printf("AST context before transforming:\n%s", s.c_str());
200 }
201
202 Stmt *method_body = MethodDecl->getBody();
Sean Callanan880e6802011-10-07 23:18:13 +0000203
204 if (!method_body)
205 return false;
206
Sean Callanan17827832010-12-13 22:46:15 +0000207 CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(method_body);
208
209 bool ret = SynthesizeBodyResult (compound_stmt,
210 MethodDecl);
211
212 if (log)
213 {
214 std::string s;
215 raw_string_ostream os(s);
216
217 MethodDecl->print(os);
218
219 os.flush();
220
221 log->Printf("Transformed function AST:\n%s", s.c_str());
222 }
223
224 return ret;
225}
226
227bool
228ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body,
229 DeclContext *DC)
230{
231 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
232
233 ASTContext &Ctx(*m_ast_context);
Sean Callanan22c52d92011-07-18 21:30:18 +0000234
235 if (!Body)
Sean Callanan116be532010-07-01 20:08:22 +0000236 return false;
237
Sean Callanan22c52d92011-07-18 21:30:18 +0000238 if (Body->body_empty())
Sean Callanan116be532010-07-01 20:08:22 +0000239 return false;
240
Sean Callanan22c52d92011-07-18 21:30:18 +0000241 Stmt **last_stmt_ptr = Body->body_end() - 1;
Sean Callanan116be532010-07-01 20:08:22 +0000242 Stmt *last_stmt = *last_stmt_ptr;
243
Sean Callanan9e6ed532010-09-13 21:34:21 +0000244 while (dyn_cast<NullStmt>(last_stmt))
245 {
Sean Callanan22c52d92011-07-18 21:30:18 +0000246 if (last_stmt_ptr != Body->body_begin())
Sean Callanan9e6ed532010-09-13 21:34:21 +0000247 {
248 last_stmt_ptr--;
249 last_stmt = *last_stmt_ptr;
250 }
Sean Callanan2d1f4be2011-02-22 21:52:56 +0000251 else
252 {
253 return false;
254 }
Sean Callanan9e6ed532010-09-13 21:34:21 +0000255 }
256
Sean Callanan116be532010-07-01 20:08:22 +0000257 Expr *last_expr = dyn_cast<Expr>(last_stmt);
258
259 if (!last_expr)
260 // No auxiliary variable necessary; expression returns void
261 return true;
262
Sean Callanan8d825782012-05-16 21:03:38 +0000263 // In C++11, last_expr can be a LValueToRvalue implicit cast. Strip that off if that's the
264 // case.
265
266 do {
267 ImplicitCastExpr *implicit_cast = dyn_cast<ImplicitCastExpr>(last_expr);
268
269 if (!implicit_cast)
270 break;
271
272 if (!implicit_cast->getCastKind() == CK_LValueToRValue)
273 break;
274
275 last_expr = implicit_cast->getSubExpr();
276 } while (0);
277
Sean Callanan92adcac2011-01-13 08:53:35 +0000278 // is_lvalue is used to record whether the expression returns an assignable Lvalue or an
279 // Rvalue. This is relevant because they are handled differently.
280 //
281 // For Lvalues
282 //
283 // - In AST result synthesis (here!) the expression E is transformed into an initialization
284 // T *$__lldb_expr_result_ptr = &E.
285 //
286 // - In structure allocation, a pointer-sized slot is allocated in the struct that is to be
287 // passed into the expression.
288 //
289 // - In IR transformations, reads and writes to $__lldb_expr_result_ptr are redirected at
290 // an entry in the struct ($__lldb_arg) passed into the expression. (Other persistent
291 // variables are treated similarly, having been materialized as references, but in those
292 // cases the value of the reference itself is never modified.)
293 //
294 // - During materialization, $0 (the result persistent variable) is ignored.
295 //
296 // - During dematerialization, $0 is marked up as a load address with value equal to the
297 // contents of the structure entry.
298 //
299 // For Rvalues
300 //
301 // - In AST result synthesis the expression E is transformed into an initialization
302 // static T $__lldb_expr_result = E.
303 //
304 // - In structure allocation, a pointer-sized slot is allocated in the struct that is to be
305 // passed into the expression.
306 //
307 // - In IR transformations, an instruction is inserted at the beginning of the function to
308 // dereference the pointer resident in the slot. Reads and writes to $__lldb_expr_result
309 // are redirected at that dereferenced version. Guard variables for the static variable
310 // are excised.
311 //
312 // - During materialization, $0 (the result persistent variable) is populated with the location
313 // of a newly-allocated area of memory.
314 //
315 // - During dematerialization, $0 is ignored.
316
317 bool is_lvalue =
318 (last_expr->getValueKind() == VK_LValue || last_expr->getValueKind() == VK_XValue) &&
319 (last_expr->getObjectKind() == OK_Ordinary);
320
Sean Callanan116be532010-07-01 20:08:22 +0000321 QualType expr_qual_type = last_expr->getType();
Sean Callanan78e37602011-01-27 04:42:51 +0000322 const clang::Type *expr_type = expr_qual_type.getTypePtr();
Sean Callanan116be532010-07-01 20:08:22 +0000323
324 if (!expr_type)
325 return false;
326
327 if (expr_type->isVoidType())
328 return true;
329
330 if (log)
331 {
332 std::string s = expr_qual_type.getAsString();
333
Sean Callanan92adcac2011-01-13 08:53:35 +0000334 log->Printf("Last statement is an %s with type: %s", (is_lvalue ? "lvalue" : "rvalue"), s.c_str());
Sean Callanan116be532010-07-01 20:08:22 +0000335 }
336
Sean Callanan77eaf442011-07-08 00:39:14 +0000337 clang::VarDecl *result_decl = NULL;
Sean Callanan116be532010-07-01 20:08:22 +0000338
Sean Callanan92adcac2011-01-13 08:53:35 +0000339 if (is_lvalue)
340 {
Sean Callanan0c4d8d22011-08-04 21:37:47 +0000341 IdentifierInfo *result_ptr_id;
342
343 if (expr_type->isFunctionType())
344 result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result"); // functions actually should be treated like function pointers
345 else
346 result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result_ptr");
Sean Callanan92adcac2011-01-13 08:53:35 +0000347
Sean Callanancf128622012-03-15 01:53:17 +0000348 m_sema->RequireCompleteType(SourceLocation(), expr_qual_type, clang::diag::err_incomplete_type);
Sean Callanan5780f9d2011-12-08 19:04:34 +0000349
Sean Callanancf128622012-03-15 01:53:17 +0000350 QualType ptr_qual_type;
351
Sean Callananfc4f2fb2011-12-14 01:13:04 +0000352 if (expr_qual_type->getAs<ObjCObjectType>() != NULL)
Sean Callanan5780f9d2011-12-08 19:04:34 +0000353 ptr_qual_type = Ctx.getObjCObjectPointerType(expr_qual_type);
354 else
355 ptr_qual_type = Ctx.getPointerType(expr_qual_type);
Sean Callanan92adcac2011-01-13 08:53:35 +0000356
357 result_decl = VarDecl::Create(Ctx,
358 DC,
359 SourceLocation(),
Sean Callananfb0b7582011-03-15 00:17:19 +0000360 SourceLocation(),
Sean Callanan0c4d8d22011-08-04 21:37:47 +0000361 result_ptr_id,
Sean Callanan92adcac2011-01-13 08:53:35 +0000362 ptr_qual_type,
363 NULL,
364 SC_Static,
365 SC_Static);
366
367 if (!result_decl)
368 return false;
369
370 ExprResult address_of_expr = m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr);
371
Sean Callanan8d825782012-05-16 21:03:38 +0000372 m_sema->AddInitializerToDecl(result_decl, address_of_expr.take(), true, false);
Sean Callanan92adcac2011-01-13 08:53:35 +0000373 }
374 else
375 {
376 IdentifierInfo &result_id = Ctx.Idents.get("$__lldb_expr_result");
377
378 result_decl = VarDecl::Create(Ctx,
379 DC,
Sean Callananfb0b7582011-03-15 00:17:19 +0000380 SourceLocation(),
381 SourceLocation(),
Sean Callanan92adcac2011-01-13 08:53:35 +0000382 &result_id,
383 expr_qual_type,
384 NULL,
385 SC_Static,
386 SC_Static);
387
388 if (!result_decl)
389 return false;
390
Sean Callanan8d825782012-05-16 21:03:38 +0000391 m_sema->AddInitializerToDecl(result_decl, last_expr, true, false);
Sean Callanan92adcac2011-01-13 08:53:35 +0000392 }
Sean Callanan116be532010-07-01 20:08:22 +0000393
Sean Callanan17827832010-12-13 22:46:15 +0000394 DC->addDecl(result_decl);
Sean Callanan116be532010-07-01 20:08:22 +0000395
396 ///////////////////////////////
397 // call AddInitializerToDecl
398 //
Sean Callanane2ef6e32010-09-23 03:01:22 +0000399
Sean Callanan92adcac2011-01-13 08:53:35 +0000400 //m_sema->AddInitializerToDecl(result_decl, last_expr);
Sean Callanan116be532010-07-01 20:08:22 +0000401
402 /////////////////////////////////
403 // call ConvertDeclToDeclGroup
404 //
405
Sean Callanane2ef6e32010-09-23 03:01:22 +0000406 Sema::DeclGroupPtrTy result_decl_group_ptr;
Sean Callanan116be532010-07-01 20:08:22 +0000407
Sean Callanane2ef6e32010-09-23 03:01:22 +0000408 result_decl_group_ptr = m_sema->ConvertDeclToDeclGroup(result_decl);
Sean Callanan116be532010-07-01 20:08:22 +0000409
410 ////////////////////////
411 // call ActOnDeclStmt
412 //
413
Sean Callanane2ef6e32010-09-23 03:01:22 +0000414 StmtResult result_initialization_stmt_result(m_sema->ActOnDeclStmt(result_decl_group_ptr,
415 SourceLocation(),
416 SourceLocation()));
Sean Callanan116be532010-07-01 20:08:22 +0000417
Sean Callanan116be532010-07-01 20:08:22 +0000418 ////////////////////////////////////////////////
419 // replace the old statement with the new one
420 //
421
Sean Callananddb46ef2010-07-24 01:37:44 +0000422 *last_stmt_ptr = reinterpret_cast<Stmt*>(result_initialization_stmt_result.take());
Sean Callanan116be532010-07-01 20:08:22 +0000423
Sean Callanan116be532010-07-01 20:08:22 +0000424 return true;
425}
426
427void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000428ASTResultSynthesizer::HandleTranslationUnit(ASTContext &Ctx)
Sean Callanan116be532010-07-01 20:08:22 +0000429{
430 if (m_passthrough)
431 m_passthrough->HandleTranslationUnit(Ctx);
432}
433
Sean Callananbccce812011-08-23 21:20:51 +0000434void
435ASTResultSynthesizer::RecordPersistentTypes(DeclContext *FunDeclCtx)
436{
437 typedef DeclContext::specific_decl_iterator<TypeDecl> TypeDeclIterator;
438
439 for (TypeDeclIterator i = TypeDeclIterator(FunDeclCtx->decls_begin()),
440 e = TypeDeclIterator(FunDeclCtx->decls_end());
441 i != e;
442 ++i)
443 {
444 MaybeRecordPersistentType(*i);
445 }
446}
447
448void
449ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D)
450{
451 if (!D->getIdentifier())
452 return;
453
454 StringRef name = D->getName();
455
456 if (name.size() == 0 || name[0] != '$')
457 return;
458
459 lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
460
461 ConstString name_cs(name.str().c_str());
462
463 if (log)
464 log->Printf ("Recording persistent type %s\n", name_cs.GetCString());
465
Sean Callanan0eed0d42011-12-06 03:41:14 +0000466 Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(m_target.GetScratchClangASTContext()->getASTContext(),
467 m_ast_context,
468 D);
Sean Callananbccce812011-08-23 21:20:51 +0000469
Sean Callanan0eed0d42011-12-06 03:41:14 +0000470 if (TypeDecl *TypeDecl_scratch = dyn_cast<TypeDecl>(D_scratch))
471 m_target.GetPersistentVariables().RegisterPersistentType(name_cs, TypeDecl_scratch);
Sean Callananbccce812011-08-23 21:20:51 +0000472}
473
Sean Callanan116be532010-07-01 20:08:22 +0000474void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000475ASTResultSynthesizer::HandleTagDeclDefinition(TagDecl *D)
Sean Callananbccce812011-08-23 21:20:51 +0000476{
Sean Callanan116be532010-07-01 20:08:22 +0000477 if (m_passthrough)
478 m_passthrough->HandleTagDeclDefinition(D);
479}
480
481void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000482ASTResultSynthesizer::CompleteTentativeDefinition(VarDecl *D)
Sean Callanan116be532010-07-01 20:08:22 +0000483{
484 if (m_passthrough)
485 m_passthrough->CompleteTentativeDefinition(D);
486}
487
488void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000489ASTResultSynthesizer::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired)
Sean Callanan116be532010-07-01 20:08:22 +0000490{
491 if (m_passthrough)
492 m_passthrough->HandleVTable(RD, DefinitionRequired);
493}
494
495void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000496ASTResultSynthesizer::PrintStats()
Sean Callanan116be532010-07-01 20:08:22 +0000497{
498 if (m_passthrough)
499 m_passthrough->PrintStats();
500}
501
502void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000503ASTResultSynthesizer::InitializeSema(Sema &S)
Sean Callanan116be532010-07-01 20:08:22 +0000504{
505 m_sema = &S;
Sean Callanan116be532010-07-01 20:08:22 +0000506
507 if (m_passthrough_sema)
508 m_passthrough_sema->InitializeSema(S);
509}
510
511void
Sean Callanan1a8d4092010-08-27 01:01:44 +0000512ASTResultSynthesizer::ForgetSema()
Sean Callanan116be532010-07-01 20:08:22 +0000513{
514 m_sema = NULL;
Sean Callanan116be532010-07-01 20:08:22 +0000515
516 if (m_passthrough_sema)
517 m_passthrough_sema->ForgetSema();
518}