diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp | 438 |
1 files changed, 149 insertions, 289 deletions
diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp index 4f30ccf..aae96bf 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp @@ -16,7 +16,7 @@ // Other libraries and framework includes // Clang headers like to use NDEBUG inside of them to enable/disable debug -// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing +// related features using "#ifndef NDEBUG" preprocessor blocks to do one thing // or another. This is bad because it means that if clang was built in release // mode, it assumes that you are building in release mode which is not always // the case. You can end up with functions that are defined as empty in header @@ -79,6 +79,16 @@ using namespace lldb_private; using namespace llvm; using namespace clang; +typedef llvm::DenseMap<clang::ASTContext *, ClangASTContext*> ClangASTMap; + +static ClangASTMap & +GetASTMap() +{ + static ClangASTMap g_map; + return g_map; +} + + clang::AccessSpecifier ClangASTContext::ConvertAccessTypeToAccessSpecifier (AccessType access) { @@ -103,7 +113,7 @@ ParseLangArgs { // FIXME: Cleanup per-file based stuff. - // Set some properties which depend soley on the input kind; it would be nice + // Set some properties which depend solely on the input kind; it would be nice // to move these to the language standard, and have the driver resolve the // input kind + language standard. if (IK == IK_Asm) { @@ -276,9 +286,9 @@ ClangASTContext::ClangASTContext (const char *target_triple) : m_identifier_table_ap(), m_selector_table_ap(), m_builtins_ap(), - m_callback_tag_decl (NULL), - m_callback_objc_decl (NULL), - m_callback_baton (NULL), + m_callback_tag_decl (nullptr), + m_callback_objc_decl (nullptr), + m_callback_baton (nullptr), m_pointer_byte_size (0) { @@ -291,6 +301,11 @@ ClangASTContext::ClangASTContext (const char *target_triple) : //---------------------------------------------------------------------- ClangASTContext::~ClangASTContext() { + if (m_ast_ap.get()) + { + GetASTMap().erase(m_ast_ap.get()); + } + m_builtins_ap.reset(); m_selector_table_ap.reset(); m_identifier_table_ap.reset(); @@ -342,12 +357,12 @@ ClangASTContext::HasExternalSource () { ASTContext *ast = getASTContext(); if (ast) - return ast->getExternalSource () != NULL; + return ast->getExternalSource () != nullptr; return false; } void -ClangASTContext::SetExternalSource (llvm::OwningPtr<ExternalASTSource> &ast_source_ap) +ClangASTContext::SetExternalSource (llvm::IntrusiveRefCntPtr<ExternalASTSource> &ast_source_ap) { ASTContext *ast = getASTContext(); if (ast) @@ -365,7 +380,7 @@ ClangASTContext::RemoveExternalSource () if (ast) { - llvm::OwningPtr<ExternalASTSource> empty_ast_source_ap; + llvm::IntrusiveRefCntPtr<ExternalASTSource> empty_ast_source_ap; ast->setExternalSource (empty_ast_source_ap); ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false); //ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(false); @@ -377,15 +392,14 @@ ClangASTContext::RemoveExternalSource () ASTContext * ClangASTContext::getASTContext() { - if (m_ast_ap.get() == NULL) + if (m_ast_ap.get() == nullptr) { m_ast_ap.reset(new ASTContext (*getLanguageOptions(), *getSourceManager(), - getTargetInfo(), *getIdentifierTable(), *getSelectorTable(), - *getBuiltinContext(), - 0)); + *getBuiltinContext())); + m_ast_ap->InitBuiltinTypes(*getTargetInfo()); if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) { @@ -394,14 +408,23 @@ ClangASTContext::getASTContext() } m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false); + + GetASTMap().insert(std::make_pair(m_ast_ap.get(), this)); } return m_ast_ap.get(); } +ClangASTContext* +ClangASTContext::GetASTContext (clang::ASTContext* ast) +{ + ClangASTContext *clang_ast = GetASTMap().lookup(ast); + return clang_ast; +} + Builtin::Context * ClangASTContext::getBuiltinContext() { - if (m_builtins_ap.get() == NULL) + if (m_builtins_ap.get() == nullptr) m_builtins_ap.reset (new Builtin::Context()); return m_builtins_ap.get(); } @@ -409,15 +432,15 @@ ClangASTContext::getBuiltinContext() IdentifierTable * ClangASTContext::getIdentifierTable() { - if (m_identifier_table_ap.get() == NULL) - m_identifier_table_ap.reset(new IdentifierTable (*ClangASTContext::getLanguageOptions(), NULL)); + if (m_identifier_table_ap.get() == nullptr) + m_identifier_table_ap.reset(new IdentifierTable (*ClangASTContext::getLanguageOptions(), nullptr)); return m_identifier_table_ap.get(); } LangOptions * ClangASTContext::getLanguageOptions() { - if (m_language_options_ap.get() == NULL) + if (m_language_options_ap.get() == nullptr) { m_language_options_ap.reset(new LangOptions()); ParseLangArgs(*m_language_options_ap, IK_ObjCXX); @@ -429,7 +452,7 @@ ClangASTContext::getLanguageOptions() SelectorTable * ClangASTContext::getSelectorTable() { - if (m_selector_table_ap.get() == NULL) + if (m_selector_table_ap.get() == nullptr) m_selector_table_ap.reset (new SelectorTable()); return m_selector_table_ap.get(); } @@ -437,7 +460,7 @@ ClangASTContext::getSelectorTable() clang::FileManager * ClangASTContext::getFileManager() { - if (m_file_manager_ap.get() == NULL) + if (m_file_manager_ap.get() == nullptr) { clang::FileSystemOptions file_system_options; m_file_manager_ap.reset(new clang::FileManager(file_system_options)); @@ -448,7 +471,7 @@ ClangASTContext::getFileManager() clang::SourceManager * ClangASTContext::getSourceManager() { - if (m_source_manager_ap.get() == NULL) + if (m_source_manager_ap.get() == nullptr) m_source_manager_ap.reset(new clang::SourceManager(*getDiagnosticsEngine(), *getFileManager())); return m_source_manager_ap.get(); } @@ -456,7 +479,7 @@ ClangASTContext::getSourceManager() clang::DiagnosticsEngine * ClangASTContext::getDiagnosticsEngine() { - if (m_diagnostics_engine_ap.get() == NULL) + if (m_diagnostics_engine_ap.get() == nullptr) { llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs()); m_diagnostics_engine_ap.reset(new DiagnosticsEngine(diag_id_sp, new DiagnosticOptions())); @@ -494,23 +517,21 @@ private: DiagnosticConsumer * ClangASTContext::getDiagnosticConsumer() { - if (m_diagnostic_consumer_ap.get() == NULL) + if (m_diagnostic_consumer_ap.get() == nullptr) m_diagnostic_consumer_ap.reset(new NullDiagnosticConsumer); return m_diagnostic_consumer_ap.get(); } -TargetOptions * -ClangASTContext::getTargetOptions() -{ - if (m_target_options_rp.getPtr() == NULL && !m_target_triple.empty()) +std::shared_ptr<TargetOptions> & +ClangASTContext::getTargetOptions() { + if (m_target_options_rp.get() == nullptr && !m_target_triple.empty()) { - m_target_options_rp.reset (); - m_target_options_rp = new TargetOptions(); - if (m_target_options_rp.getPtr() != NULL) + m_target_options_rp = std::make_shared<TargetOptions>(); + if (m_target_options_rp.get() != nullptr) m_target_options_rp->Triple = m_target_triple; } - return m_target_options_rp.getPtr(); + return m_target_options_rp; } @@ -518,7 +539,7 @@ TargetInfo * ClangASTContext::getTargetInfo() { // target_triple should be something like "x86_64-apple-macosx" - if (m_target_info_ap.get() == NULL && !m_target_triple.empty()) + if (m_target_info_ap.get() == nullptr && !m_target_triple.empty()) m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(), getTargetOptions())); return m_target_info_ap.get(); } @@ -650,7 +671,7 @@ ClangASTContext::GetBasicTypeEnumeration (const ConstString &name) g_type_map.Append(ConstString("__int128_t").GetCString(), eBasicTypeInt128); g_type_map.Append(ConstString("__uint128_t").GetCString(), eBasicTypeUnsignedInt128); - // Miscelaneous + // Miscellaneous g_type_map.Append(ConstString("bool").GetCString(), eBasicTypeBool); g_type_map.Append(ConstString("float").GetCString(), eBasicTypeFloat); g_type_map.Append(ConstString("double").GetCString(), eBasicTypeDouble); @@ -696,7 +717,7 @@ ClangASTContext::GetBasicType (ASTContext *ast, lldb::BasicType basic_type) { if (ast) { - clang_type_t clang_type = NULL; + clang_type_t clang_type = nullptr; switch (basic_type) { @@ -811,7 +832,7 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name ASTContext *ast = getASTContext(); #define streq(a,b) strcmp(a,b) == 0 - assert (ast != NULL); + assert (ast != nullptr); if (ast) { switch (dw_ate) @@ -1134,9 +1155,9 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, ClangASTMetadata *metadata) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); @@ -1160,7 +1181,7 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, decl_ctx, SourceLocation(), SourceLocation(), - is_anonymous ? NULL : &ast->Idents.get(name)); + is_anonymous ? nullptr : &ast->Idents.get(name)); if (is_anonymous) decl->setAnonymousStructOrUnion(true); @@ -1194,7 +1215,7 @@ CreateTemplateParameterList (ASTContext *ast, { const char *name = template_param_infos.names[i]; - IdentifierInfo *identifier_info = NULL; + IdentifierInfo *identifier_info = nullptr; if (name && name[0]) identifier_info = &ast->Idents.get(name); if (template_param_infos.args[i].getKind() == TemplateArgument::Integral) @@ -1208,7 +1229,7 @@ CreateTemplateParameterList (ASTContext *ast, identifier_info, template_param_infos.args[i].getIntegralType(), parameter_pack, - NULL)); + nullptr)); } else @@ -1277,7 +1298,7 @@ ClangASTContext::CreateFunctionTemplateSpecializationInfo (FunctionDecl *func_de func_decl->setFunctionTemplateSpecialization (func_tmpl_decl, &template_args, - NULL); + nullptr); } @@ -1290,8 +1311,8 @@ ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx, { ASTContext *ast = getASTContext(); - ClassTemplateDecl *class_template_decl = NULL; - if (decl_ctx == NULL) + ClassTemplateDecl *class_template_decl = nullptr; + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); IdentifierInfo &identifier_info = ast->Idents.get(class_name); @@ -1337,7 +1358,7 @@ ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx, decl_name, template_param_list, template_cxx_decl, - NULL); + nullptr); if (class_template_decl) { @@ -1373,7 +1394,7 @@ ClangASTContext::CreateClassTemplateSpecializationDecl (DeclContext *decl_ctx, class_template_decl, &template_param_infos.args.front(), template_param_infos.args.size(), - NULL); + nullptr); class_template_specialization_decl->setSpecializationKind(TSK_ExplicitSpecialization); @@ -1392,222 +1413,6 @@ ClangASTContext::CreateClassTemplateSpecializationType (ClassTemplateSpecializat return ClangASTType(); } -static bool -IsOperator (const char *name, OverloadedOperatorKind &op_kind) -{ - if (name == NULL || name[0] == '\0') - return false; - -#define OPERATOR_PREFIX "operator" -#define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1) - - const char *post_op_name = NULL; - - bool no_space = true; - - if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH)) - return false; - - post_op_name = name + OPERATOR_PREFIX_LENGTH; - - if (post_op_name[0] == ' ') - { - post_op_name++; - no_space = false; - } - -#undef OPERATOR_PREFIX -#undef OPERATOR_PREFIX_LENGTH - - // This is an operator, set the overloaded operator kind to invalid - // in case this is a conversion operator... - op_kind = NUM_OVERLOADED_OPERATORS; - - switch (post_op_name[0]) - { - default: - if (no_space) - return false; - break; - case 'n': - if (no_space) - return false; - if (strcmp (post_op_name, "new") == 0) - op_kind = OO_New; - else if (strcmp (post_op_name, "new[]") == 0) - op_kind = OO_Array_New; - break; - - case 'd': - if (no_space) - return false; - if (strcmp (post_op_name, "delete") == 0) - op_kind = OO_Delete; - else if (strcmp (post_op_name, "delete[]") == 0) - op_kind = OO_Array_Delete; - break; - - case '+': - if (post_op_name[1] == '\0') - op_kind = OO_Plus; - else if (post_op_name[2] == '\0') - { - if (post_op_name[1] == '=') - op_kind = OO_PlusEqual; - else if (post_op_name[1] == '+') - op_kind = OO_PlusPlus; - } - break; - - case '-': - if (post_op_name[1] == '\0') - op_kind = OO_Minus; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '=': op_kind = OO_MinusEqual; break; - case '-': op_kind = OO_MinusMinus; break; - case '>': op_kind = OO_Arrow; break; - } - } - else if (post_op_name[3] == '\0') - { - if (post_op_name[2] == '*') - op_kind = OO_ArrowStar; break; - } - break; - - case '*': - if (post_op_name[1] == '\0') - op_kind = OO_Star; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_StarEqual; - break; - - case '/': - if (post_op_name[1] == '\0') - op_kind = OO_Slash; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_SlashEqual; - break; - - case '%': - if (post_op_name[1] == '\0') - op_kind = OO_Percent; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_PercentEqual; - break; - - - case '^': - if (post_op_name[1] == '\0') - op_kind = OO_Caret; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_CaretEqual; - break; - - case '&': - if (post_op_name[1] == '\0') - op_kind = OO_Amp; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '=': op_kind = OO_AmpEqual; break; - case '&': op_kind = OO_AmpAmp; break; - } - } - break; - - case '|': - if (post_op_name[1] == '\0') - op_kind = OO_Pipe; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '=': op_kind = OO_PipeEqual; break; - case '|': op_kind = OO_PipePipe; break; - } - } - break; - - case '~': - if (post_op_name[1] == '\0') - op_kind = OO_Tilde; - break; - - case '!': - if (post_op_name[1] == '\0') - op_kind = OO_Exclaim; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_ExclaimEqual; - break; - - case '=': - if (post_op_name[1] == '\0') - op_kind = OO_Equal; - else if (post_op_name[1] == '=' && post_op_name[2] == '\0') - op_kind = OO_EqualEqual; - break; - - case '<': - if (post_op_name[1] == '\0') - op_kind = OO_Less; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '<': op_kind = OO_LessLess; break; - case '=': op_kind = OO_LessEqual; break; - } - } - else if (post_op_name[3] == '\0') - { - if (post_op_name[2] == '=') - op_kind = OO_LessLessEqual; - } - break; - - case '>': - if (post_op_name[1] == '\0') - op_kind = OO_Greater; - else if (post_op_name[2] == '\0') - { - switch (post_op_name[1]) - { - case '>': op_kind = OO_GreaterGreater; break; - case '=': op_kind = OO_GreaterEqual; break; - } - } - else if (post_op_name[1] == '>' && - post_op_name[2] == '=' && - post_op_name[3] == '\0') - { - op_kind = OO_GreaterGreaterEqual; - } - break; - - case ',': - if (post_op_name[1] == '\0') - op_kind = OO_Comma; - break; - - case '(': - if (post_op_name[1] == ')' && post_op_name[2] == '\0') - op_kind = OO_Call; - break; - - case '[': - if (post_op_name[1] == ']' && post_op_name[2] == '\0') - op_kind = OO_Subscript; - break; - } - - return true; -} - static inline bool check_op_param (uint32_t op_kind, bool unary, bool binary, uint32_t num_params) { @@ -1615,7 +1420,7 @@ check_op_param (uint32_t op_kind, bool unary, bool binary, uint32_t num_params) if(op_kind == OO_Call) return true; - // The parameter count doens't include "this" + // The parameter count doesn't include "this" if (num_params == 0) return unary; if (num_params == 1) @@ -1686,7 +1491,7 @@ ClangASTContext::FieldIsBitfield uint32_t& bitfield_bit_size ) { - if (ast == NULL || field == NULL) + if (ast == nullptr || field == nullptr) return false; if (field->isBitField()) @@ -1708,7 +1513,7 @@ ClangASTContext::FieldIsBitfield bool ClangASTContext::RecordHasFields (const RecordDecl *record_decl) { - if (record_decl == NULL) + if (record_decl == nullptr) return false; if (!record_decl->field_empty()) @@ -1744,16 +1549,16 @@ ClangASTContext::CreateObjCClass ) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); assert (name && name[0]); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create (*ast, decl_ctx, SourceLocation(), &ast->Idents.get(name), - NULL, + nullptr, SourceLocation(), /*isForwardDecl,*/ isInternal); @@ -1804,10 +1609,10 @@ ClangASTContext::GetNumBaseClasses (const CXXRecordDecl *cxx_record_decl, bool o NamespaceDecl * ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *decl_ctx) { - NamespaceDecl *namespace_decl = NULL; + NamespaceDecl *namespace_decl = nullptr; ASTContext *ast = getASTContext(); TranslationUnitDecl *translation_unit_decl = ast->getTranslationUnitDecl (); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = translation_unit_decl; if (name) @@ -1828,7 +1633,7 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d SourceLocation(), SourceLocation(), &identifier_info, - NULL); + nullptr); decl_ctx->addDecl (namespace_decl); } @@ -1845,8 +1650,8 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d false, SourceLocation(), SourceLocation(), - NULL, - NULL); + nullptr, + nullptr); translation_unit_decl->setAnonymousNamespace (namespace_decl); translation_unit_decl->addDecl (namespace_decl); assert (namespace_decl == translation_unit_decl->getAnonymousNamespace()); @@ -1864,8 +1669,8 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d false, SourceLocation(), SourceLocation(), - NULL, - NULL); + nullptr, + nullptr); parent_namespace_decl->setAnonymousNamespace (namespace_decl); parent_namespace_decl->addDecl (namespace_decl); assert (namespace_decl == parent_namespace_decl->getAnonymousNamespace()); @@ -1910,9 +1715,9 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, int storage, bool is_inline) { - FunctionDecl *func_decl = NULL; + FunctionDecl *func_decl = nullptr; ASTContext *ast = getASTContext(); - if (decl_ctx == NULL) + if (decl_ctx == nullptr) decl_ctx = ast->getTranslationUnitDecl(); @@ -1927,7 +1732,7 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, SourceLocation(), DeclarationName (&ast->Idents.get(name)), function_clang_type.GetQualType(), - NULL, + nullptr, (FunctionDecl::StorageClass)storage, is_inline, hasWrittenPrototype, @@ -1941,7 +1746,7 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, SourceLocation(), DeclarationName (), function_clang_type.GetQualType(), - NULL, + nullptr, (FunctionDecl::StorageClass)storage, is_inline, hasWrittenPrototype, @@ -1965,7 +1770,7 @@ ClangASTContext::CreateFunctionType (ASTContext *ast, bool is_variadic, unsigned type_quals) { - assert (ast != NULL); + assert (ast != nullptr); std::vector<QualType> qual_type_args; for (unsigned i=0; i<num_args; ++i) qual_type_args.push_back (args[i].GetQualType()); @@ -1973,12 +1778,10 @@ ClangASTContext::CreateFunctionType (ASTContext *ast, // TODO: Detect calling convention in DWARF? FunctionProtoType::ExtProtoInfo proto_info; proto_info.Variadic = is_variadic; - proto_info.ExceptionSpecType = EST_None; + proto_info.ExceptionSpec = EST_None; proto_info.TypeQuals = type_quals; proto_info.RefQualifier = RQ_None; - proto_info.NumExceptions = 0; - proto_info.Exceptions = NULL; - + return ClangASTType (ast, ast->getFunctionType (result_type.GetQualType(), qual_type_args, proto_info).getAsOpaquePtr()); @@ -1988,16 +1791,16 @@ ParmVarDecl * ClangASTContext::CreateParameterDeclaration (const char *name, const ClangASTType ¶m_type, int storage) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); return ParmVarDecl::Create(*ast, ast->getTranslationUnitDecl(), SourceLocation(), SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : NULL, + name && name[0] ? &ast->Idents.get(name) : nullptr, param_type.GetQualType(), - NULL, + nullptr, (VarDecl::StorageClass)storage, - 0); + nullptr); } void @@ -2018,7 +1821,7 @@ ClangASTContext::CreateArrayType (const ClangASTType &element_type, if (element_type.IsValid()) { ASTContext *ast = getASTContext(); - assert (ast != NULL); + assert (ast != nullptr); if (is_vector) { @@ -2071,8 +1874,8 @@ ClangASTContext::CreateEnumerationType decl_ctx, SourceLocation(), SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : NULL, - NULL, + name && name[0] ? &ast->Idents.get(name) : nullptr, + nullptr, false, // IsScoped false, // IsScopedUsingClassTag false); // IsFixed @@ -2131,6 +1934,63 @@ ClangASTContext::CreateEnumerationType // return false; //} +ClangASTType +ClangASTContext::GetIntTypeFromBitSize (clang::ASTContext *ast, + size_t bit_size, bool is_signed) +{ + if (ast) + { + if (is_signed) + { + if (bit_size == ast->getTypeSize(ast->SignedCharTy)) + return ClangASTType(ast, ast->SignedCharTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->ShortTy)) + return ClangASTType(ast, ast->ShortTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->IntTy)) + return ClangASTType(ast, ast->IntTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->LongTy)) + return ClangASTType(ast, ast->LongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->LongLongTy)) + return ClangASTType(ast, ast->LongLongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->Int128Ty)) + return ClangASTType(ast, ast->Int128Ty.getAsOpaquePtr()); + } + else + { + if (bit_size == ast->getTypeSize(ast->UnsignedCharTy)) + return ClangASTType(ast, ast->UnsignedCharTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedShortTy)) + return ClangASTType(ast, ast->UnsignedShortTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedIntTy)) + return ClangASTType(ast, ast->UnsignedIntTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedLongTy)) + return ClangASTType(ast, ast->UnsignedLongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedLongLongTy)) + return ClangASTType(ast, ast->UnsignedLongLongTy.getAsOpaquePtr()); + + if (bit_size == ast->getTypeSize(ast->UnsignedInt128Ty)) + return ClangASTType(ast, ast->UnsignedInt128Ty.getAsOpaquePtr()); + } + } + return ClangASTType(); +} + +ClangASTType +ClangASTContext::GetPointerSizedIntType (clang::ASTContext *ast, bool is_signed) +{ + if (ast) + return GetIntTypeFromBitSize(ast, ast->getTypeSize(ast->VoidPtrTy), is_signed); + return ClangASTType(); +} ClangASTType ClangASTContext::GetFloatTypeFromBitSize (clang::ASTContext *ast, @@ -2223,7 +2083,7 @@ ClangASTContext::GetMetadata (clang::ASTContext *ast, if (external_source && external_source->HasMetadata(object)) return external_source->GetMetadata(object); else - return NULL; + return nullptr; } clang::DeclContext * |