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