Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 1 | //===-- ASTResultSynthesizer.cpp --------------------------------*- C++ -*-===// |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 2 | // |
| 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 Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 15 | #include "clang/AST/DeclObjC.h" |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 16 | #include "clang/AST/Expr.h" |
| 17 | #include "clang/AST/Stmt.h" |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 18 | #include "clang/Parse/Parser.h" |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Casting.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
| 21 | #include "lldb/Core/Log.h" |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 22 | #include "lldb/Expression/ASTResultSynthesizer.h" |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace llvm; |
| 25 | using namespace clang; |
| 26 | using namespace lldb_private; |
| 27 | |
Sean Callanan | f7c3e27 | 2010-11-19 02:52:21 +0000 | [diff] [blame] | 28 | ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough, |
| 29 | TypeFromUser desired_type) : |
Greg Clayton | c8e11e1 | 2010-07-12 23:14:00 +0000 | [diff] [blame] | 30 | m_ast_context (NULL), |
| 31 | m_passthrough (passthrough), |
| 32 | m_passthrough_sema (NULL), |
Sean Callanan | f7c3e27 | 2010-11-19 02:52:21 +0000 | [diff] [blame] | 33 | m_sema (NULL), |
| 34 | m_desired_type (desired_type) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 35 | { |
| 36 | if (!m_passthrough) |
| 37 | return; |
| 38 | |
| 39 | m_passthrough_sema = dyn_cast<SemaConsumer>(passthrough); |
| 40 | } |
| 41 | |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 42 | ASTResultSynthesizer::~ASTResultSynthesizer() |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 43 | { |
| 44 | } |
| 45 | |
| 46 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 47 | ASTResultSynthesizer::Initialize(ASTContext &Context) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 48 | { |
| 49 | m_ast_context = &Context; |
| 50 | |
| 51 | if (m_passthrough) |
| 52 | m_passthrough->Initialize(Context); |
| 53 | } |
| 54 | |
| 55 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 56 | ASTResultSynthesizer::TransformTopLevelDecl(Decl* D) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 57 | { |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 58 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 59 | |
| 60 | if (NamedDecl *named_decl = dyn_cast<NamedDecl>(D)) |
| 61 | { |
| 62 | if (log) |
| 63 | { |
| 64 | if (named_decl->getIdentifier()) |
| 65 | log->Printf("TransformTopLevelDecl(%s)", named_decl->getIdentifier()->getNameStart()); |
| 66 | else if (ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(D)) |
| 67 | log->Printf("TransformTopLevelDecl(%s)", method_decl->getSelector().getAsString().c_str()); |
| 68 | else |
| 69 | log->Printf("TransformTopLevelDecl(<complex>)"); |
| 70 | } |
| 71 | |
| 72 | } |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 73 | |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 74 | if (LinkageSpecDecl *linkage_spec_decl = dyn_cast<LinkageSpecDecl>(D)) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 75 | { |
| 76 | RecordDecl::decl_iterator decl_iterator; |
| 77 | |
| 78 | for (decl_iterator = linkage_spec_decl->decls_begin(); |
| 79 | decl_iterator != linkage_spec_decl->decls_end(); |
| 80 | ++decl_iterator) |
| 81 | { |
| 82 | TransformTopLevelDecl(*decl_iterator); |
| 83 | } |
| 84 | } |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 85 | else if (ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(D)) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 86 | { |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 87 | if (m_ast_context && |
| 88 | !method_decl->getSelector().getAsString().compare("$__lldb_expr:")) |
| 89 | { |
| 90 | SynthesizeObjCMethodResult(method_decl); |
| 91 | } |
| 92 | } |
| 93 | else if (FunctionDecl *function_decl = dyn_cast<FunctionDecl>(D)) |
| 94 | { |
| 95 | if (m_ast_context && |
| 96 | !function_decl->getNameInfo().getAsString().compare("$__lldb_expr")) |
| 97 | { |
| 98 | SynthesizeFunctionResult(function_decl); |
| 99 | } |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | |
| 103 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 104 | ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 105 | { |
| 106 | DeclGroupRef::iterator decl_iterator; |
| 107 | |
| 108 | for (decl_iterator = D.begin(); |
| 109 | decl_iterator != D.end(); |
| 110 | ++decl_iterator) |
| 111 | { |
| 112 | Decl *decl = *decl_iterator; |
| 113 | |
| 114 | TransformTopLevelDecl(decl); |
| 115 | } |
| 116 | |
| 117 | if (m_passthrough) |
| 118 | m_passthrough->HandleTopLevelDecl(D); |
| 119 | } |
| 120 | |
| 121 | bool |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 122 | ASTResultSynthesizer::SynthesizeFunctionResult (FunctionDecl *FunDecl) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 123 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 124 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 125 | |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 126 | ASTContext &Ctx(*m_ast_context); |
| 127 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 128 | if (!m_sema) |
| 129 | return false; |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 130 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 131 | FunctionDecl *function_decl = FunDecl; |
| 132 | |
| 133 | if (!function_decl) |
| 134 | return false; |
| 135 | |
Jim Ingham | e3be0c5 | 2011-01-22 01:25:40 +0000 | [diff] [blame] | 136 | if (log && log->GetVerbose()) |
Sean Callanan | 9e6ed53 | 2010-09-13 21:34:21 +0000 | [diff] [blame] | 137 | { |
| 138 | std::string s; |
| 139 | raw_string_ostream os(s); |
| 140 | |
Sean Callanan | c31ba26 | 2010-09-22 00:33:31 +0000 | [diff] [blame] | 141 | Ctx.getTranslationUnitDecl()->print(os); |
Sean Callanan | 9e6ed53 | 2010-09-13 21:34:21 +0000 | [diff] [blame] | 142 | |
| 143 | os.flush(); |
| 144 | |
Sean Callanan | c31ba26 | 2010-09-22 00:33:31 +0000 | [diff] [blame] | 145 | log->Printf("AST context before transforming:\n%s", s.c_str()); |
Sean Callanan | 9e6ed53 | 2010-09-13 21:34:21 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 148 | Stmt *function_body = function_decl->getBody(); |
| 149 | CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(function_body); |
| 150 | |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 151 | bool ret = SynthesizeBodyResult (compound_stmt, |
| 152 | function_decl); |
Jim Ingham | e3be0c5 | 2011-01-22 01:25:40 +0000 | [diff] [blame] | 153 | |
| 154 | if (log && log->GetVerbose()) |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 155 | { |
| 156 | std::string s; |
| 157 | raw_string_ostream os(s); |
| 158 | |
| 159 | function_decl->print(os); |
| 160 | |
| 161 | os.flush(); |
| 162 | |
Jim Ingham | e3be0c5 | 2011-01-22 01:25:40 +0000 | [diff] [blame] | 163 | log->Printf ("Transformed function AST:\n%s", s.c_str()); |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | return ret; |
| 167 | } |
| 168 | |
| 169 | bool |
| 170 | ASTResultSynthesizer::SynthesizeObjCMethodResult (ObjCMethodDecl *MethodDecl) |
| 171 | { |
| 172 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 173 | |
| 174 | ASTContext &Ctx(*m_ast_context); |
| 175 | |
| 176 | if (!m_sema) |
| 177 | return false; |
| 178 | |
| 179 | if (!MethodDecl) |
| 180 | return false; |
| 181 | |
Jim Ingham | e3be0c5 | 2011-01-22 01:25:40 +0000 | [diff] [blame] | 182 | if (log && log->GetVerbose()) |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 183 | { |
| 184 | std::string s; |
| 185 | raw_string_ostream os(s); |
| 186 | |
| 187 | Ctx.getTranslationUnitDecl()->print(os); |
| 188 | |
| 189 | os.flush(); |
| 190 | |
| 191 | log->Printf("AST context before transforming:\n%s", s.c_str()); |
| 192 | } |
| 193 | |
| 194 | Stmt *method_body = MethodDecl->getBody(); |
| 195 | CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(method_body); |
| 196 | |
| 197 | bool ret = SynthesizeBodyResult (compound_stmt, |
| 198 | MethodDecl); |
| 199 | |
| 200 | if (log) |
| 201 | { |
| 202 | std::string s; |
| 203 | raw_string_ostream os(s); |
| 204 | |
| 205 | MethodDecl->print(os); |
| 206 | |
| 207 | os.flush(); |
| 208 | |
| 209 | log->Printf("Transformed function AST:\n%s", s.c_str()); |
| 210 | } |
| 211 | |
| 212 | return ret; |
| 213 | } |
| 214 | |
| 215 | bool |
| 216 | ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body, |
| 217 | DeclContext *DC) |
| 218 | { |
| 219 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 220 | |
| 221 | ASTContext &Ctx(*m_ast_context); |
| 222 | |
| 223 | CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(Body); |
| 224 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 225 | if (!compound_stmt) |
| 226 | return false; |
| 227 | |
| 228 | if (compound_stmt->body_empty()) |
| 229 | return false; |
| 230 | |
| 231 | Stmt **last_stmt_ptr = compound_stmt->body_end() - 1; |
| 232 | Stmt *last_stmt = *last_stmt_ptr; |
| 233 | |
Sean Callanan | 9e6ed53 | 2010-09-13 21:34:21 +0000 | [diff] [blame] | 234 | while (dyn_cast<NullStmt>(last_stmt)) |
| 235 | { |
| 236 | if (last_stmt_ptr != compound_stmt->body_begin()) |
| 237 | { |
| 238 | last_stmt_ptr--; |
| 239 | last_stmt = *last_stmt_ptr; |
| 240 | } |
Sean Callanan | 2d1f4be | 2011-02-22 21:52:56 +0000 | [diff] [blame^] | 241 | else |
| 242 | { |
| 243 | return false; |
| 244 | } |
Sean Callanan | 9e6ed53 | 2010-09-13 21:34:21 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 247 | Expr *last_expr = dyn_cast<Expr>(last_stmt); |
| 248 | |
| 249 | if (!last_expr) |
| 250 | // No auxiliary variable necessary; expression returns void |
| 251 | return true; |
| 252 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 253 | // is_lvalue is used to record whether the expression returns an assignable Lvalue or an |
| 254 | // Rvalue. This is relevant because they are handled differently. |
| 255 | // |
| 256 | // For Lvalues |
| 257 | // |
| 258 | // - In AST result synthesis (here!) the expression E is transformed into an initialization |
| 259 | // T *$__lldb_expr_result_ptr = &E. |
| 260 | // |
| 261 | // - In structure allocation, a pointer-sized slot is allocated in the struct that is to be |
| 262 | // passed into the expression. |
| 263 | // |
| 264 | // - In IR transformations, reads and writes to $__lldb_expr_result_ptr are redirected at |
| 265 | // an entry in the struct ($__lldb_arg) passed into the expression. (Other persistent |
| 266 | // variables are treated similarly, having been materialized as references, but in those |
| 267 | // cases the value of the reference itself is never modified.) |
| 268 | // |
| 269 | // - During materialization, $0 (the result persistent variable) is ignored. |
| 270 | // |
| 271 | // - During dematerialization, $0 is marked up as a load address with value equal to the |
| 272 | // contents of the structure entry. |
| 273 | // |
| 274 | // For Rvalues |
| 275 | // |
| 276 | // - In AST result synthesis the expression E is transformed into an initialization |
| 277 | // static T $__lldb_expr_result = E. |
| 278 | // |
| 279 | // - In structure allocation, a pointer-sized slot is allocated in the struct that is to be |
| 280 | // passed into the expression. |
| 281 | // |
| 282 | // - In IR transformations, an instruction is inserted at the beginning of the function to |
| 283 | // dereference the pointer resident in the slot. Reads and writes to $__lldb_expr_result |
| 284 | // are redirected at that dereferenced version. Guard variables for the static variable |
| 285 | // are excised. |
| 286 | // |
| 287 | // - During materialization, $0 (the result persistent variable) is populated with the location |
| 288 | // of a newly-allocated area of memory. |
| 289 | // |
| 290 | // - During dematerialization, $0 is ignored. |
| 291 | |
| 292 | bool is_lvalue = |
| 293 | (last_expr->getValueKind() == VK_LValue || last_expr->getValueKind() == VK_XValue) && |
| 294 | (last_expr->getObjectKind() == OK_Ordinary); |
| 295 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 296 | QualType expr_qual_type = last_expr->getType(); |
Sean Callanan | 78e3760 | 2011-01-27 04:42:51 +0000 | [diff] [blame] | 297 | const clang::Type *expr_type = expr_qual_type.getTypePtr(); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 298 | |
| 299 | if (!expr_type) |
| 300 | return false; |
| 301 | |
| 302 | if (expr_type->isVoidType()) |
| 303 | return true; |
| 304 | |
| 305 | if (log) |
| 306 | { |
| 307 | std::string s = expr_qual_type.getAsString(); |
| 308 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 309 | log->Printf("Last statement is an %s with type: %s", (is_lvalue ? "lvalue" : "rvalue"), s.c_str()); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 312 | clang::VarDecl *result_decl; |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 313 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 314 | if (is_lvalue) |
| 315 | { |
| 316 | IdentifierInfo &result_ptr_id = Ctx.Idents.get("$__lldb_expr_result_ptr"); |
| 317 | |
| 318 | QualType ptr_qual_type = Ctx.getPointerType(expr_qual_type); |
| 319 | |
| 320 | result_decl = VarDecl::Create(Ctx, |
| 321 | DC, |
| 322 | SourceLocation(), |
| 323 | &result_ptr_id, |
| 324 | ptr_qual_type, |
| 325 | NULL, |
| 326 | SC_Static, |
| 327 | SC_Static); |
| 328 | |
| 329 | if (!result_decl) |
| 330 | return false; |
| 331 | |
| 332 | ExprResult address_of_expr = m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr); |
| 333 | |
| 334 | m_sema->AddInitializerToDecl(result_decl, address_of_expr.take()); |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | IdentifierInfo &result_id = Ctx.Idents.get("$__lldb_expr_result"); |
| 339 | |
| 340 | result_decl = VarDecl::Create(Ctx, |
| 341 | DC, |
| 342 | SourceLocation(), |
| 343 | &result_id, |
| 344 | expr_qual_type, |
| 345 | NULL, |
| 346 | SC_Static, |
| 347 | SC_Static); |
| 348 | |
| 349 | if (!result_decl) |
| 350 | return false; |
| 351 | |
| 352 | m_sema->AddInitializerToDecl(result_decl, last_expr); |
| 353 | } |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 354 | |
Sean Callanan | 1782783 | 2010-12-13 22:46:15 +0000 | [diff] [blame] | 355 | DC->addDecl(result_decl); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 356 | |
| 357 | /////////////////////////////// |
| 358 | // call AddInitializerToDecl |
| 359 | // |
Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 360 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 361 | //m_sema->AddInitializerToDecl(result_decl, last_expr); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 362 | |
| 363 | ///////////////////////////////// |
| 364 | // call ConvertDeclToDeclGroup |
| 365 | // |
| 366 | |
Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 367 | Sema::DeclGroupPtrTy result_decl_group_ptr; |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 368 | |
Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 369 | result_decl_group_ptr = m_sema->ConvertDeclToDeclGroup(result_decl); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 370 | |
| 371 | //////////////////////// |
| 372 | // call ActOnDeclStmt |
| 373 | // |
| 374 | |
Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 375 | StmtResult result_initialization_stmt_result(m_sema->ActOnDeclStmt(result_decl_group_ptr, |
| 376 | SourceLocation(), |
| 377 | SourceLocation())); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 378 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 379 | //////////////////////////////////////////////// |
| 380 | // replace the old statement with the new one |
| 381 | // |
| 382 | |
Sean Callanan | ddb46ef | 2010-07-24 01:37:44 +0000 | [diff] [blame] | 383 | *last_stmt_ptr = reinterpret_cast<Stmt*>(result_initialization_stmt_result.take()); |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 384 | |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 385 | return true; |
| 386 | } |
| 387 | |
| 388 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 389 | ASTResultSynthesizer::HandleTranslationUnit(ASTContext &Ctx) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 390 | { |
| 391 | if (m_passthrough) |
| 392 | m_passthrough->HandleTranslationUnit(Ctx); |
| 393 | } |
| 394 | |
| 395 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 396 | ASTResultSynthesizer::HandleTagDeclDefinition(TagDecl *D) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 397 | { |
| 398 | if (m_passthrough) |
| 399 | m_passthrough->HandleTagDeclDefinition(D); |
| 400 | } |
| 401 | |
| 402 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 403 | ASTResultSynthesizer::CompleteTentativeDefinition(VarDecl *D) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 404 | { |
| 405 | if (m_passthrough) |
| 406 | m_passthrough->CompleteTentativeDefinition(D); |
| 407 | } |
| 408 | |
| 409 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 410 | ASTResultSynthesizer::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 411 | { |
| 412 | if (m_passthrough) |
| 413 | m_passthrough->HandleVTable(RD, DefinitionRequired); |
| 414 | } |
| 415 | |
| 416 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 417 | ASTResultSynthesizer::PrintStats() |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 418 | { |
| 419 | if (m_passthrough) |
| 420 | m_passthrough->PrintStats(); |
| 421 | } |
| 422 | |
| 423 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 424 | ASTResultSynthesizer::InitializeSema(Sema &S) |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 425 | { |
| 426 | m_sema = &S; |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 427 | |
| 428 | if (m_passthrough_sema) |
| 429 | m_passthrough_sema->InitializeSema(S); |
| 430 | } |
| 431 | |
| 432 | void |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 433 | ASTResultSynthesizer::ForgetSema() |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 434 | { |
| 435 | m_sema = NULL; |
Sean Callanan | 116be53 | 2010-07-01 20:08:22 +0000 | [diff] [blame] | 436 | |
| 437 | if (m_passthrough_sema) |
| 438 | m_passthrough_sema->ForgetSema(); |
| 439 | } |