Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- Function.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/Symbol/Function.h" |
| 11 | #include "lldb/Core/Module.h" |
| 12 | #include "lldb/Core/Section.h" |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 13 | #include "lldb/Symbol/ClangASTType.h" |
| 14 | #include "lldb/Symbol/ClangASTContext.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Symbol/CompileUnit.h" |
| 16 | #include "lldb/Symbol/LineTable.h" |
| 17 | #include "lldb/Symbol/SymbolVendor.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "clang/AST/Type.h" |
| 19 | #include "clang/AST/CanonicalType.h" |
| 20 | |
Greg Clayton | c67b7d1 | 2010-09-10 01:30:46 +0000 | [diff] [blame] | 21 | using namespace lldb; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | using namespace lldb_private; |
| 23 | |
| 24 | //---------------------------------------------------------------------- |
| 25 | // Basic function information is contained in the FunctionInfo class. |
| 26 | // It is designed to contain the name, linkage name, and declaration |
| 27 | // location. |
| 28 | //---------------------------------------------------------------------- |
| 29 | FunctionInfo::FunctionInfo (const char *name, const Declaration *decl_ptr) : |
| 30 | m_name(name), |
| 31 | m_declaration(decl_ptr) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | |
| 36 | FunctionInfo::FunctionInfo (const ConstString& name, const Declaration *decl_ptr) : |
| 37 | m_name(name), |
| 38 | m_declaration(decl_ptr) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | |
| 43 | FunctionInfo::~FunctionInfo() |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | void |
Greg Clayton | 1924e24 | 2010-09-15 05:51:24 +0000 | [diff] [blame] | 48 | FunctionInfo::Dump(Stream *s, bool show_fullpaths) const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | { |
| 50 | if (m_name) |
| 51 | *s << ", name = \"" << m_name << "\""; |
Greg Clayton | 1924e24 | 2010-09-15 05:51:24 +0000 | [diff] [blame] | 52 | m_declaration.Dump(s, show_fullpaths); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | |
| 56 | int |
| 57 | FunctionInfo::Compare(const FunctionInfo& a, const FunctionInfo& b) |
| 58 | { |
| 59 | int result = ConstString::Compare(a.GetName(), b.GetName()); |
| 60 | if (result) |
| 61 | return result; |
| 62 | |
| 63 | return Declaration::Compare(a.m_declaration, b.m_declaration); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | Declaration& |
| 68 | FunctionInfo::GetDeclaration() |
| 69 | { |
| 70 | return m_declaration; |
| 71 | } |
| 72 | |
| 73 | const Declaration& |
| 74 | FunctionInfo::GetDeclaration() const |
| 75 | { |
| 76 | return m_declaration; |
| 77 | } |
| 78 | |
| 79 | const ConstString& |
| 80 | FunctionInfo::GetName() const |
| 81 | { |
| 82 | return m_name; |
| 83 | } |
| 84 | |
| 85 | size_t |
| 86 | FunctionInfo::MemorySize() const |
| 87 | { |
| 88 | return m_name.MemorySize() + m_declaration.MemorySize(); |
| 89 | } |
| 90 | |
| 91 | |
| 92 | InlineFunctionInfo::InlineFunctionInfo |
| 93 | ( |
| 94 | const char *name, |
| 95 | const char *mangled, |
| 96 | const Declaration *decl_ptr, |
| 97 | const Declaration *call_decl_ptr |
| 98 | ) : |
| 99 | FunctionInfo(name, decl_ptr), |
| 100 | m_mangled(mangled, true), |
| 101 | m_call_decl (call_decl_ptr) |
| 102 | { |
| 103 | } |
| 104 | |
| 105 | InlineFunctionInfo::InlineFunctionInfo |
| 106 | ( |
| 107 | const ConstString& name, |
| 108 | const Mangled &mangled, |
| 109 | const Declaration *decl_ptr, |
| 110 | const Declaration *call_decl_ptr |
| 111 | ) : |
| 112 | FunctionInfo(name, decl_ptr), |
| 113 | m_mangled(mangled), |
| 114 | m_call_decl (call_decl_ptr) |
| 115 | { |
| 116 | } |
| 117 | |
| 118 | InlineFunctionInfo::~InlineFunctionInfo() |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | int |
| 123 | InlineFunctionInfo::Compare(const InlineFunctionInfo& a, const InlineFunctionInfo& b) |
| 124 | { |
| 125 | |
| 126 | int result = FunctionInfo::Compare(a, b); |
| 127 | if (result) |
| 128 | return result; |
| 129 | // only compare the mangled names if both have them |
| 130 | return Mangled::Compare(a.m_mangled, a.m_mangled); |
| 131 | } |
| 132 | |
| 133 | void |
Greg Clayton | 1924e24 | 2010-09-15 05:51:24 +0000 | [diff] [blame] | 134 | InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 135 | { |
Greg Clayton | 1924e24 | 2010-09-15 05:51:24 +0000 | [diff] [blame] | 136 | FunctionInfo::Dump(s, show_fullpaths); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 137 | if (m_mangled) |
| 138 | m_mangled.Dump(s); |
| 139 | } |
| 140 | |
| 141 | void |
| 142 | InlineFunctionInfo::DumpStopContext (Stream *s) const |
| 143 | { |
| 144 | // s->Indent("[inlined] "); |
| 145 | s->Indent(); |
| 146 | if (m_mangled) |
| 147 | s->PutCString (m_mangled.GetName().AsCString()); |
| 148 | else |
| 149 | s->PutCString (m_name.AsCString()); |
| 150 | } |
| 151 | |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 152 | |
| 153 | const ConstString & |
| 154 | InlineFunctionInfo::GetName () const |
| 155 | { |
| 156 | if (m_mangled) |
| 157 | return m_mangled.GetName(); |
| 158 | return m_name; |
| 159 | } |
| 160 | |
| 161 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 162 | Declaration & |
| 163 | InlineFunctionInfo::GetCallSite () |
| 164 | { |
| 165 | return m_call_decl; |
| 166 | } |
| 167 | |
| 168 | const Declaration & |
| 169 | InlineFunctionInfo::GetCallSite () const |
| 170 | { |
| 171 | return m_call_decl; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | Mangled& |
| 176 | InlineFunctionInfo::GetMangled() |
| 177 | { |
| 178 | return m_mangled; |
| 179 | } |
| 180 | |
| 181 | const Mangled& |
| 182 | InlineFunctionInfo::GetMangled() const |
| 183 | { |
| 184 | return m_mangled; |
| 185 | } |
| 186 | |
| 187 | size_t |
| 188 | InlineFunctionInfo::MemorySize() const |
| 189 | { |
| 190 | return FunctionInfo::MemorySize() + m_mangled.MemorySize(); |
| 191 | } |
| 192 | |
| 193 | //---------------------------------------------------------------------- |
| 194 | // |
| 195 | //---------------------------------------------------------------------- |
| 196 | Function::Function |
| 197 | ( |
| 198 | CompileUnit *comp_unit, |
| 199 | lldb::user_id_t func_uid, |
| 200 | lldb::user_id_t type_uid, |
| 201 | const Mangled &mangled, |
| 202 | Type * type, |
| 203 | const AddressRange& range |
| 204 | ) : |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 205 | UserID (func_uid), |
| 206 | m_comp_unit (comp_unit), |
| 207 | m_type_uid (type_uid), |
| 208 | m_type (type), |
| 209 | m_mangled (mangled), |
| 210 | m_block (func_uid), |
| 211 | m_range (range), |
| 212 | m_frame_base (), |
| 213 | m_flags (), |
| 214 | m_prologue_byte_size (0) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 215 | { |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 216 | m_block.SetParentScope(this); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 217 | assert(comp_unit != NULL); |
| 218 | } |
| 219 | |
| 220 | Function::Function |
| 221 | ( |
| 222 | CompileUnit *comp_unit, |
| 223 | lldb::user_id_t func_uid, |
| 224 | lldb::user_id_t type_uid, |
| 225 | const char *mangled, |
| 226 | Type *type, |
| 227 | const AddressRange &range |
| 228 | ) : |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 229 | UserID (func_uid), |
| 230 | m_comp_unit (comp_unit), |
| 231 | m_type_uid (type_uid), |
| 232 | m_type (type), |
| 233 | m_mangled (mangled, true), |
| 234 | m_block (func_uid), |
| 235 | m_range (range), |
| 236 | m_frame_base (), |
| 237 | m_flags (), |
| 238 | m_prologue_byte_size (0) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | { |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 240 | m_block.SetParentScope(this); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 241 | assert(comp_unit != NULL); |
| 242 | } |
| 243 | |
| 244 | |
| 245 | Function::~Function() |
| 246 | { |
| 247 | } |
| 248 | |
Jim Ingham | b75b466 | 2010-08-20 01:15:01 +0000 | [diff] [blame] | 249 | void |
| 250 | Function::GetStartLineSourceInfo (FileSpec &source_file, uint32_t &line_no) |
| 251 | { |
| 252 | line_no = 0; |
| 253 | source_file.Clear(); |
| 254 | |
| 255 | if (m_comp_unit == NULL) |
| 256 | return; |
| 257 | |
| 258 | if (m_type != NULL && m_type->GetDeclaration().GetLine() != 0) |
| 259 | { |
| 260 | source_file = m_type->GetDeclaration().GetFile(); |
| 261 | line_no = m_type->GetDeclaration().GetLine(); |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | LineTable *line_table = m_comp_unit->GetLineTable(); |
| 266 | if (line_table == NULL) |
| 267 | return; |
| 268 | |
| 269 | LineEntry line_entry; |
| 270 | if (line_table->FindLineEntryByAddress (GetAddressRange().GetBaseAddress(), line_entry, NULL)) |
| 271 | { |
| 272 | line_no = line_entry.line; |
| 273 | source_file = line_entry.file; |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | void |
| 279 | Function::GetEndLineSourceInfo (FileSpec &source_file, uint32_t &line_no) |
| 280 | { |
| 281 | line_no = 0; |
| 282 | source_file.Clear(); |
| 283 | |
| 284 | // The -1 is kind of cheesy, but I want to get the last line entry for the given function, not the |
| 285 | // first entry of the next. |
| 286 | Address scratch_addr(GetAddressRange().GetBaseAddress()); |
| 287 | scratch_addr.SetOffset (scratch_addr.GetOffset() + GetAddressRange().GetByteSize() - 1); |
| 288 | |
| 289 | LineTable *line_table = m_comp_unit->GetLineTable(); |
| 290 | if (line_table == NULL) |
| 291 | return; |
| 292 | |
| 293 | LineEntry line_entry; |
| 294 | if (line_table->FindLineEntryByAddress (scratch_addr, line_entry, NULL)) |
| 295 | { |
| 296 | line_no = line_entry.line; |
| 297 | source_file = line_entry.file; |
| 298 | } |
| 299 | } |
| 300 | |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 301 | Block & |
| 302 | Function::GetBlock (bool can_create) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 303 | { |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 304 | if (!m_block.BlockInfoHasBeenParsed() && can_create) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 305 | { |
| 306 | SymbolContext sc; |
| 307 | CalculateSymbolContext(&sc); |
Greg Clayton | b27e74b | 2011-06-24 03:47:23 +0000 | [diff] [blame^] | 308 | if (sc.module_sp) |
| 309 | { |
| 310 | sc.module_sp->GetSymbolVendor()->ParseFunctionBlocks(sc); |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | ::fprintf (stderr, |
| 315 | "unable to find module shared pointer for function '%s' in %s%s%s\n", |
| 316 | GetName().GetCString(), |
| 317 | m_comp_unit->GetDirectory().GetCString(), |
| 318 | m_comp_unit->GetDirectory() ? "/" : "", |
| 319 | m_comp_unit->GetFilename().GetCString()); |
| 320 | } |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 321 | m_block.SetBlockInfoHasBeenParsed (true, true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 322 | } |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 323 | return m_block; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | CompileUnit* |
| 327 | Function::GetCompileUnit() |
| 328 | { |
| 329 | return m_comp_unit; |
| 330 | } |
| 331 | |
| 332 | const CompileUnit* |
| 333 | Function::GetCompileUnit() const |
| 334 | { |
| 335 | return m_comp_unit; |
| 336 | } |
| 337 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 338 | |
| 339 | void |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 340 | Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 341 | { |
| 342 | Type* func_type = GetType(); |
Greg Clayton | c67b7d1 | 2010-09-10 01:30:46 +0000 | [diff] [blame] | 343 | *s << "id = " << (const UserID&)*this << ", name = \"" << func_type->GetName() << "\", range = "; |
| 344 | |
| 345 | Address::DumpStyle fallback_style; |
| 346 | if (level == eDescriptionLevelVerbose) |
| 347 | fallback_style = Address::DumpStyleModuleWithFileAddress; |
| 348 | else |
| 349 | fallback_style = Address::DumpStyleFileAddress; |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 350 | GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress, fallback_style); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 353 | void |
| 354 | Function::Dump(Stream *s, bool show_context) const |
| 355 | { |
| 356 | s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); |
| 357 | s->Indent(); |
| 358 | *s << "Function" << (const UserID&)*this; |
| 359 | |
| 360 | m_mangled.Dump(s); |
| 361 | |
| 362 | // FunctionInfo::Dump(s); |
| 363 | if (m_type) |
| 364 | { |
| 365 | *s << ", type = " << (void*)m_type; |
| 366 | /// << " ("; |
| 367 | ///m_type->DumpTypeName(s); |
| 368 | ///s->PutChar(')'); |
| 369 | } |
| 370 | else if (m_type_uid != LLDB_INVALID_UID) |
| 371 | *s << ", type_uid = " << m_type_uid; |
| 372 | |
| 373 | s->EOL(); |
| 374 | // Dump the root object |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 375 | if (m_block.BlockInfoHasBeenParsed ()) |
| 376 | m_block.Dump(s, m_range.GetBaseAddress().GetFileAddress(), INT_MAX, show_context); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | |
| 380 | void |
| 381 | Function::CalculateSymbolContext(SymbolContext* sc) |
| 382 | { |
| 383 | sc->function = this; |
| 384 | m_comp_unit->CalculateSymbolContext(sc); |
| 385 | } |
| 386 | |
| 387 | void |
| 388 | Function::DumpSymbolContext(Stream *s) |
| 389 | { |
| 390 | m_comp_unit->DumpSymbolContext(s); |
| 391 | s->Printf(", Function{0x%8.8x}", GetID()); |
| 392 | } |
| 393 | |
| 394 | size_t |
| 395 | Function::MemorySize () const |
| 396 | { |
Greg Clayton | 75ccf50 | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 397 | size_t mem_size = sizeof(Function) + m_block.MemorySize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 398 | return mem_size; |
| 399 | } |
| 400 | |
| 401 | Type* |
| 402 | Function::GetType() |
| 403 | { |
| 404 | return m_type; |
| 405 | } |
| 406 | |
| 407 | const Type* |
| 408 | Function::GetType() const |
| 409 | { |
| 410 | return m_type; |
| 411 | } |
| 412 | |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 413 | clang_type_t |
| 414 | Function::GetReturnClangType () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 415 | { |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 416 | clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); |
Sean Callanan | d5b3c35 | 2011-01-27 04:42:51 +0000 | [diff] [blame] | 417 | const clang::FunctionType *function_type = dyn_cast<clang::FunctionType> (clang_type); |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 418 | if (function_type) |
| 419 | return function_type->getResultType().getAsOpaquePtr(); |
| 420 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | int |
| 424 | Function::GetArgumentCount () |
| 425 | { |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 426 | clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 427 | assert (clang_type->isFunctionType()); |
| 428 | if (!clang_type->isFunctionProtoType()) |
| 429 | return -1; |
| 430 | |
| 431 | const clang::FunctionProtoType *function_proto_type = dyn_cast<clang::FunctionProtoType>(clang_type); |
| 432 | if (function_proto_type != NULL) |
| 433 | return function_proto_type->getNumArgs(); |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 438 | clang_type_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 439 | Function::GetArgumentTypeAtIndex (size_t idx) |
| 440 | { |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 441 | clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 442 | const clang::FunctionProtoType *function_proto_type = dyn_cast<clang::FunctionProtoType>(clang_type); |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 443 | if (function_proto_type) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 444 | { |
| 445 | unsigned num_args = function_proto_type->getNumArgs(); |
| 446 | if (idx >= num_args) |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 447 | return NULL; |
| 448 | |
| 449 | return (function_proto_type->arg_type_begin())[idx].getAsOpaquePtr(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 450 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 451 | return NULL; |
| 452 | } |
| 453 | |
| 454 | bool |
| 455 | Function::IsVariadic () |
| 456 | { |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 457 | const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangFullType())->getTypePtr(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 458 | assert (clang_type->isFunctionType()); |
| 459 | if (!clang_type->isFunctionProtoType()) |
| 460 | return false; |
| 461 | |
| 462 | const clang::FunctionProtoType *function_proto_type = dyn_cast<clang::FunctionProtoType>(clang_type); |
Greg Clayton | 04c9c7b | 2011-02-16 23:00:21 +0000 | [diff] [blame] | 463 | if (function_proto_type) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 464 | return function_proto_type->isVariadic(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 465 | |
| 466 | return false; |
| 467 | } |
| 468 | |
| 469 | uint32_t |
| 470 | Function::GetPrologueByteSize () |
| 471 | { |
| 472 | if (m_prologue_byte_size == 0 && m_flags.IsClear(flagsCalculatedPrologueSize)) |
| 473 | { |
| 474 | m_flags.Set(flagsCalculatedPrologueSize); |
| 475 | LineTable* line_table = m_comp_unit->GetLineTable (); |
| 476 | if (line_table) |
| 477 | { |
| 478 | LineEntry line_entry; |
| 479 | if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(), line_entry)) |
Greg Clayton | 2b8732c | 2010-11-11 20:13:30 +0000 | [diff] [blame] | 480 | { |
| 481 | // We need to take the delta of the end of the first line entry |
| 482 | // as a file address and the start file address of the function |
| 483 | // in case the first line entry doesn't start at the beginning |
| 484 | // of the function. |
| 485 | const addr_t func_start_file_addr = m_range.GetBaseAddress().GetFileAddress(); |
| 486 | const addr_t line_entry_end_file_addr = line_entry.range.GetBaseAddress().GetFileAddress() + line_entry.range.GetByteSize(); |
| 487 | if (line_entry_end_file_addr > func_start_file_addr) |
| 488 | m_prologue_byte_size = line_entry_end_file_addr - func_start_file_addr; |
| 489 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | return m_prologue_byte_size; |
| 493 | } |
| 494 | |
| 495 | |
| 496 | |