ClangASTContext.h revision 3eeaf6e715784499520885535236ccff1ba56d1c
1//===-- ClangASTContext.h ---------------------------------------*- 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#ifndef liblldb_ClangASTContext_h_ 11#define liblldb_ClangASTContext_h_ 12 13// C Includes 14// C++ Includes 15#include <string> 16#include <vector> 17#include <memory> 18#include <stdint.h> 19 20// Other libraries and framework includes 21#include "llvm/ADT/OwningPtr.h" 22#include "llvm/ADT/SmallVector.h" 23#include "clang/AST/TemplateBase.h" 24 25 26// Project includes 27#include "lldb/lldb-enumerations.h" 28#include "lldb/Core/ClangForward.h" 29#include "lldb/Symbol/ClangASTType.h" 30 31namespace lldb_private { 32 33class Declaration; 34 35class ClangASTContext 36{ 37public: 38 enum { 39 eTypeHasChildren = (1u << 0), 40 eTypeHasValue = (1u << 1), 41 eTypeIsArray = (1u << 2), 42 eTypeIsBlock = (1u << 3), 43 eTypeIsBuiltIn = (1u << 4), 44 eTypeIsClass = (1u << 5), 45 eTypeIsCPlusPlus = (1u << 6), 46 eTypeIsEnumeration = (1u << 7), 47 eTypeIsFuncPrototype = (1u << 8), 48 eTypeIsMember = (1u << 9), 49 eTypeIsObjC = (1u << 10), 50 eTypeIsPointer = (1u << 11), 51 eTypeIsReference = (1u << 12), 52 eTypeIsStructUnion = (1u << 13), 53 eTypeIsTemplate = (1u << 14), 54 eTypeIsTypedef = (1u << 15), 55 eTypeIsVector = (1u << 16), 56 eTypeIsScalar = (1u << 17) 57 }; 58 59 typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *); 60 typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *); 61 62 //------------------------------------------------------------------ 63 // Constructors and Destructors 64 //------------------------------------------------------------------ 65 ClangASTContext (const char *triple = NULL); 66 67 ~ClangASTContext(); 68 69 clang::ASTContext * 70 getASTContext(); 71 72 clang::Builtin::Context * 73 getBuiltinContext(); 74 75 clang::IdentifierTable * 76 getIdentifierTable(); 77 78 clang::LangOptions * 79 getLanguageOptions(); 80 81 clang::SelectorTable * 82 getSelectorTable(); 83 84 clang::FileManager * 85 getFileManager(); 86 87 clang::SourceManager * 88 getSourceManager(); 89 90 clang::DiagnosticsEngine * 91 getDiagnosticsEngine(); 92 93 clang::DiagnosticConsumer * 94 getDiagnosticConsumer(); 95 96 clang::TargetOptions * 97 getTargetOptions(); 98 99 clang::TargetInfo * 100 getTargetInfo(); 101 102 void 103 Clear(); 104 105 const char * 106 GetTargetTriple (); 107 108 void 109 SetTargetTriple (const char *target_triple); 110 111 void 112 SetArchitecture (const ArchSpec &arch); 113 114 bool 115 HasExternalSource (); 116 117 void 118 SetExternalSource (llvm::OwningPtr<clang::ExternalASTSource> &ast_source_ap); 119 120 void 121 RemoveExternalSource (); 122 123 bool 124 GetCompleteType (lldb::clang_type_t clang_type); 125 126 static bool 127 GetCompleteType (clang::ASTContext *ast, 128 lldb::clang_type_t clang_type); 129 130 bool 131 GetCompleteDecl (clang::Decl *decl) 132 { 133 return ClangASTContext::GetCompleteDecl(getASTContext(), decl); 134 } 135 136 static bool 137 GetCompleteDecl (clang::ASTContext *ast, 138 clang::Decl *decl); 139 140 //------------------------------------------------------------------ 141 // Basic Types 142 //------------------------------------------------------------------ 143 144 lldb::clang_type_t 145 GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding, 146 uint32_t bit_size); 147 148 static lldb::clang_type_t 149 GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast, 150 lldb::Encoding encoding, 151 uint32_t bit_size); 152 153 lldb::clang_type_t 154 GetBuiltinTypeForDWARFEncodingAndBitSize ( 155 const char *type_name, 156 uint32_t dw_ate, 157 uint32_t bit_size); 158 159 static lldb::clang_type_t 160 GetBuiltInType_void(clang::ASTContext *ast); 161 162 lldb::clang_type_t 163 GetBuiltInType_void() 164 { 165 return GetBuiltInType_void(getASTContext()); 166 } 167 168 lldb::clang_type_t 169 GetBuiltInType_bool(); 170 171 lldb::clang_type_t 172 GetBuiltInType_objc_id(); 173 174 lldb::clang_type_t 175 GetBuiltInType_objc_Class(); 176 177 static lldb::clang_type_t 178 GetUnknownAnyType(clang::ASTContext *ast); 179 180 lldb::clang_type_t 181 GetUnknownAnyType() 182 { 183 return ClangASTContext::GetUnknownAnyType(getASTContext()); 184 } 185 186 lldb::clang_type_t 187 GetBuiltInType_objc_selector(); 188 189 lldb::clang_type_t 190 GetCStringType(bool is_const); 191 192 lldb::clang_type_t 193 GetVoidPtrType(bool is_const); 194 195 static lldb::clang_type_t 196 GetVoidPtrType(clang::ASTContext *ast, bool is_const); 197 198 static clang::DeclContext * 199 GetTranslationUnitDecl (clang::ASTContext *ast); 200 201 clang::DeclContext * 202 GetTranslationUnitDecl () 203 { 204 return GetTranslationUnitDecl (getASTContext()); 205 } 206 207 static lldb::clang_type_t 208 CopyType(clang::ASTContext *dest_context, 209 clang::ASTContext *source_context, 210 lldb::clang_type_t clang_type); 211 212 static clang::Decl * 213 CopyDecl (clang::ASTContext *dest_context, 214 clang::ASTContext *source_context, 215 clang::Decl *source_decl); 216 217 static bool 218 AreTypesSame(clang::ASTContext *ast, 219 lldb::clang_type_t type1, 220 lldb::clang_type_t type2); 221 222 bool 223 AreTypesSame(lldb::clang_type_t type1, 224 lldb::clang_type_t type2) 225 { 226 return ClangASTContext::AreTypesSame(getASTContext(), type1, type2); 227 } 228 229 230 lldb::clang_type_t 231 GetTypeForDecl (clang::TagDecl *decl); 232 233 lldb::clang_type_t 234 GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl); 235 236 //------------------------------------------------------------------ 237 // CVR modifiers 238 //------------------------------------------------------------------ 239 240 static lldb::clang_type_t 241 AddConstModifier (lldb::clang_type_t clang_type); 242 243 static lldb::clang_type_t 244 AddRestrictModifier (lldb::clang_type_t clang_type); 245 246 static lldb::clang_type_t 247 AddVolatileModifier (lldb::clang_type_t clang_type); 248 249 //------------------------------------------------------------------ 250 // Structure, Unions, Classes 251 //------------------------------------------------------------------ 252 253 lldb::clang_type_t 254 CreateRecordType (clang::DeclContext *decl_ctx, 255 lldb::AccessType access_type, 256 const char *name, 257 int kind, 258 lldb::LanguageType language); 259 260 static clang::FieldDecl * 261 AddFieldToRecordType (clang::ASTContext *ast, 262 lldb::clang_type_t record_qual_type, 263 const char *name, 264 lldb::clang_type_t field_type, 265 lldb::AccessType access, 266 uint32_t bitfield_bit_size); 267 268 clang::FieldDecl * 269 AddFieldToRecordType (lldb::clang_type_t record_qual_type, 270 const char *name, 271 lldb::clang_type_t field_type, 272 lldb::AccessType access, 273 uint32_t bitfield_bit_size) 274 { 275 return ClangASTContext::AddFieldToRecordType (getASTContext(), 276 record_qual_type, 277 name, 278 field_type, 279 access, 280 bitfield_bit_size); 281 } 282 283 static clang::CXXMethodDecl * 284 AddMethodToCXXRecordType (clang::ASTContext *ast, 285 lldb::clang_type_t record_opaque_type, 286 const char *name, 287 lldb::clang_type_t method_type, 288 lldb::AccessType access, 289 bool is_virtual, 290 bool is_static, 291 bool is_inline, 292 bool is_explicit, 293 bool is_attr_used, 294 bool is_artificial); 295 296 clang::CXXMethodDecl * 297 AddMethodToCXXRecordType (lldb::clang_type_t record_opaque_type, 298 const char *name, 299 lldb::clang_type_t method_type, 300 lldb::AccessType access, 301 bool is_virtual, 302 bool is_static, 303 bool is_inline, 304 bool is_explicit, 305 bool is_attr_used, 306 bool is_artificial) 307 308 { 309 return ClangASTContext::AddMethodToCXXRecordType (getASTContext(), 310 record_opaque_type, 311 name, 312 method_type, 313 access, 314 is_virtual, 315 is_static, 316 is_inline, 317 is_explicit, 318 is_attr_used, 319 is_artificial); 320 } 321 322 class TemplateParameterInfos 323 { 324 public: 325 bool 326 IsValid() const 327 { 328 if (args.empty()) 329 return false; 330 return args.size() == names.size(); 331 } 332 333 size_t 334 GetSize () const 335 { 336 if (IsValid()) 337 return args.size(); 338 return 0; 339 } 340 341 llvm::SmallVector<const char *, 8> names; 342 llvm::SmallVector<clang::TemplateArgument, 8> args; 343 }; 344 345 clang::ClassTemplateDecl * 346 CreateClassTemplateDecl (clang::DeclContext *decl_ctx, 347 lldb::AccessType access_type, 348 const char *class_name, 349 int kind, 350 const TemplateParameterInfos &infos); 351 352 clang::ClassTemplateSpecializationDecl * 353 CreateClassTemplateSpecializationDecl (clang::DeclContext *decl_ctx, 354 clang::ClassTemplateDecl *class_template_decl, 355 int kind, 356 const TemplateParameterInfos &infos); 357 358 lldb::clang_type_t 359 CreateClassTemplateSpecializationType (clang::ClassTemplateSpecializationDecl *class_template_specialization_decl); 360 361 static clang::DeclContext * 362 GetAsDeclContext (clang::CXXMethodDecl *cxx_method_decl); 363 364 static clang::DeclContext * 365 GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl); 366 367 368 static bool 369 CheckOverloadedOperatorKindParameterCount (uint32_t op_kind, 370 uint32_t num_params); 371 372 bool 373 FieldIsBitfield (clang::FieldDecl* field, 374 uint32_t& bitfield_bit_size); 375 376 static bool 377 FieldIsBitfield (clang::ASTContext *ast, 378 clang::FieldDecl* field, 379 uint32_t& bitfield_bit_size); 380 381 static bool 382 RecordHasFields (const clang::RecordDecl *record_decl); 383 384 void 385 SetDefaultAccessForRecordFields (lldb::clang_type_t clang_type, 386 int default_accessibility, 387 int *assigned_accessibilities, 388 size_t num_assigned_accessibilities); 389 390 lldb::clang_type_t 391 CreateObjCClass (const char *name, 392 clang::DeclContext *decl_ctx, 393 bool isForwardDecl, 394 bool isInternal); 395 396 static clang::FieldDecl * 397 AddObjCClassIVar (clang::ASTContext *ast, 398 lldb::clang_type_t class_opaque_type, 399 const char *name, 400 lldb::clang_type_t ivar_opaque_type, 401 lldb::AccessType access, 402 uint32_t bitfield_bit_size, 403 bool isSynthesized); 404 405 clang::FieldDecl * 406 AddObjCClassIVar (lldb::clang_type_t class_opaque_type, 407 const char *name, 408 lldb::clang_type_t ivar_opaque_type, 409 lldb::AccessType access, 410 uint32_t bitfield_bit_size, 411 bool isSynthesized) 412 { 413 return ClangASTContext::AddObjCClassIVar (getASTContext(), 414 class_opaque_type, 415 name, 416 ivar_opaque_type, 417 access, 418 bitfield_bit_size, 419 isSynthesized); 420 } 421 422 static bool 423 AddObjCClassProperty 424 ( 425 clang::ASTContext *ast, 426 lldb::clang_type_t class_opaque_type, 427 const char *property_name, 428 lldb::clang_type_t property_opaque_type, // The property type is only required if you don't have an ivar decl 429 clang::ObjCIvarDecl *ivar_decl, 430 const char *property_setter_name, 431 const char *property_getter_name, 432 uint32_t property_attributes 433 ); 434 435 bool 436 AddObjCClassProperty 437 ( 438 lldb::clang_type_t class_opaque_type, 439 const char *property_name, 440 lldb::clang_type_t property_opaque_type, 441 clang::ObjCIvarDecl *ivar_decl, 442 const char *property_setter_name, 443 const char *property_getter_name, 444 uint32_t property_attributes 445 ) 446 { 447 return ClangASTContext::AddObjCClassProperty (getASTContext(), 448 class_opaque_type, 449 property_name, 450 property_opaque_type, 451 ivar_decl, 452 property_setter_name, 453 property_getter_name, 454 property_attributes); 455 } 456 457 bool 458 SetObjCSuperClass (lldb::clang_type_t class_clang_type, 459 lldb::clang_type_t superclass_clang_type); 460 461 static bool 462 ObjCTypeHasIVars (lldb::clang_type_t class_clang_type, bool check_superclass); 463 464 static bool 465 ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, 466 bool check_superclass); 467 468 469 static clang::ObjCMethodDecl * 470 AddMethodToObjCObjectType (clang::ASTContext *ast, 471 lldb::clang_type_t class_opaque_type, 472 const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") 473 lldb::clang_type_t method_opaque_type, 474 lldb::AccessType access); 475 476 clang::ObjCMethodDecl * 477 AddMethodToObjCObjectType (lldb::clang_type_t class_opaque_type, 478 const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") 479 lldb::clang_type_t method_opaque_type, 480 lldb::AccessType access) 481 { 482 return AddMethodToObjCObjectType (getASTContext(), 483 class_opaque_type, 484 name, 485 method_opaque_type, 486 access); 487 } 488 489 static bool 490 SetHasExternalStorage (lldb::clang_type_t clang_type, bool has_extern); 491 492 //------------------------------------------------------------------ 493 // Aggregate Types 494 //------------------------------------------------------------------ 495 static bool 496 IsAggregateType (lldb::clang_type_t clang_type); 497 498 // Returns a mask containing bits from the ClangASTContext::eTypeXXX enumerations 499 static uint32_t 500 GetTypeInfo (lldb::clang_type_t clang_type, 501 clang::ASTContext *ast, // The AST for clang_type (can be NULL) 502 lldb::clang_type_t *pointee_or_element_type); // (can be NULL) 503 504 static uint32_t 505 GetNumChildren (clang::ASTContext *ast, 506 lldb::clang_type_t clang_type, 507 bool omit_empty_base_classes); 508 509 static uint32_t 510 GetNumDirectBaseClasses (clang::ASTContext *ast, 511 lldb::clang_type_t clang_type); 512 513 static uint32_t 514 GetNumVirtualBaseClasses (clang::ASTContext *ast, 515 lldb::clang_type_t clang_type); 516 517 static uint32_t 518 GetNumFields (clang::ASTContext *ast, 519 lldb::clang_type_t clang_type); 520 521 static lldb::clang_type_t 522 GetDirectBaseClassAtIndex (clang::ASTContext *ast, 523 lldb::clang_type_t clang_type, 524 uint32_t idx, 525 uint32_t *bit_offset_ptr); 526 527 static lldb::clang_type_t 528 GetVirtualBaseClassAtIndex (clang::ASTContext *ast, 529 lldb::clang_type_t clang_type, 530 uint32_t idx, 531 uint32_t *bit_offset_ptr); 532 533 static lldb::clang_type_t 534 GetFieldAtIndex (clang::ASTContext *ast, 535 lldb::clang_type_t clang_type, 536 uint32_t idx, 537 std::string& name, 538 uint32_t *bit_offset_ptr); 539 540 static uint32_t 541 GetNumPointeeChildren (lldb::clang_type_t clang_type); 542 543 lldb::clang_type_t 544 GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, 545 const char *parent_name, 546 lldb::clang_type_t parent_clang_type, 547 uint32_t idx, 548 bool transparent_pointers, 549 bool omit_empty_base_classes, 550 bool ignore_array_bounds, 551 std::string& child_name, 552 uint32_t &child_byte_size, 553 int32_t &child_byte_offset, 554 uint32_t &child_bitfield_bit_size, 555 uint32_t &child_bitfield_bit_offset, 556 bool &child_is_base_class, 557 bool &child_is_deref_of_parent); 558 559 static lldb::clang_type_t 560 GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, 561 clang::ASTContext *ast, 562 const char *parent_name, 563 lldb::clang_type_t parent_clang_type, 564 uint32_t idx, 565 bool transparent_pointers, 566 bool omit_empty_base_classes, 567 bool ignore_array_bounds, 568 std::string& child_name, 569 uint32_t &child_byte_size, 570 int32_t &child_byte_offset, 571 uint32_t &child_bitfield_bit_size, 572 uint32_t &child_bitfield_bit_offset, 573 bool &child_is_base_class, 574 bool &child_is_deref_of_parent); 575 576 // Lookup a child given a name. This function will match base class names 577 // and member member names in "clang_type" only, not descendants. 578 static uint32_t 579 GetIndexOfChildWithName (clang::ASTContext *ast, 580 lldb::clang_type_t clang_type, 581 const char *name, 582 bool omit_empty_base_classes); 583 584 // Lookup a child member given a name. This function will match member names 585 // only and will descend into "clang_type" children in search for the first 586 // member in this class, or any base class that matches "name". 587 // TODO: Return all matches for a given name by returning a vector<vector<uint32_t>> 588 // so we catch all names that match a given child name, not just the first. 589 static size_t 590 GetIndexOfChildMemberWithName (clang::ASTContext *ast, 591 lldb::clang_type_t clang_type, 592 const char *name, 593 bool omit_empty_base_classes, 594 std::vector<uint32_t>& child_indexes); 595 596 size_t 597 GetNumTemplateArguments (lldb::clang_type_t clang_type) 598 { 599 return GetNumTemplateArguments(getASTContext(), clang_type); 600 } 601 602 lldb::clang_type_t 603 GetTemplateArgument (lldb::clang_type_t clang_type, 604 size_t idx, 605 lldb::TemplateArgumentKind &kind) 606 { 607 return GetTemplateArgument(getASTContext(), clang_type, idx, kind); 608 } 609 610 static size_t 611 GetNumTemplateArguments (clang::ASTContext *ast, 612 lldb::clang_type_t clang_type); 613 614 static lldb::clang_type_t 615 GetTemplateArgument (clang::ASTContext *ast, 616 lldb::clang_type_t clang_type, 617 size_t idx, 618 lldb::TemplateArgumentKind &kind); 619 620 //------------------------------------------------------------------ 621 // clang::TagType 622 //------------------------------------------------------------------ 623 624 bool 625 SetTagTypeKind (lldb::clang_type_t tag_qual_type, 626 int kind); 627 628 //------------------------------------------------------------------ 629 // C++ Base Classes 630 //------------------------------------------------------------------ 631 632 clang::CXXBaseSpecifier * 633 CreateBaseClassSpecifier (lldb::clang_type_t base_class_type, 634 lldb::AccessType access, 635 bool is_virtual, 636 bool base_of_class); 637 638 static void 639 DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, 640 unsigned num_base_classes); 641 642 bool 643 SetBaseClassesForClassType (lldb::clang_type_t class_clang_type, 644 clang::CXXBaseSpecifier const * const *base_classes, 645 unsigned num_base_classes); 646 647 //------------------------------------------------------------------ 648 // DeclContext Functions 649 //------------------------------------------------------------------ 650 651 static clang::DeclContext * 652 GetDeclContextForType (lldb::clang_type_t qual_type); 653 654 //------------------------------------------------------------------ 655 // Namespace Declarations 656 //------------------------------------------------------------------ 657 658 clang::NamespaceDecl * 659 GetUniqueNamespaceDeclaration (const char *name, 660 clang::DeclContext *decl_ctx); 661 662 //------------------------------------------------------------------ 663 // Function Types 664 //------------------------------------------------------------------ 665 666 clang::FunctionDecl * 667 CreateFunctionDeclaration (clang::DeclContext *decl_ctx, 668 const char *name, 669 lldb::clang_type_t function_Type, 670 int storage, 671 bool is_inline); 672 673 static lldb::clang_type_t 674 CreateFunctionType (clang::ASTContext *ast, 675 lldb::clang_type_t result_type, 676 lldb::clang_type_t *args, 677 unsigned num_args, 678 bool is_variadic, 679 unsigned type_quals); 680 681 lldb::clang_type_t 682 CreateFunctionType (lldb::clang_type_t result_type, 683 lldb::clang_type_t *args, 684 unsigned num_args, 685 bool is_variadic, 686 unsigned type_quals) 687 { 688 return ClangASTContext::CreateFunctionType(getASTContext(), 689 result_type, 690 args, 691 num_args, 692 is_variadic, 693 type_quals); 694 } 695 696 clang::ParmVarDecl * 697 CreateParameterDeclaration (const char *name, 698 lldb::clang_type_t param_type, 699 int storage); 700 701 void 702 SetFunctionParameters (clang::FunctionDecl *function_decl, 703 clang::ParmVarDecl **params, 704 unsigned num_params); 705 706 //------------------------------------------------------------------ 707 // Array Types 708 //------------------------------------------------------------------ 709 710 lldb::clang_type_t 711 CreateArrayType (lldb::clang_type_t element_type, 712 size_t element_count, 713 uint32_t bit_stride); 714 715 //------------------------------------------------------------------ 716 // Tag Declarations 717 //------------------------------------------------------------------ 718 bool 719 StartTagDeclarationDefinition (lldb::clang_type_t qual_type); 720 721 bool 722 CompleteTagDeclarationDefinition (lldb::clang_type_t qual_type); 723 724 //------------------------------------------------------------------ 725 // Enumeration Types 726 //------------------------------------------------------------------ 727 lldb::clang_type_t 728 CreateEnumerationType (const char *name, 729 clang::DeclContext *decl_ctx, 730 const Declaration &decl, 731 lldb::clang_type_t integer_qual_type); 732 733 static lldb::clang_type_t 734 GetEnumerationIntegerType (lldb::clang_type_t enum_clang_type); 735 736 bool 737 AddEnumerationValueToEnumerationType (lldb::clang_type_t enum_qual_type, 738 lldb::clang_type_t enumerator_qual_type, 739 const Declaration &decl, 740 const char *name, 741 int64_t enum_value, 742 uint32_t enum_value_bit_size); 743 744 //------------------------------------------------------------------ 745 // Pointers & References 746 //------------------------------------------------------------------ 747 lldb::clang_type_t 748 CreatePointerType (lldb::clang_type_t clang_type); 749 750 static lldb::clang_type_t 751 CreatePointerType (clang::ASTContext *ast, 752 lldb::clang_type_t clang_type); 753 754 static lldb::clang_type_t 755 CreateLValueReferenceType (clang::ASTContext *ast_context, 756 lldb::clang_type_t clang_type); 757 758 static lldb::clang_type_t 759 CreateRValueReferenceType (clang::ASTContext *ast_context, 760 lldb::clang_type_t clang_type); 761 762 lldb::clang_type_t 763 CreateLValueReferenceType (lldb::clang_type_t clang_type) 764 { 765 return ClangASTContext::CreateLValueReferenceType(getASTContext(), clang_type); 766 } 767 768 lldb::clang_type_t 769 CreateRValueReferenceType (lldb::clang_type_t clang_type) 770 { 771 return ClangASTContext::CreateRValueReferenceType(getASTContext(), clang_type); 772 } 773 774 lldb::clang_type_t 775 CreateMemberPointerType (lldb::clang_type_t clang_pointee_type, 776 lldb::clang_type_t clang_class_type); 777 778 uint32_t 779 GetPointerBitSize (); 780 781 static bool 782 IsIntegerType (lldb::clang_type_t clang_type, bool &is_signed); 783 784 static bool 785 IsPointerType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); 786 787 static bool 788 IsReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); 789 790 static bool 791 IsPointerOrReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); 792 793 static bool 794 IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, 795 lldb::clang_type_t clang_type, 796 lldb::clang_type_t *target_type = NULL); 797 798 static bool 799 IsPossibleDynamicType (clang::ASTContext *ast, 800 lldb::clang_type_t clang_type, 801 lldb::clang_type_t *dynamic_pointee_type = NULL); 802 803 static bool 804 IsCStringType (lldb::clang_type_t clang_type, uint32_t &length); 805 806 static bool 807 IsFunctionPointerType (lldb::clang_type_t clang_type); 808 809 static lldb::clang_type_t 810 GetAsArrayType (lldb::clang_type_t clang_type, 811 lldb::clang_type_t *member_type = NULL, 812 uint64_t *size = NULL); 813 814 static bool 815 IsArrayType (lldb::clang_type_t clang_type, 816 lldb::clang_type_t *member_type = NULL, 817 uint64_t *size = NULL) 818 { 819 return GetAsArrayType(clang_type, member_type, size) != 0; 820 } 821 822 //------------------------------------------------------------------ 823 // Typedefs 824 //------------------------------------------------------------------ 825 lldb::clang_type_t 826 CreateTypedefType (const char *name, 827 lldb::clang_type_t clang_type, 828 clang::DeclContext *decl_ctx); 829 830 //------------------------------------------------------------------ 831 // Type names 832 //------------------------------------------------------------------ 833 static bool 834 IsFloatingPointType (lldb::clang_type_t clang_type, uint32_t &count, bool &is_complex); 835 836 // true iff this is one of the types that can "fit" 837 // in a Scalar object 838 static bool 839 IsScalarType (lldb::clang_type_t clang_type); 840 841 static bool 842 IsPointerToScalarType (lldb::clang_type_t clang_type); 843 844 static bool 845 IsArrayOfScalarType (lldb::clang_type_t clang_type); 846 847 static bool 848 GetCXXClassName (lldb::clang_type_t clang_type, 849 std::string &class_name); 850 851 static bool 852 IsCXXClassType (lldb::clang_type_t clang_type); 853 854 static bool 855 IsBeingDefined (lldb::clang_type_t clang_type); 856 857 static bool 858 IsObjCClassType (lldb::clang_type_t clang_type); 859 860 static bool 861 IsCharType (lldb::clang_type_t clang_type); 862 863 static size_t 864 GetArraySize (lldb::clang_type_t clang_type); 865 866 //static bool 867 //ConvertFloatValueToString (clang::ASTContext *ast, 868 // lldb::clang_type_t clang_type, 869 // const uint8_t* bytes, 870 // size_t byte_size, 871 // int apint_byte_order, 872 // std::string &float_str); 873 874 static size_t 875 ConvertStringToFloatValue (clang::ASTContext *ast, 876 lldb::clang_type_t clang_type, 877 const char *s, 878 uint8_t *dst, 879 size_t dst_size); 880 881 //------------------------------------------------------------------ 882 // Qualifiers 883 //------------------------------------------------------------------ 884 static unsigned 885 GetTypeQualifiers(lldb::clang_type_t clang_type); 886 887 //------------------------------------------------------------------ 888 // Flags 889 //------------------------------------------------------------------ 890 static uint64_t 891 GetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type); 892 893 static void 894 SetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type, uint64_t flags); 895protected: 896 //------------------------------------------------------------------ 897 // Classes that inherit from ClangASTContext can see and modify these 898 //------------------------------------------------------------------ 899 std::string m_target_triple; 900 std::auto_ptr<clang::ASTContext> m_ast_ap; 901 std::auto_ptr<clang::LangOptions> m_language_options_ap; 902 std::auto_ptr<clang::FileManager> m_file_manager_ap; 903 std::auto_ptr<clang::FileSystemOptions> m_file_system_options_ap; 904 std::auto_ptr<clang::SourceManager> m_source_manager_ap; 905 std::auto_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap; 906 std::auto_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap; 907 std::auto_ptr<clang::TargetOptions> m_target_options_ap; 908 std::auto_ptr<clang::TargetInfo> m_target_info_ap; 909 std::auto_ptr<clang::IdentifierTable> m_identifier_table_ap; 910 std::auto_ptr<clang::SelectorTable> m_selector_table_ap; 911 std::auto_ptr<clang::Builtin::Context> m_builtins_ap; 912 CompleteTagDeclCallback m_callback_tag_decl; 913 CompleteObjCInterfaceDeclCallback m_callback_objc_decl; 914 void * m_callback_baton; 915private: 916 //------------------------------------------------------------------ 917 // For ClangASTContext only 918 //------------------------------------------------------------------ 919 ClangASTContext(const ClangASTContext&); 920 const ClangASTContext& operator=(const ClangASTContext&); 921}; 922 923} // namespace lldb_private 924 925#endif // liblldb_ClangASTContext_h_ 926