Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===// |
| 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 "lldb/Expression/ClangExpressionDeclMap.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/lldb-private.h" |
| 17 | #include "lldb/Core/Address.h" |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Error.h" |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Module.h" |
| 21 | #include "lldb/Expression/ClangASTSource.h" |
| 22 | #include "lldb/Symbol/ClangASTContext.h" |
| 23 | #include "lldb/Symbol/CompileUnit.h" |
| 24 | #include "lldb/Symbol/Function.h" |
| 25 | #include "lldb/Symbol/ObjectFile.h" |
| 26 | #include "lldb/Symbol/SymbolContext.h" |
| 27 | #include "lldb/Symbol/Type.h" |
| 28 | #include "lldb/Symbol/TypeList.h" |
| 29 | #include "lldb/Symbol/Variable.h" |
| 30 | #include "lldb/Symbol/VariableList.h" |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 31 | #include "lldb/Target/ExecutionContext.h" |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 32 | #include "lldb/Target/Process.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | #include "lldb/Target/StackFrame.h" |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 34 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | using namespace lldb_private; |
| 37 | using namespace clang; |
| 38 | |
| 39 | ClangExpressionDeclMap::ClangExpressionDeclMap(ExecutionContext *exe_ctx) : |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 40 | m_exe_ctx(exe_ctx), |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 41 | m_struct_laid_out(false), |
| 42 | m_materialized_location(0) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | { |
| 44 | if (exe_ctx && exe_ctx->frame) |
| 45 | m_sym_ctx = new SymbolContext(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); |
| 46 | else |
| 47 | m_sym_ctx = NULL; |
| 48 | } |
| 49 | |
| 50 | ClangExpressionDeclMap::~ClangExpressionDeclMap() |
| 51 | { |
| 52 | uint32_t num_tuples = m_tuples.size (); |
| 53 | uint32_t tuple_index; |
| 54 | |
| 55 | for (tuple_index = 0; tuple_index < num_tuples; ++tuple_index) |
| 56 | delete m_tuples[tuple_index].m_value; |
| 57 | |
| 58 | if (m_sym_ctx) |
| 59 | delete m_sym_ctx; |
| 60 | } |
| 61 | |
| 62 | bool |
| 63 | ClangExpressionDeclMap::GetIndexForDecl (uint32_t &index, |
| 64 | const clang::Decl *decl) |
| 65 | { |
| 66 | uint32_t num_tuples = m_tuples.size (); |
| 67 | uint32_t tuple_index; |
| 68 | |
| 69 | for (tuple_index = 0; tuple_index < num_tuples; ++tuple_index) |
| 70 | { |
| 71 | if (m_tuples[tuple_index].m_decl == decl) |
| 72 | { |
| 73 | index = tuple_index; |
| 74 | return true; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return false; |
| 79 | } |
| 80 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 81 | // Interface for IRForTarget |
| 82 | |
| 83 | bool |
| 84 | ClangExpressionDeclMap::AddValueToStruct (llvm::Value *value, |
| 85 | const clang::NamedDecl *decl, |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 86 | std::string &name, |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 87 | void *parser_type, |
| 88 | clang::ASTContext *parser_ast_context, |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 89 | size_t size, |
| 90 | off_t alignment) |
| 91 | { |
| 92 | m_struct_laid_out = false; |
| 93 | |
| 94 | StructMemberIterator iter; |
| 95 | |
| 96 | for (iter = m_members.begin(); |
| 97 | iter != m_members.end(); |
| 98 | ++iter) |
| 99 | { |
| 100 | if (iter->m_decl == decl) |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | StructMember member; |
| 105 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 106 | member.m_value = value; |
| 107 | member.m_decl = decl; |
| 108 | member.m_name = name; |
| 109 | member.m_parser_type = TypeFromParser(parser_type, parser_ast_context); |
| 110 | member.m_offset = 0; |
| 111 | member.m_size = size; |
| 112 | member.m_alignment = alignment; |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 113 | |
| 114 | m_members.push_back(member); |
| 115 | |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | bool |
| 120 | ClangExpressionDeclMap::DoStructLayout () |
| 121 | { |
| 122 | if (m_struct_laid_out) |
| 123 | return true; |
| 124 | |
| 125 | StructMemberIterator iter; |
| 126 | |
| 127 | off_t cursor = 0; |
| 128 | |
| 129 | m_struct_alignment = 0; |
| 130 | m_struct_size = 0; |
| 131 | |
| 132 | for (iter = m_members.begin(); |
| 133 | iter != m_members.end(); |
| 134 | ++iter) |
| 135 | { |
| 136 | if (iter == m_members.begin()) |
| 137 | m_struct_alignment = iter->m_alignment; |
| 138 | |
| 139 | if (cursor % iter->m_alignment) |
| 140 | cursor += (iter->m_alignment - (cursor % iter->m_alignment)); |
| 141 | |
| 142 | iter->m_offset = cursor; |
| 143 | cursor += iter->m_size; |
| 144 | } |
| 145 | |
| 146 | m_struct_size = cursor; |
| 147 | |
| 148 | m_struct_laid_out = true; |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | bool ClangExpressionDeclMap::GetStructInfo (uint32_t &num_elements, |
| 153 | size_t &size, |
| 154 | off_t &alignment) |
| 155 | { |
| 156 | if (!m_struct_laid_out) |
| 157 | return false; |
| 158 | |
| 159 | num_elements = m_members.size(); |
| 160 | size = m_struct_size; |
| 161 | alignment = m_struct_alignment; |
| 162 | |
| 163 | return true; |
| 164 | } |
| 165 | |
| 166 | bool |
| 167 | ClangExpressionDeclMap::GetStructElement (const clang::NamedDecl *&decl, |
| 168 | llvm::Value *&value, |
| 169 | off_t &offset, |
| 170 | uint32_t index) |
| 171 | { |
| 172 | if (!m_struct_laid_out) |
| 173 | return false; |
| 174 | |
| 175 | if (index >= m_members.size()) |
| 176 | return false; |
| 177 | |
| 178 | decl = m_members[index].m_decl; |
| 179 | value = m_members[index].m_value; |
| 180 | offset = m_members[index].m_offset; |
| 181 | |
| 182 | return true; |
| 183 | } |
| 184 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 185 | // Interface for DwarfExpression |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 186 | lldb_private::Value |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 187 | *ClangExpressionDeclMap::GetValueForIndex (uint32_t index) |
| 188 | { |
| 189 | if (index >= m_tuples.size ()) |
| 190 | return NULL; |
| 191 | |
| 192 | return m_tuples[index].m_value; |
| 193 | } |
| 194 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 195 | // Interface for CommandObjectExpression |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 196 | |
| 197 | bool |
| 198 | ClangExpressionDeclMap::Materialize (ExecutionContext *exe_ctx, |
| 199 | lldb::addr_t &struct_address, |
| 200 | Error &err) |
| 201 | { |
| 202 | bool result = DoMaterialize(false, exe_ctx, NULL, err); |
| 203 | |
| 204 | if (result) |
| 205 | struct_address = m_materialized_location; |
| 206 | |
| 207 | return result; |
| 208 | } |
| 209 | |
| 210 | bool |
| 211 | ClangExpressionDeclMap::Dematerialize (ExecutionContext *exe_ctx, |
| 212 | lldb_private::Value &result_value, |
| 213 | Error &err) |
| 214 | { |
| 215 | return DoMaterialize(true, exe_ctx, &result_value, err); |
| 216 | } |
| 217 | |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 218 | bool |
| 219 | ClangExpressionDeclMap::DumpMaterializedStruct(ExecutionContext *exe_ctx, |
| 220 | Stream &s, |
| 221 | Error &err) |
| 222 | { |
| 223 | if (!m_struct_laid_out) |
| 224 | { |
| 225 | err.SetErrorString("Structure hasn't been laid out yet"); |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | if (!exe_ctx) |
| 230 | { |
| 231 | err.SetErrorString("Received null execution context"); |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | |
| 236 | if (!exe_ctx->process) |
| 237 | { |
| 238 | err.SetErrorString("Couldn't find the process"); |
| 239 | return false; |
| 240 | } |
| 241 | |
| 242 | if (!exe_ctx->target) |
| 243 | { |
| 244 | err.SetErrorString("Couldn't find the target"); |
| 245 | return false; |
| 246 | } |
| 247 | |
| 248 | lldb::DataBufferSP data(new DataBufferHeap(m_struct_size, 0)); |
| 249 | |
| 250 | Error error; |
| 251 | if (exe_ctx->process->ReadMemory (m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) |
| 252 | { |
| 253 | err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString()); |
| 254 | return false; |
| 255 | } |
| 256 | |
| 257 | DataExtractor extractor(data, exe_ctx->process->GetByteOrder(), exe_ctx->target->GetArchitecture().GetAddressByteSize()); |
| 258 | |
| 259 | StructMemberIterator iter; |
| 260 | |
| 261 | for (iter = m_members.begin(); |
| 262 | iter != m_members.end(); |
| 263 | ++iter) |
| 264 | { |
| 265 | s.Printf("[%s]\n", iter->m_name.c_str()); |
| 266 | |
| 267 | extractor.Dump(&s, // stream |
| 268 | iter->m_offset, // offset |
| 269 | lldb::eFormatBytesWithASCII, // format |
| 270 | 1, // byte size of individual entries |
| 271 | iter->m_size, // number of entries |
| 272 | 16, // entries per line |
| 273 | m_materialized_location + iter->m_offset, // address to print |
| 274 | 0, // bit size (bitfields only; 0 means ignore) |
| 275 | 0); // bit alignment (bitfields only; 0 means ignore) |
| 276 | |
| 277 | s.PutChar('\n'); |
| 278 | } |
| 279 | |
| 280 | return true; |
| 281 | } |
| 282 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 283 | bool |
| 284 | ClangExpressionDeclMap::DoMaterialize (bool dematerialize, |
| 285 | ExecutionContext *exe_ctx, |
| 286 | lldb_private::Value *result_value, |
| 287 | Error &err) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 288 | { |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 289 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 290 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 291 | if (!m_struct_laid_out) |
| 292 | { |
| 293 | err.SetErrorString("Structure hasn't been laid out yet"); |
| 294 | return LLDB_INVALID_ADDRESS; |
| 295 | } |
| 296 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 297 | if (!exe_ctx) |
| 298 | { |
| 299 | err.SetErrorString("Received null execution context"); |
| 300 | return LLDB_INVALID_ADDRESS; |
| 301 | } |
| 302 | |
Sean Callanan | 4583927 | 2010-07-24 01:37:44 +0000 | [diff] [blame] | 303 | if (!exe_ctx->frame) |
| 304 | { |
| 305 | err.SetErrorString("Received null execution frame"); |
| 306 | return LLDB_INVALID_ADDRESS; |
| 307 | } |
| 308 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 309 | const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); |
| 310 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 311 | if (!dematerialize) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 312 | { |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 313 | if (m_materialized_location) |
| 314 | { |
| 315 | exe_ctx->process->DeallocateMemory(m_materialized_location); |
| 316 | m_materialized_location = 0; |
| 317 | } |
| 318 | |
| 319 | lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, |
| 320 | lldb::ePermissionsReadable | lldb::ePermissionsWritable, |
| 321 | err); |
| 322 | |
| 323 | if (mem == LLDB_INVALID_ADDRESS) |
| 324 | return false; |
| 325 | |
| 326 | m_allocated_area = mem; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 327 | } |
| 328 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 329 | m_materialized_location = m_allocated_area; |
| 330 | |
| 331 | if (m_materialized_location % m_struct_alignment) |
| 332 | { |
| 333 | m_materialized_location += (m_struct_alignment - (m_materialized_location % m_struct_alignment)); |
| 334 | } |
| 335 | |
| 336 | StructMemberIterator iter; |
| 337 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 338 | for (iter = m_members.begin(); |
| 339 | iter != m_members.end(); |
| 340 | ++iter) |
| 341 | { |
| 342 | uint32_t tuple_index; |
| 343 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 344 | if (!GetIndexForDecl(tuple_index, iter->m_decl)) |
| 345 | { |
| 346 | if (iter->m_name.find("___clang_expr_result") == std::string::npos) |
| 347 | { |
| 348 | err.SetErrorStringWithFormat("Unexpected variable %s", iter->m_name.c_str()); |
| 349 | return false; |
| 350 | } |
| 351 | |
| 352 | if (log) |
| 353 | log->Printf("Found special result variable %s", iter->m_name.c_str()); |
| 354 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 355 | if (dematerialize) |
| 356 | { |
| 357 | clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); |
| 358 | |
| 359 | if (!context) |
| 360 | { |
| 361 | err.SetErrorString("Couldn't find a scratch AST context to put the result type into"); |
| 362 | } |
| 363 | |
| 364 | TypeFromUser copied_type(ClangASTContext::CopyType(context, |
| 365 | iter->m_parser_type.GetASTContext(), |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 366 | iter->m_parser_type.GetOpaqueQualType()), |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 367 | context); |
| 368 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 369 | result_value->SetContext(Value::eContextTypeOpaqueClangQualType, copied_type.GetOpaqueQualType()); |
| 370 | |
| 371 | result_value->SetValueType(Value::eValueTypeLoadAddress); |
| 372 | result_value->GetScalar() = (uintptr_t)m_materialized_location + iter->m_offset; |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 375 | continue; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 376 | } |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 377 | |
| 378 | Tuple &tuple(m_tuples[tuple_index]); |
| 379 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 380 | if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, iter->m_name.c_str(), tuple.m_user_type, m_materialized_location + iter->m_offset, err)) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 381 | return false; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 382 | } |
| 383 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 384 | return true; |
| 385 | } |
| 386 | |
| 387 | bool |
| 388 | ClangExpressionDeclMap::DoMaterializeOneVariable(bool dematerialize, |
| 389 | ExecutionContext &exe_ctx, |
| 390 | const SymbolContext &sym_ctx, |
| 391 | const char *name, |
| 392 | TypeFromUser type, |
| 393 | lldb::addr_t addr, |
| 394 | Error &err) |
| 395 | { |
| 396 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 397 | |
| 398 | Variable *var = FindVariableInScope(sym_ctx, name, &type); |
| 399 | |
| 400 | if (!var) |
| 401 | { |
| 402 | err.SetErrorStringWithFormat("Couldn't find %s with appropriate type", name); |
| 403 | return false; |
| 404 | } |
| 405 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 406 | if (log) |
| 407 | log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name, type.GetOpaqueQualType()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 408 | |
| 409 | std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(exe_ctx, |
| 410 | var, |
| 411 | type.GetASTContext())); |
| 412 | |
| 413 | if (!location_value.get()) |
| 414 | { |
| 415 | err.SetErrorStringWithFormat("Couldn't get value for %s", name); |
| 416 | return false; |
| 417 | } |
| 418 | |
| 419 | if (location_value->GetValueType() == Value::eValueTypeLoadAddress) |
| 420 | { |
| 421 | lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); |
| 422 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 423 | size_t bit_size = ClangASTContext::GetTypeBitSize(type.GetASTContext(), type.GetOpaqueQualType()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 424 | size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); |
| 425 | |
| 426 | DataBufferHeap data; |
| 427 | data.SetByteSize(byte_size); |
| 428 | |
| 429 | lldb::addr_t src_addr; |
| 430 | lldb::addr_t dest_addr; |
| 431 | |
| 432 | if (dematerialize) |
| 433 | { |
| 434 | src_addr = addr; |
| 435 | dest_addr = value_addr; |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | src_addr = value_addr; |
| 440 | dest_addr = addr; |
| 441 | } |
| 442 | |
| 443 | Error error; |
| 444 | if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), byte_size, error) != byte_size) |
| 445 | { |
| 446 | err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); |
| 447 | return false; |
| 448 | } |
| 449 | |
| 450 | if (exe_ctx.process->WriteMemory (dest_addr, data.GetBytes(), byte_size, error) != byte_size) |
| 451 | { |
| 452 | err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); |
| 453 | return false; |
| 454 | } |
| 455 | |
| 456 | if (log) |
| 457 | log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); |
| 458 | } |
| 459 | else |
| 460 | { |
| 461 | StreamString ss; |
| 462 | |
| 463 | location_value->Dump(&ss); |
| 464 | |
| 465 | err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name, ss.GetString().c_str()); |
| 466 | } |
| 467 | |
| 468 | return true; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 471 | Variable* |
| 472 | ClangExpressionDeclMap::FindVariableInScope(const SymbolContext &sym_ctx, |
| 473 | const char *name, |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 474 | TypeFromUser *type) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 475 | { |
| 476 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 477 | |
| 478 | Function *function(m_sym_ctx->function); |
| 479 | Block *block(m_sym_ctx->block); |
| 480 | |
| 481 | if (!function || !block) |
| 482 | { |
| 483 | if (log) |
| 484 | log->Printf("function = %p, block = %p", function, block); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 485 | return NULL; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | BlockList& blocks(function->GetBlocks(true)); |
| 489 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 490 | ConstString name_cs(name); |
| 491 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 492 | lldb::user_id_t current_block_id; |
| 493 | |
| 494 | for (current_block_id = block->GetID(); |
| 495 | current_block_id != Block::InvalidID; |
| 496 | current_block_id = blocks.GetParent(current_block_id)) |
| 497 | { |
| 498 | Block *current_block(blocks.GetBlockByID(current_block_id)); |
| 499 | |
| 500 | lldb::VariableListSP var_list = current_block->GetVariableList(false, true); |
| 501 | |
| 502 | if (!var_list) |
| 503 | continue; |
| 504 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 505 | lldb::VariableSP var = var_list->FindVariable(name_cs); |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 506 | |
| 507 | if (!var) |
| 508 | continue; |
| 509 | |
| 510 | // var->GetType()->GetClangAST() is the program's AST context and holds |
| 511 | // var->GetType()->GetOpaqueClangQualType(). |
| 512 | |
| 513 | // type is m_type for one of the struct members, which was added by |
| 514 | // AddValueToStruct. That type was extracted from the AST context of |
| 515 | // the compiler in IRForTarget. The original for the type was copied |
| 516 | // out of the program's AST context by AddOneVariable. |
| 517 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 518 | // So that we can compare these two without having to copy back |
| 519 | // something we already had in the original AST context, we maintain |
| 520 | // m_orig_type and m_ast_context (which are passed into |
| 521 | // MaterializeOneVariable by Materialize) for each variable. |
| 522 | |
| 523 | if (!type) |
| 524 | return var.get(); |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 525 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 526 | if (type->GetASTContext() == var->GetType()->GetClangAST()) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 527 | { |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 528 | if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type, var->GetType()->GetOpaqueClangQualType())) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 529 | continue; |
| 530 | } |
| 531 | else |
| 532 | { |
| 533 | if (log) |
| 534 | log->PutCString("Skipping a candidate variable because of different AST contexts"); |
| 535 | continue; |
| 536 | } |
| 537 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 538 | return var.get(); |
| 539 | } |
| 540 | |
| 541 | { |
| 542 | CompileUnit *compile_unit = m_sym_ctx->comp_unit; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 543 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 544 | if (!compile_unit) |
| 545 | { |
| 546 | if (log) |
| 547 | log->Printf("compile_unit = %p", compile_unit); |
| 548 | return NULL; |
| 549 | } |
| 550 | |
| 551 | lldb::VariableListSP var_list = compile_unit->GetVariableList(true); |
| 552 | |
| 553 | if (!var_list) |
| 554 | return NULL; |
| 555 | |
| 556 | lldb::VariableSP var = var_list->FindVariable(name_cs); |
| 557 | |
| 558 | if (!var) |
| 559 | return NULL; |
| 560 | |
| 561 | if (!type) |
| 562 | return var.get(); |
| 563 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 564 | if (type->GetASTContext() == var->GetType()->GetClangAST()) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 565 | { |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 566 | if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 567 | return NULL; |
| 568 | } |
| 569 | else |
| 570 | { |
| 571 | if (log) |
| 572 | log->PutCString("Skipping a candidate variable because of different AST contexts"); |
| 573 | return NULL; |
| 574 | } |
| 575 | |
| 576 | return var.get(); |
| 577 | } |
| 578 | |
| 579 | return NULL; |
| 580 | } |
| 581 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 582 | // Interface for ClangASTSource |
| 583 | void |
| 584 | ClangExpressionDeclMap::GetDecls(NameSearchContext &context, |
| 585 | const char *name) |
| 586 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 587 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 588 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 589 | if (log) |
| 590 | log->Printf("Hunting for a definition for %s", name); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 591 | |
| 592 | // Back out in all cases where we're not fully initialized |
| 593 | if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx) |
| 594 | return; |
| 595 | |
| 596 | Function *function = m_sym_ctx->function; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 597 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 598 | if (!function) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 599 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 600 | if (log) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 601 | log->Printf("Can't evaluate an expression when not in a function"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 602 | return; |
| 603 | } |
| 604 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 605 | ConstString name_cs(name); |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 606 | SymbolContextList sym_ctxs; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 607 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 608 | m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 609 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 610 | for (uint32_t index = 0, num_indices = sym_ctxs.GetSize(); |
| 611 | index < num_indices; |
| 612 | ++index) |
| 613 | { |
| 614 | SymbolContext sym_ctx; |
| 615 | sym_ctxs.GetContextAtIndex(index, sym_ctx); |
| 616 | |
| 617 | if (sym_ctx.function) |
| 618 | AddOneFunction(context, sym_ctx.function, NULL); |
| 619 | else if(sym_ctx.symbol) |
| 620 | AddOneFunction(context, NULL, sym_ctx.symbol); |
| 621 | } |
| 622 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 623 | Variable *var = FindVariableInScope(*m_sym_ctx, name); |
| 624 | |
| 625 | if (var) |
| 626 | AddOneVariable(context, var); |
| 627 | } |
| 628 | |
| 629 | Value * |
| 630 | ClangExpressionDeclMap::GetVariableValue(ExecutionContext &exe_ctx, |
| 631 | Variable *var, |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 632 | clang::ASTContext *parser_ast_context, |
| 633 | TypeFromUser *user_type, |
| 634 | TypeFromParser *parser_type) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 635 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 636 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 637 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 638 | Type *var_type = var->GetType(); |
| 639 | |
| 640 | if (!var_type) |
| 641 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 642 | if (log) |
| 643 | log->PutCString("Skipped a definition because it has no type"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 644 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | void *var_opaque_type = var_type->GetOpaqueClangQualType(); |
| 648 | |
| 649 | if (!var_opaque_type) |
| 650 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 651 | if (log) |
| 652 | log->PutCString("Skipped a definition because it has no Clang type"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 653 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 654 | } |
| 655 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 656 | TypeList *type_list = var_type->GetTypeList(); |
| 657 | |
| 658 | if (!type_list) |
| 659 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 660 | if (log) |
| 661 | log->PutCString("Skipped a definition because the type has no associated type list"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 662 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | clang::ASTContext *exe_ast_ctx = type_list->GetClangASTContext().getASTContext(); |
| 666 | |
| 667 | if (!exe_ast_ctx) |
| 668 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 669 | if (log) |
| 670 | log->PutCString("There is no AST context for the current execution context"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 671 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 674 | DWARFExpression &var_location_expr = var->LocationExpression(); |
| 675 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 676 | std::auto_ptr<Value> var_location(new Value); |
| 677 | |
| 678 | Error err; |
| 679 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 680 | if (!var_location_expr.Evaluate(&exe_ctx, exe_ast_ctx, NULL, *var_location.get(), &err)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 681 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 682 | if (log) |
| 683 | log->Printf("Error evaluating location: %s", err.AsCString()); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 684 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 685 | } |
| 686 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 687 | clang::ASTContext *var_ast_context = type_list->GetClangASTContext().getASTContext(); |
| 688 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 689 | void *type_to_use; |
| 690 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 691 | if (parser_ast_context) |
| 692 | { |
| 693 | type_to_use = ClangASTContext::CopyType(parser_ast_context, var_ast_context, var_opaque_type); |
| 694 | |
| 695 | if (parser_type) |
| 696 | *parser_type = TypeFromParser(type_to_use, parser_ast_context); |
| 697 | } |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 698 | else |
| 699 | type_to_use = var_opaque_type; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 700 | |
| 701 | if (var_location.get()->GetContextType() == Value::eContextTypeInvalid) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 702 | var_location.get()->SetContext(Value::eContextTypeOpaqueClangQualType, type_to_use); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 703 | |
| 704 | if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress) |
| 705 | { |
| 706 | SymbolContext var_sc; |
| 707 | var->CalculateSymbolContext(&var_sc); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 708 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 709 | if (!var_sc.module_sp) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 710 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 711 | |
| 712 | ObjectFile *object_file = var_sc.module_sp->GetObjectFile(); |
| 713 | |
| 714 | if (!object_file) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 715 | return NULL; |
| 716 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 717 | Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList()); |
| 718 | |
| 719 | lldb::addr_t load_addr = so_addr.GetLoadAddress(m_exe_ctx->process); |
| 720 | |
| 721 | var_location->GetScalar() = load_addr; |
| 722 | var_location->SetValueType(Value::eValueTypeLoadAddress); |
| 723 | } |
| 724 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 725 | if (user_type) |
| 726 | *user_type = TypeFromUser(var_opaque_type, var_ast_context); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 727 | |
| 728 | return var_location.release(); |
| 729 | } |
| 730 | |
| 731 | void |
| 732 | ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, |
| 733 | Variable* var) |
| 734 | { |
| 735 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 736 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 737 | TypeFromUser ut; |
| 738 | TypeFromParser pt; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 739 | |
| 740 | Value *var_location = GetVariableValue(*m_exe_ctx, |
| 741 | var, |
| 742 | context.GetASTContext(), |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 743 | &ut, |
| 744 | &pt); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 745 | |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 746 | NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 747 | |
| 748 | Tuple tuple; |
| 749 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 750 | tuple.m_decl = var_decl; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 751 | tuple.m_value = var_location; |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 752 | tuple.m_user_type = ut; |
| 753 | tuple.m_parser_type = pt; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 754 | |
| 755 | m_tuples.push_back(tuple); |
| 756 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 757 | if (log) |
| 758 | log->PutCString("Found variable"); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | void |
| 762 | ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 763 | Function* fun, |
| 764 | Symbol* symbol) |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 765 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 766 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 767 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 768 | NamedDecl *fun_decl; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 769 | std::auto_ptr<Value> fun_location(new Value); |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 770 | const Address *fun_address; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 771 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame^] | 772 | // only valid for Functions, not for Symbols |
| 773 | void *fun_opaque_type = NULL; |
| 774 | clang::ASTContext *fun_ast_context = NULL; |
| 775 | |
| 776 | if (fun) |
| 777 | { |
| 778 | Type *fun_type = fun->GetType(); |
| 779 | |
| 780 | if (!fun_type) |
| 781 | { |
| 782 | if (log) |
| 783 | log->PutCString("Skipped a function because it has no type"); |
| 784 | return; |
| 785 | } |
| 786 | |
| 787 | fun_opaque_type = fun_type->GetOpaqueClangQualType(); |
| 788 | |
| 789 | if (!fun_opaque_type) |
| 790 | { |
| 791 | if (log) |
| 792 | log->PutCString("Skipped a function because it has no Clang type"); |
| 793 | return; |
| 794 | } |
| 795 | |
| 796 | fun_address = &fun->GetAddressRange().GetBaseAddress(); |
| 797 | |
| 798 | TypeList *type_list = fun_type->GetTypeList(); |
| 799 | fun_ast_context = type_list->GetClangASTContext().getASTContext(); |
| 800 | void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type); |
| 801 | |
| 802 | fun_decl = context.AddFunDecl(copied_type); |
| 803 | } |
| 804 | else if (symbol) |
| 805 | { |
| 806 | fun_address = &symbol->GetAddressRangeRef().GetBaseAddress(); |
| 807 | |
| 808 | fun_decl = context.AddGenericFunDecl(); |
| 809 | } |
| 810 | else |
| 811 | { |
| 812 | if (log) |
| 813 | log->PutCString("AddOneFunction called with no function and no symbol"); |
| 814 | return; |
| 815 | } |
| 816 | |
| 817 | lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx->process); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 818 | fun_location->SetValueType(Value::eValueTypeLoadAddress); |
| 819 | fun_location->GetScalar() = load_addr; |
| 820 | |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 821 | Tuple tuple; |
| 822 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 823 | tuple.m_decl = fun_decl; |
| 824 | tuple.m_value = fun_location.release(); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 825 | tuple.m_user_type = TypeFromUser(fun_opaque_type, fun_ast_context); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 826 | |
| 827 | m_tuples.push_back(tuple); |
| 828 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 829 | if (log) |
| 830 | log->PutCString("Found function"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 831 | } |