Greg Clayton | 1e591ce | 2010-07-16 18:28:27 +0000 | [diff] [blame] | 1 | //===-- ClangASTSource.cpp ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 10 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 11 | #include "clang/AST/ASTContext.h" |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 12 | #include "lldb/Core/Log.h" |
Greg Clayton | 6e0101c | 2011-09-17 06:21:20 +0000 | [diff] [blame] | 13 | #include "lldb/Core/Module.h" |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 14 | #include "lldb/Core/ModuleList.h" |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 15 | #include "lldb/Expression/ASTDumper.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 16 | #include "lldb/Expression/ClangASTSource.h" |
| 17 | #include "lldb/Expression/ClangExpression.h" |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 18 | #include "lldb/Symbol/ClangNamespaceDecl.h" |
| 19 | #include "lldb/Symbol/SymbolVendor.h" |
Sean Callanan | 673f3db | 2011-11-30 22:11:59 +0000 | [diff] [blame] | 20 | #include "lldb/Target/ObjCLanguageRuntime.h" |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 21 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | |
| 23 | using namespace clang; |
| 24 | using namespace lldb_private; |
| 25 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 26 | ClangASTSource::~ClangASTSource() |
| 27 | { |
Sean Callanan | a3d0447 | 2011-11-29 00:42:02 +0000 | [diff] [blame] | 28 | m_ast_importer->ForgetDestination(m_ast_context); |
| 29 | |
Johnny Chen | fa21ffd | 2011-11-30 23:18:53 +0000 | [diff] [blame] | 30 | // We are in the process of destruction, don't create clang ast context on demand |
| 31 | // by passing false to Target::GetScratchClangASTContext(create_on_demand). |
| 32 | ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(false); |
Sean Callanan | a3d0447 | 2011-11-29 00:42:02 +0000 | [diff] [blame] | 33 | |
| 34 | if (!scratch_clang_ast_context) |
| 35 | return; |
| 36 | |
| 37 | clang::ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext(); |
| 38 | |
| 39 | if (!scratch_ast_context) |
| 40 | return; |
| 41 | |
| 42 | if (m_ast_context != scratch_ast_context) |
| 43 | m_ast_importer->ForgetSource(scratch_ast_context, m_ast_context); |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 44 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 45 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 46 | void |
| 47 | ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) |
| 48 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 49 | if (!m_ast_context) |
| 50 | return; |
| 51 | |
| 52 | m_ast_context->getTranslationUnitDecl()->setHasExternalVisibleStorage(); |
| 53 | m_ast_context->getTranslationUnitDecl()->setHasExternalLexicalStorage(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | // The core lookup interface. |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 57 | DeclContext::lookup_result |
| 58 | ClangASTSource::FindExternalVisibleDeclsByName |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 59 | ( |
| 60 | const DeclContext *decl_ctx, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 61 | DeclarationName clang_decl_name |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 62 | ) |
| 63 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 64 | if (!m_ast_context) |
| 65 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 66 | |
| 67 | if (GetImportInProgress()) |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 68 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 69 | |
| 70 | std::string decl_name (clang_decl_name.getAsString()); |
| 71 | |
| 72 | // if (m_decl_map.DoingASTImport ()) |
| 73 | // return DeclContext::lookup_result(); |
| 74 | // |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 75 | switch (clang_decl_name.getNameKind()) { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 76 | // Normal identifiers. |
| 77 | case DeclarationName::Identifier: |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 78 | if (clang_decl_name.getAsIdentifierInfo()->getBuiltinID() != 0) |
| 79 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 80 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 81 | |
| 82 | // Operator names. Not important for now. |
| 83 | case DeclarationName::CXXOperatorName: |
| 84 | case DeclarationName::CXXLiteralOperatorName: |
| 85 | return DeclContext::lookup_result(); |
| 86 | |
| 87 | // Using directives found in this context. |
| 88 | // Tell Sema we didn't find any or we'll end up getting asked a *lot*. |
| 89 | case DeclarationName::CXXUsingDirective: |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 90 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 92 | case DeclarationName::ObjCZeroArgSelector: |
| 93 | case DeclarationName::ObjCOneArgSelector: |
| 94 | case DeclarationName::ObjCMultiArgSelector: |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 95 | { |
| 96 | llvm::SmallVector<NamedDecl*, 1> method_decls; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 97 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 98 | NameSearchContext method_search_context (*this, method_decls, clang_decl_name, decl_ctx); |
| 99 | |
| 100 | FindObjCMethodDecls(method_search_context); |
| 101 | |
| 102 | return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls); |
| 103 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | // These aren't possible in the global context. |
| 105 | case DeclarationName::CXXConstructorName: |
| 106 | case DeclarationName::CXXDestructorName: |
| 107 | case DeclarationName::CXXConversionFunctionName: |
| 108 | return DeclContext::lookup_result(); |
| 109 | } |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 110 | |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 111 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 112 | if (!GetLookupsEnabled()) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 113 | { |
| 114 | // Wait until we see a '$' at the start of a name before we start doing |
| 115 | // any lookups so we can avoid lookup up all of the builtin types. |
| 116 | if (!decl_name.empty() && decl_name[0] == '$') |
| 117 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 118 | SetLookupsEnabled (true); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 119 | } |
| 120 | else |
| 121 | { |
| 122 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 123 | } |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 124 | } |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 125 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 126 | ConstString const_decl_name(decl_name.c_str()); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 127 | |
| 128 | const char *uniqued_const_decl_name = const_decl_name.GetCString(); |
| 129 | if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end()) |
| 130 | { |
| 131 | // We are currently looking up this name... |
| 132 | return DeclContext::lookup_result(); |
| 133 | } |
| 134 | m_active_lookups.insert(uniqued_const_decl_name); |
Greg Clayton | a8b278a | 2010-11-15 01:34:18 +0000 | [diff] [blame] | 135 | // static uint32_t g_depth = 0; |
| 136 | // ++g_depth; |
| 137 | // printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth, uniqued_const_decl_name); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 138 | llvm::SmallVector<NamedDecl*, 4> name_decls; |
| 139 | NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 140 | FindExternalVisibleDecls(name_search_context); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 141 | DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls)); |
Greg Clayton | a8b278a | 2010-11-15 01:34:18 +0000 | [diff] [blame] | 142 | // --g_depth; |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 143 | m_active_lookups.erase (uniqued_const_decl_name); |
| 144 | return result; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 147 | void |
| 148 | ClangASTSource::CompleteType (TagDecl *tag_decl) |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 149 | { |
| 150 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 151 | |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 152 | static unsigned int invocation_id = 0; |
| 153 | unsigned int current_id = invocation_id++; |
| 154 | |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 155 | if (log) |
| 156 | { |
Sean Callanan | 6e22e8b | 2012-01-13 22:05:55 +0000 | [diff] [blame] | 157 | log->Printf(" CompleteTagDecl[%u] on (ASTContext*)%p Completing (TagDecl*)%p named %s", |
| 158 | current_id, |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 159 | m_ast_context, |
Sean Callanan | 6e22e8b | 2012-01-13 22:05:55 +0000 | [diff] [blame] | 160 | tag_decl, |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 161 | tag_decl->getName().str().c_str()); |
| 162 | |
| 163 | log->Printf(" CTD[%u] Before:", current_id); |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 164 | ASTDumper dumper((Decl*)tag_decl); |
| 165 | dumper.ToLog(log, " [CTD] "); |
| 166 | } |
| 167 | |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 168 | if (!m_ast_importer->CompleteTagDecl (tag_decl)) |
| 169 | { |
| 170 | // We couldn't complete the type. Maybe there's a definition |
| 171 | // somewhere else that can be completed. |
| 172 | |
| 173 | if (log) |
| 174 | log->Printf(" CTD[%u] Type could not be completed in the module in which it was first found.", current_id); |
| 175 | |
| 176 | bool found = false; |
| 177 | |
| 178 | DeclContext *decl_ctx = tag_decl->getDeclContext(); |
| 179 | |
| 180 | if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(decl_ctx)) |
| 181 | { |
| 182 | ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context); |
| 183 | |
| 184 | if (log && log->GetVerbose()) |
| 185 | log->Printf(" CTD[%u] Inspecting namespace map %p (%d entries)", |
| 186 | current_id, |
| 187 | namespace_map.get(), |
| 188 | (int)namespace_map->size()); |
| 189 | |
| 190 | if (!namespace_map) |
| 191 | return; |
| 192 | |
| 193 | for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end(); |
| 194 | i != e && !found; |
| 195 | ++i) |
| 196 | { |
| 197 | if (log) |
| 198 | log->Printf(" CTD[%u] Searching namespace %s in module %s", |
| 199 | current_id, |
| 200 | i->second.GetNamespaceDecl()->getNameAsString().c_str(), |
| 201 | i->first->GetFileSpec().GetFilename().GetCString()); |
| 202 | |
| 203 | TypeList types; |
| 204 | |
| 205 | SymbolContext null_sc; |
| 206 | ConstString name(tag_decl->getName().str().c_str()); |
| 207 | |
| 208 | i->first->FindTypes(null_sc, name, &i->second, true, UINT32_MAX, types); |
| 209 | |
| 210 | for (uint32_t ti = 0, te = types.GetSize(); |
| 211 | ti != te && !found; |
| 212 | ++ti) |
| 213 | { |
| 214 | lldb::TypeSP type = types.GetTypeAtIndex(ti); |
| 215 | |
| 216 | if (!type) |
| 217 | continue; |
| 218 | |
| 219 | lldb::clang_type_t opaque_type = type->GetClangFullType(); |
| 220 | |
| 221 | if (!opaque_type) |
| 222 | continue; |
| 223 | |
Sean Callanan | 21f2e19 | 2011-12-14 01:13:04 +0000 | [diff] [blame] | 224 | const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs<TagType>(); |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 225 | |
| 226 | if (!tag_type) |
| 227 | continue; |
| 228 | |
| 229 | TagDecl *candidate_tag_decl = const_cast<TagDecl*>(tag_type->getDecl()); |
| 230 | |
| 231 | if (m_ast_importer->CompleteTagDeclWithOrigin (tag_decl, candidate_tag_decl)) |
| 232 | found = true; |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | TypeList types; |
| 239 | |
| 240 | SymbolContext null_sc; |
| 241 | ConstString name(tag_decl->getName().str().c_str()); |
| 242 | ClangNamespaceDecl namespace_decl; |
| 243 | |
| 244 | ModuleList &module_list = m_target->GetImages(); |
| 245 | |
| 246 | module_list.FindTypes(null_sc, name, true, UINT32_MAX, types); |
| 247 | |
| 248 | for (uint32_t ti = 0, te = types.GetSize(); |
| 249 | ti != te && !found; |
| 250 | ++ti) |
| 251 | { |
| 252 | lldb::TypeSP type = types.GetTypeAtIndex(ti); |
| 253 | |
| 254 | if (!type) |
| 255 | continue; |
| 256 | |
| 257 | lldb::clang_type_t opaque_type = type->GetClangFullType(); |
| 258 | |
| 259 | if (!opaque_type) |
| 260 | continue; |
| 261 | |
Sean Callanan | 21f2e19 | 2011-12-14 01:13:04 +0000 | [diff] [blame] | 262 | const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs<TagType>(); |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 263 | |
| 264 | if (!tag_type) |
| 265 | continue; |
| 266 | |
| 267 | TagDecl *candidate_tag_decl = const_cast<TagDecl*>(tag_type->getDecl()); |
| 268 | |
| 269 | if (m_ast_importer->CompleteTagDeclWithOrigin (tag_decl, candidate_tag_decl)) |
| 270 | found = true; |
| 271 | } |
| 272 | } |
| 273 | } |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 274 | |
| 275 | if (log) |
| 276 | { |
| 277 | log->Printf(" [CTD] After:"); |
| 278 | ASTDumper dumper((Decl*)tag_decl); |
| 279 | dumper.ToLog(log, " [CTD] "); |
| 280 | } |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | void |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 284 | ClangASTSource::CompleteType (clang::ObjCInterfaceDecl *interface_decl) |
| 285 | { |
| 286 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 287 | |
| 288 | if (log) |
| 289 | { |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 290 | log->Printf(" [CompleteObjCInterfaceDecl] on (ASTContext*)%p Completing an ObjCInterfaceDecl named %s", m_ast_context, interface_decl->getName().str().c_str()); |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 291 | log->Printf(" [COID] Before:"); |
| 292 | ASTDumper dumper((Decl*)interface_decl); |
| 293 | dumper.ToLog(log, " [COID] "); |
| 294 | } |
| 295 | |
| 296 | m_ast_importer->CompleteObjCInterfaceDecl (interface_decl); |
| 297 | |
| 298 | if (log) |
| 299 | { |
| 300 | log->Printf(" [COID] After:"); |
| 301 | ASTDumper dumper((Decl*)interface_decl); |
| 302 | dumper.ToLog(log, " [COID] "); |
| 303 | } |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Sean Callanan | 9b6898f | 2011-07-30 02:42:06 +0000 | [diff] [blame] | 306 | clang::ExternalLoadResult |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 307 | ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context, |
| 308 | bool (*predicate)(Decl::Kind), |
| 309 | llvm::SmallVectorImpl<Decl*> &decls) |
| 310 | { |
| 311 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 312 | |
| 313 | const Decl *context_decl = dyn_cast<Decl>(decl_context); |
| 314 | |
| 315 | if (!context_decl) |
| 316 | return ELR_Failure; |
| 317 | |
| 318 | static unsigned int invocation_id = 0; |
| 319 | unsigned int current_id = invocation_id++; |
| 320 | |
| 321 | if (log) |
| 322 | { |
| 323 | if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl)) |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 324 | log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' (%sDecl*)%p with %s predicate", |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 325 | current_id, |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 326 | m_ast_context, |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 327 | context_named_decl->getNameAsString().c_str(), |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 328 | context_decl->getDeclKindName(), |
| 329 | context_decl, |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 330 | (predicate ? "non-null" : "null")); |
| 331 | else if(context_decl) |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 332 | log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in (%sDecl*)%p with %s predicate", |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 333 | current_id, |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 334 | m_ast_context, |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 335 | context_decl->getDeclKindName(), |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 336 | context_decl, |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 337 | (predicate ? "non-null" : "null")); |
| 338 | else |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 339 | log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context with %s predicate", |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 340 | current_id, |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 341 | m_ast_context, |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 342 | (predicate ? "non-null" : "null")); |
| 343 | } |
| 344 | |
| 345 | Decl *original_decl = NULL; |
| 346 | ASTContext *original_ctx = NULL; |
| 347 | |
| 348 | if (!m_ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx)) |
| 349 | return ELR_Failure; |
| 350 | |
| 351 | if (log) |
| 352 | { |
Sean Callanan | 6e22e8b | 2012-01-13 22:05:55 +0000 | [diff] [blame] | 353 | log->Printf(" FELD[%u] Original decl (Decl*)%p:", current_id, original_decl); |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 354 | ASTDumper(original_decl).ToLog(log, " "); |
| 355 | } |
| 356 | |
| 357 | if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl)) |
| 358 | { |
| 359 | ExternalASTSource *external_source = original_ctx->getExternalSource(); |
| 360 | |
| 361 | if (external_source) |
| 362 | external_source->CompleteType (original_tag_decl); |
| 363 | } |
| 364 | |
Sean Callanan | b2027ec | 2011-12-08 23:45:45 +0000 | [diff] [blame] | 365 | const DeclContext *original_decl_context = dyn_cast<DeclContext>(original_decl); |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 366 | |
| 367 | if (!original_decl_context) |
| 368 | return ELR_Failure; |
| 369 | |
| 370 | for (TagDecl::decl_iterator iter = original_decl_context->decls_begin(); |
| 371 | iter != original_decl_context->decls_end(); |
| 372 | ++iter) |
| 373 | { |
| 374 | Decl *decl = *iter; |
| 375 | |
| 376 | if (!predicate || predicate(decl->getKind())) |
| 377 | { |
| 378 | if (log) |
| 379 | { |
| 380 | ASTDumper ast_dumper(decl); |
| 381 | if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl)) |
| 382 | log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString()); |
| 383 | else |
| 384 | log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString()); |
| 385 | } |
| 386 | |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 387 | Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl); |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 388 | |
| 389 | decls.push_back(copied_decl); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | return ELR_AlreadyLoaded; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 394 | } |
| 395 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 396 | void |
| 397 | ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context) |
| 398 | { |
| 399 | assert (m_ast_context); |
| 400 | |
| 401 | const ConstString name(context.m_decl_name.getAsString().c_str()); |
| 402 | |
| 403 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 404 | |
| 405 | static unsigned int invocation_id = 0; |
| 406 | unsigned int current_id = invocation_id++; |
| 407 | |
| 408 | if (log) |
| 409 | { |
| 410 | if (!context.m_decl_context) |
Sean Callanan | 6e22e8b | 2012-01-13 22:05:55 +0000 | [diff] [blame] | 411 | log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in a NULL DeclContext", current_id, m_ast_context, name.GetCString()); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 412 | else if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context.m_decl_context)) |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 413 | log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in '%s'", current_id, m_ast_context, name.GetCString(), context_named_decl->getNameAsString().c_str()); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 414 | else |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 415 | log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in a '%s'", current_id, m_ast_context, name.GetCString(), context.m_decl_context->getDeclKindName()); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap); |
| 419 | |
| 420 | if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context)) |
| 421 | { |
| 422 | ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context); |
| 423 | |
| 424 | if (log && log->GetVerbose()) |
| 425 | log->Printf(" CAS::FEVD[%u] Inspecting namespace map %p (%d entries)", |
| 426 | current_id, |
| 427 | namespace_map.get(), |
| 428 | (int)namespace_map->size()); |
| 429 | |
| 430 | if (!namespace_map) |
| 431 | return; |
| 432 | |
| 433 | for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end(); |
| 434 | i != e; |
| 435 | ++i) |
| 436 | { |
| 437 | if (log) |
| 438 | log->Printf(" CAS::FEVD[%u] Searching namespace %s in module %s", |
| 439 | current_id, |
| 440 | i->second.GetNamespaceDecl()->getNameAsString().c_str(), |
| 441 | i->first->GetFileSpec().GetFilename().GetCString()); |
| 442 | |
| 443 | FindExternalVisibleDecls(context, |
| 444 | i->first, |
| 445 | i->second, |
| 446 | current_id); |
| 447 | } |
| 448 | } |
Sean Callanan | d3812fa | 2011-11-15 21:50:18 +0000 | [diff] [blame] | 449 | else if (isa<ObjCInterfaceDecl>(context.m_decl_context)) |
Sean Callanan | e6ea5fe | 2011-11-15 02:11:17 +0000 | [diff] [blame] | 450 | { |
| 451 | FindObjCPropertyDecls(context); |
| 452 | } |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 453 | else if (!isa<TranslationUnitDecl>(context.m_decl_context)) |
| 454 | { |
| 455 | // we shouldn't be getting FindExternalVisibleDecls calls for these |
| 456 | return; |
| 457 | } |
| 458 | else |
| 459 | { |
| 460 | ClangNamespaceDecl namespace_decl; |
| 461 | |
| 462 | if (log) |
| 463 | log->Printf(" CAS::FEVD[%u] Searching the root namespace", current_id); |
| 464 | |
| 465 | FindExternalVisibleDecls(context, |
| 466 | lldb::ModuleSP(), |
| 467 | namespace_decl, |
| 468 | current_id); |
| 469 | } |
| 470 | |
| 471 | if (!context.m_namespace_map->empty()) |
| 472 | { |
| 473 | if (log && log->GetVerbose()) |
| 474 | log->Printf(" CAS::FEVD[%u] Registering namespace map %p (%d entries)", |
| 475 | current_id, |
| 476 | context.m_namespace_map.get(), |
| 477 | (int)context.m_namespace_map->size()); |
| 478 | |
| 479 | NamespaceDecl *clang_namespace_decl = AddNamespace(context, context.m_namespace_map); |
| 480 | |
| 481 | if (clang_namespace_decl) |
| 482 | clang_namespace_decl->setHasExternalVisibleStorage(); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | void |
| 487 | ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, |
| 488 | lldb::ModuleSP module_sp, |
| 489 | ClangNamespaceDecl &namespace_decl, |
| 490 | unsigned int current_id) |
| 491 | { |
| 492 | assert (m_ast_context); |
| 493 | |
| 494 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 495 | |
| 496 | SymbolContextList sc_list; |
| 497 | |
| 498 | const ConstString name(context.m_decl_name.getAsString().c_str()); |
| 499 | |
| 500 | const char *name_unique_cstr = name.GetCString(); |
| 501 | |
| 502 | if (name_unique_cstr == NULL) |
| 503 | return; |
| 504 | |
| 505 | // The ClangASTSource is not responsible for finding $-names. |
| 506 | if (name_unique_cstr[0] == '$') |
| 507 | return; |
| 508 | |
| 509 | if (module_sp && namespace_decl) |
| 510 | { |
| 511 | ClangNamespaceDecl found_namespace_decl; |
| 512 | |
| 513 | SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); |
| 514 | |
| 515 | if (symbol_vendor) |
| 516 | { |
| 517 | SymbolContext null_sc; |
| 518 | |
| 519 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl); |
| 520 | |
| 521 | if (found_namespace_decl) |
| 522 | { |
| 523 | context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl)); |
| 524 | |
| 525 | if (log) |
| 526 | log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s", |
| 527 | current_id, |
| 528 | name.GetCString(), |
| 529 | module_sp->GetFileSpec().GetFilename().GetCString()); |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | else |
| 534 | { |
| 535 | ModuleList &images = m_target->GetImages(); |
| 536 | |
| 537 | for (uint32_t i = 0, e = images.GetSize(); |
| 538 | i != e; |
| 539 | ++i) |
| 540 | { |
| 541 | lldb::ModuleSP image = images.GetModuleAtIndex(i); |
| 542 | |
| 543 | if (!image) |
| 544 | continue; |
| 545 | |
| 546 | ClangNamespaceDecl found_namespace_decl; |
| 547 | |
| 548 | SymbolVendor *symbol_vendor = image->GetSymbolVendor(); |
| 549 | |
| 550 | if (!symbol_vendor) |
| 551 | continue; |
| 552 | |
| 553 | SymbolContext null_sc; |
| 554 | |
| 555 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl); |
| 556 | |
| 557 | if (found_namespace_decl) |
| 558 | { |
| 559 | context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl)); |
| 560 | |
| 561 | if (log) |
| 562 | log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s", |
| 563 | current_id, |
| 564 | name.GetCString(), |
| 565 | image->GetFileSpec().GetFilename().GetCString()); |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | static ConstString id_name("id"); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 571 | static ConstString Class_name("Class"); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 572 | |
| 573 | do |
| 574 | { |
| 575 | TypeList types; |
| 576 | SymbolContext null_sc; |
| 577 | |
Sean Callanan | 0f71d19 | 2011-12-19 19:38:39 +0000 | [diff] [blame] | 578 | if (name == id_name || name == Class_name) |
| 579 | break; |
| 580 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 581 | if (module_sp && namespace_decl) |
| 582 | module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types); |
Sean Callanan | 0f71d19 | 2011-12-19 19:38:39 +0000 | [diff] [blame] | 583 | else |
Sean Callanan | e1301a6 | 2011-12-06 03:41:14 +0000 | [diff] [blame] | 584 | m_target->GetImages().FindTypes(null_sc, name, true, 1, types); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 585 | |
| 586 | if (types.GetSize()) |
| 587 | { |
| 588 | lldb::TypeSP type_sp = types.GetTypeAtIndex(0); |
| 589 | |
| 590 | if (log) |
| 591 | { |
| 592 | const char *name_string = type_sp->GetName().GetCString(); |
| 593 | |
| 594 | log->Printf(" CAS::FEVD[%u] Matching type found for \"%s\": %s", |
| 595 | current_id, |
| 596 | name.GetCString(), |
| 597 | (name_string ? name_string : "<anonymous>")); |
| 598 | } |
| 599 | |
Sean Callanan | e1301a6 | 2011-12-06 03:41:14 +0000 | [diff] [blame] | 600 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 601 | void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType()); |
Sean Callanan | e1301a6 | 2011-12-06 03:41:14 +0000 | [diff] [blame] | 602 | |
Sean Callanan | dc5fce1 | 2011-12-01 21:04:37 +0000 | [diff] [blame] | 603 | if (!copied_type) |
| 604 | { |
| 605 | if (log) |
Sean Callanan | e1301a6 | 2011-12-06 03:41:14 +0000 | [diff] [blame] | 606 | log->Printf(" CAS::FEVD[%u] - Couldn't export the type for a constant integer result", |
| 607 | current_id); |
| 608 | |
Sean Callanan | dc5fce1 | 2011-12-01 21:04:37 +0000 | [diff] [blame] | 609 | break; |
| 610 | } |
| 611 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 612 | context.AddTypeDecl(copied_type); |
| 613 | } |
Sean Callanan | 673f3db | 2011-11-30 22:11:59 +0000 | [diff] [blame] | 614 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 615 | } while(0); |
| 616 | } |
| 617 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 618 | void |
| 619 | ClangASTSource::FindObjCMethodDecls (NameSearchContext &context) |
| 620 | { |
| 621 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 622 | |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 623 | static unsigned int invocation_id = 0; |
| 624 | unsigned int current_id = invocation_id++; |
| 625 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 626 | const DeclarationName &decl_name(context.m_decl_name); |
| 627 | const DeclContext *decl_ctx(context.m_decl_context); |
| 628 | |
| 629 | const ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl_ctx); |
| 630 | |
| 631 | if (!interface_decl) |
| 632 | return; |
| 633 | |
| 634 | StreamString ss; |
Sean Callanan | e1301a6 | 2011-12-06 03:41:14 +0000 | [diff] [blame] | 635 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 636 | if (decl_name.isObjCZeroArgSelector()) |
| 637 | { |
| 638 | ss.Printf("%s", decl_name.getAsString().c_str()); |
| 639 | } |
| 640 | else if (decl_name.isObjCOneArgSelector()) |
| 641 | { |
Sean Callanan | 1d9ffe2 | 2011-11-14 18:29:46 +0000 | [diff] [blame] | 642 | ss.Printf("%s", decl_name.getAsString().c_str()); |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 643 | } |
| 644 | else |
| 645 | { |
| 646 | clang::Selector sel = decl_name.getObjCSelector(); |
| 647 | |
| 648 | for (unsigned i = 0, e = sel.getNumArgs(); |
| 649 | i != e; |
| 650 | ++i) |
| 651 | { |
| 652 | llvm::StringRef r = sel.getNameForSlot(i); |
| 653 | ss.Printf("%s:", r.str().c_str()); |
| 654 | } |
| 655 | } |
| 656 | ss.Flush(); |
| 657 | |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 658 | ConstString selector_name(ss.GetData()); |
| 659 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 660 | if (log) |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 661 | log->Printf("ClangASTSource::FindObjCMethodDecls[%d] on (ASTContext*)%p for selector [%s %s]", |
| 662 | current_id, |
| 663 | m_ast_context, |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 664 | interface_decl->getNameAsString().c_str(), |
| 665 | selector_name.AsCString()); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 666 | SymbolContextList sc_list; |
| 667 | |
| 668 | const bool include_symbols = false; |
| 669 | const bool append = false; |
| 670 | |
Sean Callanan | e0028b8 | 2012-01-19 02:17:40 +0000 | [diff] [blame^] | 671 | std::string interface_name = interface_decl->getNameAsString(); |
| 672 | |
| 673 | do |
| 674 | { |
| 675 | StreamString ms; |
| 676 | ms.Printf("-[%s %s]", interface_name.c_str(), selector_name.AsCString()); |
| 677 | ms.Flush(); |
| 678 | ConstString instance_method_name(ms.GetData()); |
| 679 | |
| 680 | m_target->GetImages().FindFunctions(instance_method_name, lldb::eFunctionNameTypeFull, include_symbols, append, sc_list); |
| 681 | |
| 682 | if (sc_list.GetSize()) |
| 683 | break; |
| 684 | |
| 685 | ms.Clear(); |
| 686 | ms.Printf("+[%s %s]", interface_name.c_str(), selector_name.AsCString()); |
| 687 | ms.Flush(); |
| 688 | ConstString class_method_name(ms.GetData()); |
| 689 | |
| 690 | m_target->GetImages().FindFunctions(class_method_name, lldb::eFunctionNameTypeFull, include_symbols, append, sc_list); |
| 691 | |
| 692 | if (sc_list.GetSize()) |
| 693 | break; |
| 694 | |
| 695 | // Fall back and check for methods in categories. If we find methods this way, we need to check that they're actually in |
| 696 | // categories on the desired class. |
| 697 | |
| 698 | SymbolContextList candidate_sc_list; |
| 699 | |
| 700 | m_target->GetImages().FindFunctions(selector_name, lldb::eFunctionNameTypeSelector, include_symbols, append, candidate_sc_list); |
| 701 | |
| 702 | for (uint32_t ci = 0, ce = candidate_sc_list.GetSize(); |
| 703 | ci != ce; |
| 704 | ++ci) |
| 705 | { |
| 706 | SymbolContext candidate_sc; |
| 707 | |
| 708 | if (!candidate_sc_list.GetContextAtIndex(ci, candidate_sc)) |
| 709 | continue; |
| 710 | |
| 711 | if (!candidate_sc.function) |
| 712 | continue; |
| 713 | |
| 714 | const char *candidate_name = candidate_sc.function->GetName().AsCString(); |
| 715 | |
| 716 | const char *cursor = candidate_name; |
| 717 | |
| 718 | if (*cursor != '+' && *cursor != '-') |
| 719 | continue; |
| 720 | |
| 721 | ++cursor; |
| 722 | |
| 723 | if (*cursor != '[') |
| 724 | continue; |
| 725 | |
| 726 | ++cursor; |
| 727 | |
| 728 | size_t interface_len = interface_name.length(); |
| 729 | |
| 730 | if (strncmp(cursor, interface_name.c_str(), interface_len)) |
| 731 | continue; |
| 732 | |
| 733 | cursor += interface_len; |
| 734 | |
| 735 | if (*cursor == ' ' || *cursor == '(') |
| 736 | sc_list.Append(candidate_sc); |
| 737 | } |
| 738 | } |
| 739 | while (0); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 740 | |
| 741 | for (uint32_t i = 0, e = sc_list.GetSize(); |
| 742 | i != e; |
| 743 | ++i) |
| 744 | { |
| 745 | SymbolContext sc; |
| 746 | |
| 747 | if (!sc_list.GetContextAtIndex(i, sc)) |
| 748 | continue; |
| 749 | |
| 750 | if (!sc.function) |
| 751 | continue; |
| 752 | |
| 753 | DeclContext *function_ctx = sc.function->GetClangDeclContext(); |
| 754 | |
| 755 | if (!function_ctx) |
| 756 | continue; |
| 757 | |
| 758 | ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(function_ctx); |
| 759 | |
| 760 | if (!method_decl) |
| 761 | continue; |
| 762 | |
| 763 | ObjCInterfaceDecl *found_interface_decl = method_decl->getClassInterface(); |
| 764 | |
| 765 | if (!found_interface_decl) |
| 766 | continue; |
| 767 | |
| 768 | if (found_interface_decl->getName() == interface_decl->getName()) |
| 769 | { |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 770 | Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 771 | |
| 772 | if (!copied_decl) |
| 773 | continue; |
| 774 | |
| 775 | ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl); |
| 776 | |
| 777 | if (!copied_method_decl) |
| 778 | continue; |
| 779 | |
| 780 | if (log) |
| 781 | { |
| 782 | ASTDumper dumper((Decl*)copied_method_decl); |
Sean Callanan | e1301a6 | 2011-12-06 03:41:14 +0000 | [diff] [blame] | 783 | log->Printf(" CAS::FOMD[%d] found (in debug info) %s", current_id, dumper.GetCString()); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 784 | } |
Sean Callanan | e0028b8 | 2012-01-19 02:17:40 +0000 | [diff] [blame^] | 785 | |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame] | 786 | context.AddNamedDecl(copied_method_decl); |
| 787 | } |
| 788 | } |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Sean Callanan | e6ea5fe | 2011-11-15 02:11:17 +0000 | [diff] [blame] | 791 | void |
| 792 | ClangASTSource::FindObjCPropertyDecls (NameSearchContext &context) |
| 793 | { |
| 794 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 795 | |
| 796 | static unsigned int invocation_id = 0; |
| 797 | unsigned int current_id = invocation_id++; |
| 798 | |
| 799 | const ObjCInterfaceDecl *iface_decl = cast<ObjCInterfaceDecl>(context.m_decl_context); |
| 800 | Decl *orig_decl; |
| 801 | ASTContext *orig_ast_ctx; |
| 802 | |
| 803 | m_ast_importer->ResolveDeclOrigin(iface_decl, &orig_decl, &orig_ast_ctx); |
| 804 | |
| 805 | if (!orig_decl) |
| 806 | return; |
| 807 | |
| 808 | ObjCInterfaceDecl *orig_iface_decl = dyn_cast<ObjCInterfaceDecl>(orig_decl); |
| 809 | |
| 810 | if (!orig_iface_decl) |
| 811 | return; |
| 812 | |
| 813 | if (!ClangASTContext::GetCompleteDecl(orig_ast_ctx, orig_iface_decl)) |
| 814 | return; |
| 815 | |
| 816 | std::string property_name_str = context.m_decl_name.getAsString(); |
| 817 | StringRef property_name(property_name_str.c_str()); |
| 818 | ObjCPropertyDecl *property_decl = orig_iface_decl->FindPropertyDeclaration(&orig_ast_ctx->Idents.get(property_name)); |
| 819 | |
| 820 | if (log) |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 821 | log->Printf("ClangASTSource::FindObjCPropertyDecls[%d] on (ASTContext*)%p for property '%s.%s'", |
Sean Callanan | e6ea5fe | 2011-11-15 02:11:17 +0000 | [diff] [blame] | 822 | current_id, |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 823 | m_ast_context, |
Sean Callanan | e6ea5fe | 2011-11-15 02:11:17 +0000 | [diff] [blame] | 824 | iface_decl->getNameAsString().c_str(), |
| 825 | property_name_str.c_str()); |
| 826 | |
| 827 | if (!property_decl) |
| 828 | return; |
| 829 | |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 830 | Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, orig_ast_ctx, property_decl); |
Sean Callanan | e6ea5fe | 2011-11-15 02:11:17 +0000 | [diff] [blame] | 831 | |
| 832 | if (!copied_decl) |
| 833 | return; |
| 834 | |
| 835 | ObjCPropertyDecl *copied_property_decl = dyn_cast<ObjCPropertyDecl>(copied_decl); |
| 836 | |
| 837 | if (!copied_property_decl) |
| 838 | return; |
| 839 | |
| 840 | if (log) |
| 841 | { |
| 842 | ASTDumper dumper((Decl*)copied_property_decl); |
| 843 | log->Printf(" CAS::FOPD[%d] found %s", current_id, dumper.GetCString()); |
| 844 | } |
| 845 | |
| 846 | context.AddNamedDecl(copied_property_decl); |
| 847 | } |
| 848 | |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 849 | void |
| 850 | ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map, |
| 851 | const ConstString &name, |
| 852 | ClangASTImporter::NamespaceMapSP &parent_map) const |
| 853 | { |
| 854 | static unsigned int invocation_id = 0; |
| 855 | unsigned int current_id = invocation_id++; |
| 856 | |
| 857 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 858 | |
| 859 | if (log) |
| 860 | { |
| 861 | if (parent_map && parent_map->size()) |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 862 | log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s in namespace %s", |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 863 | current_id, |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 864 | m_ast_context, |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 865 | name.GetCString(), |
| 866 | parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str()); |
| 867 | else |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 868 | log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s", |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 869 | current_id, |
Sean Callanan | 5a55c7a | 2011-11-18 03:28:09 +0000 | [diff] [blame] | 870 | m_ast_context, |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 871 | name.GetCString()); |
| 872 | } |
| 873 | |
| 874 | |
| 875 | if (parent_map) |
| 876 | { |
| 877 | for (ClangASTImporter::NamespaceMap::iterator i = parent_map->begin(), e = parent_map->end(); |
| 878 | i != e; |
| 879 | ++i) |
| 880 | { |
| 881 | ClangNamespaceDecl found_namespace_decl; |
| 882 | |
| 883 | lldb::ModuleSP module_sp = i->first; |
| 884 | ClangNamespaceDecl module_parent_namespace_decl = i->second; |
| 885 | |
| 886 | SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); |
| 887 | |
| 888 | if (!symbol_vendor) |
| 889 | continue; |
| 890 | |
| 891 | SymbolContext null_sc; |
| 892 | |
| 893 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &module_parent_namespace_decl); |
| 894 | |
| 895 | if (!found_namespace_decl) |
| 896 | continue; |
| 897 | |
| 898 | namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl)); |
| 899 | |
| 900 | if (log) |
| 901 | log->Printf(" CMN[%u] Found namespace %s in module %s", |
| 902 | current_id, |
| 903 | name.GetCString(), |
| 904 | module_sp->GetFileSpec().GetFilename().GetCString()); |
| 905 | } |
| 906 | } |
| 907 | else |
| 908 | { |
| 909 | ModuleList &images = m_target->GetImages(); |
| 910 | ClangNamespaceDecl null_namespace_decl; |
| 911 | |
| 912 | for (uint32_t i = 0, e = images.GetSize(); |
| 913 | i != e; |
| 914 | ++i) |
| 915 | { |
| 916 | lldb::ModuleSP image = images.GetModuleAtIndex(i); |
| 917 | |
| 918 | if (!image) |
| 919 | continue; |
| 920 | |
| 921 | ClangNamespaceDecl found_namespace_decl; |
| 922 | |
| 923 | SymbolVendor *symbol_vendor = image->GetSymbolVendor(); |
| 924 | |
| 925 | if (!symbol_vendor) |
| 926 | continue; |
| 927 | |
| 928 | SymbolContext null_sc; |
| 929 | |
| 930 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &null_namespace_decl); |
| 931 | |
| 932 | if (!found_namespace_decl) |
| 933 | continue; |
| 934 | |
| 935 | namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl)); |
| 936 | |
| 937 | if (log) |
| 938 | log->Printf(" CMN[%u] Found namespace %s in module %s", |
| 939 | current_id, |
| 940 | name.GetCString(), |
| 941 | image->GetFileSpec().GetFilename().GetCString()); |
| 942 | } |
| 943 | } |
| 944 | } |
| 945 | |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 946 | NamespaceDecl * |
| 947 | ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls) |
| 948 | { |
| 949 | if (namespace_decls.empty()) |
| 950 | return NULL; |
| 951 | |
| 952 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 953 | |
| 954 | const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second; |
| 955 | |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 956 | Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl()); |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 957 | |
| 958 | NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl); |
| 959 | |
| 960 | m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls); |
| 961 | |
| 962 | return dyn_cast<NamespaceDecl>(copied_decl); |
| 963 | } |
| 964 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 965 | void * |
| 966 | ClangASTSource::GuardedCopyType (ASTContext *dest_context, |
| 967 | ASTContext *source_context, |
| 968 | void *clang_type) |
| 969 | { |
| 970 | SetImportInProgress(true); |
| 971 | |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 972 | QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type)); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 973 | |
| 974 | void *ret = ret_qual_type.getAsOpaquePtr(); |
| 975 | |
| 976 | SetImportInProgress(false); |
| 977 | |
| 978 | return ret; |
| 979 | } |
| 980 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 981 | clang::NamedDecl * |
| 982 | NameSearchContext::AddVarDecl(void *type) |
| 983 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 984 | IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo(); |
Sean Callanan | 1ddd9fe | 2010-11-30 00:27:43 +0000 | [diff] [blame] | 985 | |
| 986 | assert (type && "Type for variable must be non-NULL!"); |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 987 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 988 | clang::NamedDecl *Decl = VarDecl::Create(*m_ast_source.m_ast_context, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 989 | const_cast<DeclContext*>(m_decl_context), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 990 | SourceLocation(), |
Sean Callanan | 279584c | 2011-03-15 00:17:19 +0000 | [diff] [blame] | 991 | SourceLocation(), |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 992 | ii, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 993 | QualType::getFromOpaquePtr(type), |
| 994 | 0, |
Sean Callanan | 47a5c4c | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 995 | SC_Static, |
| 996 | SC_Static); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 997 | m_decls.push_back(Decl); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 998 | |
| 999 | return Decl; |
| 1000 | } |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1001 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 1002 | clang::NamedDecl * |
| 1003 | NameSearchContext::AddFunDecl (void *type) |
| 1004 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 1005 | clang::FunctionDecl *func_decl = FunctionDecl::Create (*m_ast_source.m_ast_context, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1006 | const_cast<DeclContext*>(m_decl_context), |
| 1007 | SourceLocation(), |
Sean Callanan | 279584c | 2011-03-15 00:17:19 +0000 | [diff] [blame] | 1008 | SourceLocation(), |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1009 | m_decl_name.getAsIdentifierInfo(), |
| 1010 | QualType::getFromOpaquePtr(type), |
| 1011 | NULL, |
| 1012 | SC_Static, |
| 1013 | SC_Static, |
| 1014 | false, |
| 1015 | true); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1016 | |
Sean Callanan | b291abe | 2010-08-12 23:45:38 +0000 | [diff] [blame] | 1017 | // We have to do more than just synthesize the FunctionDecl. We have to |
| 1018 | // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do |
| 1019 | // this, we raid the function's FunctionProtoType for types. |
| 1020 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1021 | QualType qual_type (QualType::getFromOpaquePtr(type)); |
Sean Callanan | 21f2e19 | 2011-12-14 01:13:04 +0000 | [diff] [blame] | 1022 | const FunctionProtoType *func_proto_type = qual_type.getTypePtr()->getAs<FunctionProtoType>(); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1023 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1024 | if (func_proto_type) |
Sean Callanan | 3c821cc | 2010-06-23 18:58:10 +0000 | [diff] [blame] | 1025 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1026 | unsigned NumArgs = func_proto_type->getNumArgs(); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1027 | unsigned ArgIndex; |
| 1028 | |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 1029 | SmallVector<ParmVarDecl *, 5> parm_var_decls; |
| 1030 | |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1031 | for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) |
| 1032 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1033 | QualType arg_qual_type (func_proto_type->getArgType(ArgIndex)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1034 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 1035 | parm_var_decls.push_back(ParmVarDecl::Create (*m_ast_source.m_ast_context, |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 1036 | const_cast<DeclContext*>(m_decl_context), |
| 1037 | SourceLocation(), |
| 1038 | SourceLocation(), |
| 1039 | NULL, |
| 1040 | arg_qual_type, |
| 1041 | NULL, |
| 1042 | SC_Static, |
| 1043 | SC_Static, |
| 1044 | NULL)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1045 | } |
| 1046 | |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 1047 | func_decl->setParams(ArrayRef<ParmVarDecl*>(parm_var_decls)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1048 | } |
Sean Callanan | dc5fce1 | 2011-12-01 21:04:37 +0000 | [diff] [blame] | 1049 | else |
| 1050 | { |
| 1051 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 1052 | |
| 1053 | log->Printf("Function type wasn't a FunctionProtoType"); |
| 1054 | } |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1055 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1056 | m_decls.push_back(func_decl); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1057 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1058 | return func_decl; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1059 | } |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1060 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 1061 | clang::NamedDecl * |
| 1062 | NameSearchContext::AddGenericFunDecl() |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1063 | { |
Sean Callanan | ad29309 | 2011-01-18 23:32:05 +0000 | [diff] [blame] | 1064 | FunctionProtoType::ExtProtoInfo proto_info; |
| 1065 | |
| 1066 | proto_info.Variadic = true; |
| 1067 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 1068 | QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType (m_ast_source.m_ast_context->UnknownAnyTy, // result |
| 1069 | NULL, // argument types |
| 1070 | 0, // number of arguments |
| 1071 | proto_info)); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1072 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1073 | return AddFunDecl(generic_function_type.getAsOpaquePtr()); |
| 1074 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1075 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 1076 | clang::NamedDecl * |
| 1077 | NameSearchContext::AddTypeDecl(void *type) |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1078 | { |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 1079 | if (type) |
| 1080 | { |
| 1081 | QualType qual_type = QualType::getFromOpaquePtr(type); |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1082 | |
Sean Callanan | 21f2e19 | 2011-12-14 01:13:04 +0000 | [diff] [blame] | 1083 | if (const TagType *tag_type = qual_type->getAs<TagType>()) |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 1084 | { |
| 1085 | TagDecl *tag_decl = tag_type->getDecl(); |
| 1086 | |
| 1087 | m_decls.push_back(tag_decl); |
| 1088 | |
| 1089 | return tag_decl; |
| 1090 | } |
Sean Callanan | 21f2e19 | 2011-12-14 01:13:04 +0000 | [diff] [blame] | 1091 | else if (const ObjCObjectType *objc_object_type = qual_type->getAs<ObjCObjectType>()) |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 1092 | { |
| 1093 | ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface(); |
| 1094 | |
| 1095 | m_decls.push_back((NamedDecl*)interface_decl); |
| 1096 | |
| 1097 | return (NamedDecl*)interface_decl; |
| 1098 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1099 | } |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 1100 | return NULL; |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1101 | } |
Greg Clayton | e6d72ca | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 1102 | |
| 1103 | void |
| 1104 | NameSearchContext::AddLookupResult (clang::DeclContextLookupConstResult result) |
| 1105 | { |
| 1106 | for (clang::NamedDecl * const *decl_iterator = result.first; |
| 1107 | decl_iterator != result.second; |
| 1108 | ++decl_iterator) |
| 1109 | m_decls.push_back (*decl_iterator); |
| 1110 | } |
| 1111 | |
| 1112 | void |
| 1113 | NameSearchContext::AddNamedDecl (clang::NamedDecl *decl) |
| 1114 | { |
| 1115 | m_decls.push_back (decl); |
| 1116 | } |