ClangASTContext.h revision 2fc7e8d0d392fe85f22d9c75212ebca4cbce547f
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 //------------------------------------------------------------------ 597 // clang::TagType 598 //------------------------------------------------------------------ 599 600 bool 601 SetTagTypeKind (lldb::clang_type_t tag_qual_type, 602 int kind); 603 604 //------------------------------------------------------------------ 605 // C++ Base Classes 606 //------------------------------------------------------------------ 607 608 clang::CXXBaseSpecifier * 609 CreateBaseClassSpecifier (lldb::clang_type_t base_class_type, 610 lldb::AccessType access, 611 bool is_virtual, 612 bool base_of_class); 613 614 static void 615 DeleteBaseClassSpecifiers (clang::CXXBaseSpecifier **base_classes, 616 unsigned num_base_classes); 617 618 bool 619 SetBaseClassesForClassType (lldb::clang_type_t class_clang_type, 620 clang::CXXBaseSpecifier const * const *base_classes, 621 unsigned num_base_classes); 622 623 //------------------------------------------------------------------ 624 // DeclContext Functions 625 //------------------------------------------------------------------ 626 627 static clang::DeclContext * 628 GetDeclContextForType (lldb::clang_type_t qual_type); 629 630 //------------------------------------------------------------------ 631 // Namespace Declarations 632 //------------------------------------------------------------------ 633 634 clang::NamespaceDecl * 635 GetUniqueNamespaceDeclaration (const char *name, 636 clang::DeclContext *decl_ctx); 637 638 //------------------------------------------------------------------ 639 // Function Types 640 //------------------------------------------------------------------ 641 642 clang::FunctionDecl * 643 CreateFunctionDeclaration (clang::DeclContext *decl_ctx, 644 const char *name, 645 lldb::clang_type_t function_Type, 646 int storage, 647 bool is_inline); 648 649 static lldb::clang_type_t 650 CreateFunctionType (clang::ASTContext *ast, 651 lldb::clang_type_t result_type, 652 lldb::clang_type_t *args, 653 unsigned num_args, 654 bool is_variadic, 655 unsigned type_quals); 656 657 lldb::clang_type_t 658 CreateFunctionType (lldb::clang_type_t result_type, 659 lldb::clang_type_t *args, 660 unsigned num_args, 661 bool is_variadic, 662 unsigned type_quals) 663 { 664 return ClangASTContext::CreateFunctionType(getASTContext(), 665 result_type, 666 args, 667 num_args, 668 is_variadic, 669 type_quals); 670 } 671 672 clang::ParmVarDecl * 673 CreateParameterDeclaration (const char *name, 674 lldb::clang_type_t param_type, 675 int storage); 676 677 void 678 SetFunctionParameters (clang::FunctionDecl *function_decl, 679 clang::ParmVarDecl **params, 680 unsigned num_params); 681 682 //------------------------------------------------------------------ 683 // Array Types 684 //------------------------------------------------------------------ 685 686 lldb::clang_type_t 687 CreateArrayType (lldb::clang_type_t element_type, 688 size_t element_count, 689 uint32_t bit_stride); 690 691 //------------------------------------------------------------------ 692 // Tag Declarations 693 //------------------------------------------------------------------ 694 bool 695 StartTagDeclarationDefinition (lldb::clang_type_t qual_type); 696 697 bool 698 CompleteTagDeclarationDefinition (lldb::clang_type_t qual_type); 699 700 //------------------------------------------------------------------ 701 // Enumeration Types 702 //------------------------------------------------------------------ 703 lldb::clang_type_t 704 CreateEnumerationType (const char *name, 705 clang::DeclContext *decl_ctx, 706 const Declaration &decl, 707 lldb::clang_type_t integer_qual_type); 708 709 static lldb::clang_type_t 710 GetEnumerationIntegerType (lldb::clang_type_t enum_clang_type); 711 712 bool 713 AddEnumerationValueToEnumerationType (lldb::clang_type_t enum_qual_type, 714 lldb::clang_type_t enumerator_qual_type, 715 const Declaration &decl, 716 const char *name, 717 int64_t enum_value, 718 uint32_t enum_value_bit_size); 719 720 //------------------------------------------------------------------ 721 // Pointers & References 722 //------------------------------------------------------------------ 723 lldb::clang_type_t 724 CreatePointerType (lldb::clang_type_t clang_type); 725 726 static lldb::clang_type_t 727 CreatePointerType (clang::ASTContext *ast, 728 lldb::clang_type_t clang_type); 729 730 static lldb::clang_type_t 731 CreateLValueReferenceType (clang::ASTContext *ast_context, 732 lldb::clang_type_t clang_type); 733 734 static lldb::clang_type_t 735 CreateRValueReferenceType (clang::ASTContext *ast_context, 736 lldb::clang_type_t clang_type); 737 738 lldb::clang_type_t 739 CreateLValueReferenceType (lldb::clang_type_t clang_type) 740 { 741 return ClangASTContext::CreateLValueReferenceType(getASTContext(), clang_type); 742 } 743 744 lldb::clang_type_t 745 CreateRValueReferenceType (lldb::clang_type_t clang_type) 746 { 747 return ClangASTContext::CreateRValueReferenceType(getASTContext(), clang_type); 748 } 749 750 lldb::clang_type_t 751 CreateMemberPointerType (lldb::clang_type_t clang_pointee_type, 752 lldb::clang_type_t clang_class_type); 753 754 uint32_t 755 GetPointerBitSize (); 756 757 static bool 758 IsIntegerType (lldb::clang_type_t clang_type, bool &is_signed); 759 760 static bool 761 IsPointerType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); 762 763 static bool 764 IsReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); 765 766 static bool 767 IsPointerOrReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); 768 769 static bool 770 IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, 771 lldb::clang_type_t clang_type, 772 lldb::clang_type_t *target_type = NULL); 773 774 static bool 775 IsPossibleDynamicType (clang::ASTContext *ast, 776 lldb::clang_type_t clang_type, 777 lldb::clang_type_t *dynamic_pointee_type = NULL); 778 779 static bool 780 IsCStringType (lldb::clang_type_t clang_type, uint32_t &length); 781 782 static bool 783 IsFunctionPointerType (lldb::clang_type_t clang_type); 784 785 static bool 786 IsArrayType (lldb::clang_type_t clang_type, lldb::clang_type_t *member_type = NULL, uint64_t *size = NULL); 787 788 //------------------------------------------------------------------ 789 // Typedefs 790 //------------------------------------------------------------------ 791 lldb::clang_type_t 792 CreateTypedefType (const char *name, 793 lldb::clang_type_t clang_type, 794 clang::DeclContext *decl_ctx); 795 796 //------------------------------------------------------------------ 797 // Type names 798 //------------------------------------------------------------------ 799 static bool 800 IsFloatingPointType (lldb::clang_type_t clang_type, uint32_t &count, bool &is_complex); 801 802 // true iff this is one of the types that can "fit" 803 // in a Scalar object 804 static bool 805 IsScalarType (lldb::clang_type_t clang_type); 806 807 static bool 808 IsPointerToScalarType (lldb::clang_type_t clang_type); 809 810 static bool 811 IsArrayOfScalarType (lldb::clang_type_t clang_type); 812 813 static bool 814 GetCXXClassName (lldb::clang_type_t clang_type, 815 std::string &class_name); 816 817 static bool 818 IsCXXClassType (lldb::clang_type_t clang_type); 819 820 static bool 821 IsBeingDefined (lldb::clang_type_t clang_type); 822 823 static bool 824 IsObjCClassType (lldb::clang_type_t clang_type); 825 826 static bool 827 IsCharType (lldb::clang_type_t clang_type); 828 829 static size_t 830 GetArraySize (lldb::clang_type_t clang_type); 831 832 //static bool 833 //ConvertFloatValueToString (clang::ASTContext *ast, 834 // lldb::clang_type_t clang_type, 835 // const uint8_t* bytes, 836 // size_t byte_size, 837 // int apint_byte_order, 838 // std::string &float_str); 839 840 static size_t 841 ConvertStringToFloatValue (clang::ASTContext *ast, 842 lldb::clang_type_t clang_type, 843 const char *s, 844 uint8_t *dst, 845 size_t dst_size); 846 847 //------------------------------------------------------------------ 848 // Qualifiers 849 //------------------------------------------------------------------ 850 static unsigned 851 GetTypeQualifiers(lldb::clang_type_t clang_type); 852 853 //------------------------------------------------------------------ 854 // Flags 855 //------------------------------------------------------------------ 856 static uint64_t 857 GetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type); 858 859 static void 860 SetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type, uint64_t flags); 861protected: 862 //------------------------------------------------------------------ 863 // Classes that inherit from ClangASTContext can see and modify these 864 //------------------------------------------------------------------ 865 std::string m_target_triple; 866 std::auto_ptr<clang::ASTContext> m_ast_ap; 867 std::auto_ptr<clang::LangOptions> m_language_options_ap; 868 std::auto_ptr<clang::FileManager> m_file_manager_ap; 869 std::auto_ptr<clang::FileSystemOptions> m_file_system_options_ap; 870 std::auto_ptr<clang::SourceManager> m_source_manager_ap; 871 std::auto_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap; 872 std::auto_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap; 873 std::auto_ptr<clang::TargetOptions> m_target_options_ap; 874 std::auto_ptr<clang::TargetInfo> m_target_info_ap; 875 std::auto_ptr<clang::IdentifierTable> m_identifier_table_ap; 876 std::auto_ptr<clang::SelectorTable> m_selector_table_ap; 877 std::auto_ptr<clang::Builtin::Context> m_builtins_ap; 878 CompleteTagDeclCallback m_callback_tag_decl; 879 CompleteObjCInterfaceDeclCallback m_callback_objc_decl; 880 void * m_callback_baton; 881private: 882 //------------------------------------------------------------------ 883 // For ClangASTContext only 884 //------------------------------------------------------------------ 885 ClangASTContext(const ClangASTContext&); 886 const ClangASTContext& operator=(const ClangASTContext&); 887}; 888 889} // namespace lldb_private 890 891#endif // liblldb_ClangASTContext_h_ 892