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" |
| 20 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace clang; |
| 23 | using namespace lldb_private; |
| 24 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 25 | ClangASTSource::~ClangASTSource() |
| 26 | { |
| 27 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 29 | void |
| 30 | ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) |
| 31 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 32 | if (!m_ast_context) |
| 33 | return; |
| 34 | |
| 35 | m_ast_context->getTranslationUnitDecl()->setHasExternalVisibleStorage(); |
| 36 | m_ast_context->getTranslationUnitDecl()->setHasExternalLexicalStorage(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | // The core lookup interface. |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 40 | DeclContext::lookup_result |
| 41 | ClangASTSource::FindExternalVisibleDeclsByName |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 42 | ( |
| 43 | const DeclContext *decl_ctx, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 44 | DeclarationName clang_decl_name |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 45 | ) |
| 46 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 47 | if (!m_ast_context) |
| 48 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 49 | |
| 50 | if (GetImportInProgress()) |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 51 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 52 | |
| 53 | std::string decl_name (clang_decl_name.getAsString()); |
| 54 | |
| 55 | // if (m_decl_map.DoingASTImport ()) |
| 56 | // return DeclContext::lookup_result(); |
| 57 | // |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 58 | switch (clang_decl_name.getNameKind()) { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | // Normal identifiers. |
| 60 | case DeclarationName::Identifier: |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 61 | if (clang_decl_name.getAsIdentifierInfo()->getBuiltinID() != 0) |
| 62 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 63 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 64 | |
| 65 | // Operator names. Not important for now. |
| 66 | case DeclarationName::CXXOperatorName: |
| 67 | case DeclarationName::CXXLiteralOperatorName: |
| 68 | return DeclContext::lookup_result(); |
| 69 | |
| 70 | // Using directives found in this context. |
| 71 | // Tell Sema we didn't find any or we'll end up getting asked a *lot*. |
| 72 | case DeclarationName::CXXUsingDirective: |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 73 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 74 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 75 | case DeclarationName::ObjCZeroArgSelector: |
| 76 | case DeclarationName::ObjCOneArgSelector: |
| 77 | case DeclarationName::ObjCMultiArgSelector: |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 78 | { |
| 79 | llvm::SmallVector<NamedDecl*, 1> method_decls; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 81 | NameSearchContext method_search_context (*this, method_decls, clang_decl_name, decl_ctx); |
| 82 | |
| 83 | FindObjCMethodDecls(method_search_context); |
| 84 | |
| 85 | return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls); |
| 86 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 87 | // These aren't possible in the global context. |
| 88 | case DeclarationName::CXXConstructorName: |
| 89 | case DeclarationName::CXXDestructorName: |
| 90 | case DeclarationName::CXXConversionFunctionName: |
| 91 | return DeclContext::lookup_result(); |
| 92 | } |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 93 | |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 94 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 95 | if (!GetLookupsEnabled()) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 96 | { |
| 97 | // Wait until we see a '$' at the start of a name before we start doing |
| 98 | // any lookups so we can avoid lookup up all of the builtin types. |
| 99 | if (!decl_name.empty() && decl_name[0] == '$') |
| 100 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 101 | SetLookupsEnabled (true); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 102 | } |
| 103 | else |
| 104 | { |
| 105 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 106 | } |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 107 | } |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 108 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 109 | ConstString const_decl_name(decl_name.c_str()); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 110 | |
| 111 | const char *uniqued_const_decl_name = const_decl_name.GetCString(); |
| 112 | if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end()) |
| 113 | { |
| 114 | // We are currently looking up this name... |
| 115 | return DeclContext::lookup_result(); |
| 116 | } |
| 117 | m_active_lookups.insert(uniqued_const_decl_name); |
Greg Clayton | a8b278a | 2010-11-15 01:34:18 +0000 | [diff] [blame] | 118 | // static uint32_t g_depth = 0; |
| 119 | // ++g_depth; |
| 120 | // printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth, uniqued_const_decl_name); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 121 | llvm::SmallVector<NamedDecl*, 4> name_decls; |
| 122 | NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 123 | FindExternalVisibleDecls(name_search_context); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 124 | DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls)); |
Greg Clayton | a8b278a | 2010-11-15 01:34:18 +0000 | [diff] [blame] | 125 | // --g_depth; |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 126 | m_active_lookups.erase (uniqued_const_decl_name); |
| 127 | return result; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 130 | void |
| 131 | ClangASTSource::CompleteType (TagDecl *tag_decl) |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 132 | { |
| 133 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 134 | |
| 135 | if (log) |
| 136 | { |
| 137 | log->Printf(" [CompleteTagDecl] Completing a TagDecl named %s", tag_decl->getName().str().c_str()); |
| 138 | log->Printf(" [CTD] Before:"); |
| 139 | ASTDumper dumper((Decl*)tag_decl); |
| 140 | dumper.ToLog(log, " [CTD] "); |
| 141 | } |
| 142 | |
| 143 | m_ast_importer->CompleteTagDecl (tag_decl); |
| 144 | |
| 145 | if (log) |
| 146 | { |
| 147 | log->Printf(" [CTD] After:"); |
| 148 | ASTDumper dumper((Decl*)tag_decl); |
| 149 | dumper.ToLog(log, " [CTD] "); |
| 150 | } |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | void |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 154 | ClangASTSource::CompleteType (clang::ObjCInterfaceDecl *interface_decl) |
| 155 | { |
| 156 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 157 | |
| 158 | if (log) |
| 159 | { |
| 160 | log->Printf(" [CompleteObjCInterfaceDecl] Completing an ObjCInterfaceDecl named %s", interface_decl->getName().str().c_str()); |
| 161 | log->Printf(" [COID] Before:"); |
| 162 | ASTDumper dumper((Decl*)interface_decl); |
| 163 | dumper.ToLog(log, " [COID] "); |
| 164 | } |
| 165 | |
| 166 | m_ast_importer->CompleteObjCInterfaceDecl (interface_decl); |
| 167 | |
| 168 | if (log) |
| 169 | { |
| 170 | log->Printf(" [COID] After:"); |
| 171 | ASTDumper dumper((Decl*)interface_decl); |
| 172 | dumper.ToLog(log, " [COID] "); |
| 173 | } |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Sean Callanan | 9b6898f | 2011-07-30 02:42:06 +0000 | [diff] [blame] | 176 | clang::ExternalLoadResult |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 177 | ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context, |
| 178 | bool (*predicate)(Decl::Kind), |
| 179 | llvm::SmallVectorImpl<Decl*> &decls) |
| 180 | { |
| 181 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 182 | |
| 183 | const Decl *context_decl = dyn_cast<Decl>(decl_context); |
| 184 | |
| 185 | if (!context_decl) |
| 186 | return ELR_Failure; |
| 187 | |
| 188 | static unsigned int invocation_id = 0; |
| 189 | unsigned int current_id = invocation_id++; |
| 190 | |
| 191 | if (log) |
| 192 | { |
| 193 | if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl)) |
| 194 | log->Printf("FindExternalLexicalDecls[%u] in '%s' (a %s) with %s predicate", |
| 195 | current_id, |
| 196 | context_named_decl->getNameAsString().c_str(), |
| 197 | context_decl->getDeclKindName(), |
| 198 | (predicate ? "non-null" : "null")); |
| 199 | else if(context_decl) |
| 200 | log->Printf("FindExternalLexicalDecls[%u] in a %s with %s predicate", |
| 201 | current_id, |
| 202 | context_decl->getDeclKindName(), |
| 203 | (predicate ? "non-null" : "null")); |
| 204 | else |
| 205 | log->Printf("FindExternalLexicalDecls[%u] in a NULL context with %s predicate", |
| 206 | current_id, |
| 207 | (predicate ? "non-null" : "null")); |
| 208 | } |
| 209 | |
| 210 | Decl *original_decl = NULL; |
| 211 | ASTContext *original_ctx = NULL; |
| 212 | |
| 213 | if (!m_ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx)) |
| 214 | return ELR_Failure; |
| 215 | |
| 216 | if (log) |
| 217 | { |
| 218 | log->Printf(" FELD[%u] Original decl:", current_id); |
| 219 | ASTDumper(original_decl).ToLog(log, " "); |
| 220 | } |
| 221 | |
| 222 | if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl)) |
| 223 | { |
| 224 | ExternalASTSource *external_source = original_ctx->getExternalSource(); |
| 225 | |
| 226 | if (external_source) |
| 227 | external_source->CompleteType (original_tag_decl); |
| 228 | } |
| 229 | |
| 230 | DeclContext *original_decl_context = dyn_cast<DeclContext>(original_decl); |
| 231 | |
| 232 | if (!original_decl_context) |
| 233 | return ELR_Failure; |
| 234 | |
| 235 | for (TagDecl::decl_iterator iter = original_decl_context->decls_begin(); |
| 236 | iter != original_decl_context->decls_end(); |
| 237 | ++iter) |
| 238 | { |
| 239 | Decl *decl = *iter; |
| 240 | |
| 241 | if (!predicate || predicate(decl->getKind())) |
| 242 | { |
| 243 | if (log) |
| 244 | { |
| 245 | ASTDumper ast_dumper(decl); |
| 246 | if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl)) |
| 247 | log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString()); |
| 248 | else |
| 249 | log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString()); |
| 250 | } |
| 251 | |
| 252 | Decl *copied_decl = m_ast_importer->CopyDecl(original_ctx, decl); |
| 253 | |
| 254 | decls.push_back(copied_decl); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return ELR_AlreadyLoaded; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 259 | } |
| 260 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 261 | void |
| 262 | ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context) |
| 263 | { |
| 264 | assert (m_ast_context); |
| 265 | |
| 266 | const ConstString name(context.m_decl_name.getAsString().c_str()); |
| 267 | |
| 268 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 269 | |
| 270 | static unsigned int invocation_id = 0; |
| 271 | unsigned int current_id = invocation_id++; |
| 272 | |
| 273 | if (log) |
| 274 | { |
| 275 | if (!context.m_decl_context) |
| 276 | log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in a NULL DeclContext", current_id, name.GetCString()); |
| 277 | else if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context.m_decl_context)) |
| 278 | log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in '%s'", current_id, name.GetCString(), context_named_decl->getNameAsString().c_str()); |
| 279 | else |
| 280 | log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in a '%s'", current_id, name.GetCString(), context.m_decl_context->getDeclKindName()); |
| 281 | } |
| 282 | |
| 283 | context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap); |
| 284 | |
| 285 | if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context)) |
| 286 | { |
| 287 | ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context); |
| 288 | |
| 289 | if (log && log->GetVerbose()) |
| 290 | log->Printf(" CAS::FEVD[%u] Inspecting namespace map %p (%d entries)", |
| 291 | current_id, |
| 292 | namespace_map.get(), |
| 293 | (int)namespace_map->size()); |
| 294 | |
| 295 | if (!namespace_map) |
| 296 | return; |
| 297 | |
| 298 | for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end(); |
| 299 | i != e; |
| 300 | ++i) |
| 301 | { |
| 302 | if (log) |
| 303 | log->Printf(" CAS::FEVD[%u] Searching namespace %s in module %s", |
| 304 | current_id, |
| 305 | i->second.GetNamespaceDecl()->getNameAsString().c_str(), |
| 306 | i->first->GetFileSpec().GetFilename().GetCString()); |
| 307 | |
| 308 | FindExternalVisibleDecls(context, |
| 309 | i->first, |
| 310 | i->second, |
| 311 | current_id); |
| 312 | } |
| 313 | } |
| 314 | else if (!isa<TranslationUnitDecl>(context.m_decl_context)) |
| 315 | { |
| 316 | // we shouldn't be getting FindExternalVisibleDecls calls for these |
| 317 | return; |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | ClangNamespaceDecl namespace_decl; |
| 322 | |
| 323 | if (log) |
| 324 | log->Printf(" CAS::FEVD[%u] Searching the root namespace", current_id); |
| 325 | |
| 326 | FindExternalVisibleDecls(context, |
| 327 | lldb::ModuleSP(), |
| 328 | namespace_decl, |
| 329 | current_id); |
| 330 | } |
| 331 | |
| 332 | if (!context.m_namespace_map->empty()) |
| 333 | { |
| 334 | if (log && log->GetVerbose()) |
| 335 | log->Printf(" CAS::FEVD[%u] Registering namespace map %p (%d entries)", |
| 336 | current_id, |
| 337 | context.m_namespace_map.get(), |
| 338 | (int)context.m_namespace_map->size()); |
| 339 | |
| 340 | NamespaceDecl *clang_namespace_decl = AddNamespace(context, context.m_namespace_map); |
| 341 | |
| 342 | if (clang_namespace_decl) |
| 343 | clang_namespace_decl->setHasExternalVisibleStorage(); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | void |
| 348 | ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, |
| 349 | lldb::ModuleSP module_sp, |
| 350 | ClangNamespaceDecl &namespace_decl, |
| 351 | unsigned int current_id) |
| 352 | { |
| 353 | assert (m_ast_context); |
| 354 | |
| 355 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 356 | |
| 357 | SymbolContextList sc_list; |
| 358 | |
| 359 | const ConstString name(context.m_decl_name.getAsString().c_str()); |
| 360 | |
| 361 | const char *name_unique_cstr = name.GetCString(); |
| 362 | |
| 363 | if (name_unique_cstr == NULL) |
| 364 | return; |
| 365 | |
| 366 | // The ClangASTSource is not responsible for finding $-names. |
| 367 | if (name_unique_cstr[0] == '$') |
| 368 | return; |
| 369 | |
| 370 | if (module_sp && namespace_decl) |
| 371 | { |
| 372 | ClangNamespaceDecl found_namespace_decl; |
| 373 | |
| 374 | SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); |
| 375 | |
| 376 | if (symbol_vendor) |
| 377 | { |
| 378 | SymbolContext null_sc; |
| 379 | |
| 380 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl); |
| 381 | |
| 382 | if (found_namespace_decl) |
| 383 | { |
| 384 | context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl)); |
| 385 | |
| 386 | if (log) |
| 387 | log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s", |
| 388 | current_id, |
| 389 | name.GetCString(), |
| 390 | module_sp->GetFileSpec().GetFilename().GetCString()); |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | else |
| 395 | { |
| 396 | ModuleList &images = m_target->GetImages(); |
| 397 | |
| 398 | for (uint32_t i = 0, e = images.GetSize(); |
| 399 | i != e; |
| 400 | ++i) |
| 401 | { |
| 402 | lldb::ModuleSP image = images.GetModuleAtIndex(i); |
| 403 | |
| 404 | if (!image) |
| 405 | continue; |
| 406 | |
| 407 | ClangNamespaceDecl found_namespace_decl; |
| 408 | |
| 409 | SymbolVendor *symbol_vendor = image->GetSymbolVendor(); |
| 410 | |
| 411 | if (!symbol_vendor) |
| 412 | continue; |
| 413 | |
| 414 | SymbolContext null_sc; |
| 415 | |
| 416 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl); |
| 417 | |
| 418 | if (found_namespace_decl) |
| 419 | { |
| 420 | context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl)); |
| 421 | |
| 422 | if (log) |
| 423 | log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s", |
| 424 | current_id, |
| 425 | name.GetCString(), |
| 426 | image->GetFileSpec().GetFilename().GetCString()); |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | static ConstString id_name("id"); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame^] | 432 | static ConstString Class_name("Class"); |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 433 | |
| 434 | do |
| 435 | { |
| 436 | TypeList types; |
| 437 | SymbolContext null_sc; |
| 438 | |
| 439 | if (module_sp && namespace_decl) |
| 440 | module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types); |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame^] | 441 | else if(name != id_name && name != Class_name) |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 442 | m_target->GetImages().FindTypes (null_sc, name, true, 1, types); |
| 443 | else |
| 444 | break; |
| 445 | |
| 446 | if (types.GetSize()) |
| 447 | { |
| 448 | lldb::TypeSP type_sp = types.GetTypeAtIndex(0); |
| 449 | |
| 450 | if (log) |
| 451 | { |
| 452 | const char *name_string = type_sp->GetName().GetCString(); |
| 453 | |
| 454 | log->Printf(" CAS::FEVD[%u] Matching type found for \"%s\": %s", |
| 455 | current_id, |
| 456 | name.GetCString(), |
| 457 | (name_string ? name_string : "<anonymous>")); |
| 458 | } |
| 459 | |
| 460 | void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType()); |
| 461 | |
| 462 | context.AddTypeDecl(copied_type); |
| 463 | } |
| 464 | } while(0); |
| 465 | } |
| 466 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 467 | void |
| 468 | ClangASTSource::FindObjCMethodDecls (NameSearchContext &context) |
| 469 | { |
| 470 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 471 | |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame^] | 472 | static unsigned int invocation_id = 0; |
| 473 | unsigned int current_id = invocation_id++; |
| 474 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 475 | const DeclarationName &decl_name(context.m_decl_name); |
| 476 | const DeclContext *decl_ctx(context.m_decl_context); |
| 477 | |
| 478 | const ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl_ctx); |
| 479 | |
| 480 | if (!interface_decl) |
| 481 | return; |
| 482 | |
| 483 | StreamString ss; |
| 484 | if (decl_name.isObjCZeroArgSelector()) |
| 485 | { |
| 486 | ss.Printf("%s", decl_name.getAsString().c_str()); |
| 487 | } |
| 488 | else if (decl_name.isObjCOneArgSelector()) |
| 489 | { |
| 490 | ss.Printf("%s:", decl_name.getAsString().c_str()); |
| 491 | } |
| 492 | else |
| 493 | { |
| 494 | clang::Selector sel = decl_name.getObjCSelector(); |
| 495 | |
| 496 | for (unsigned i = 0, e = sel.getNumArgs(); |
| 497 | i != e; |
| 498 | ++i) |
| 499 | { |
| 500 | llvm::StringRef r = sel.getNameForSlot(i); |
| 501 | ss.Printf("%s:", r.str().c_str()); |
| 502 | } |
| 503 | } |
| 504 | ss.Flush(); |
| 505 | |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame^] | 506 | ConstString selector_name(ss.GetData()); |
| 507 | |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 508 | if (log) |
Sean Callanan | f2a0a5c | 2011-11-11 20:37:26 +0000 | [diff] [blame^] | 509 | log->Printf("ClangASTSource::FindObjCMethodDecls[%d] for selector [%s %s]", |
| 510 | current_id, |
| 511 | interface_decl->getNameAsString().c_str(), |
| 512 | selector_name.AsCString()); |
| 513 | |
| 514 | SymbolContextList sc_list; |
| 515 | |
| 516 | const bool include_symbols = false; |
| 517 | const bool append = false; |
| 518 | |
| 519 | m_target->GetImages().FindFunctions(selector_name, lldb::eFunctionNameTypeSelector, include_symbols, append, sc_list); |
| 520 | |
| 521 | for (uint32_t i = 0, e = sc_list.GetSize(); |
| 522 | i != e; |
| 523 | ++i) |
| 524 | { |
| 525 | SymbolContext sc; |
| 526 | |
| 527 | if (!sc_list.GetContextAtIndex(i, sc)) |
| 528 | continue; |
| 529 | |
| 530 | if (!sc.function) |
| 531 | continue; |
| 532 | |
| 533 | DeclContext *function_ctx = sc.function->GetClangDeclContext(); |
| 534 | |
| 535 | if (!function_ctx) |
| 536 | continue; |
| 537 | |
| 538 | ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(function_ctx); |
| 539 | |
| 540 | if (!method_decl) |
| 541 | continue; |
| 542 | |
| 543 | ObjCInterfaceDecl *found_interface_decl = method_decl->getClassInterface(); |
| 544 | |
| 545 | if (!found_interface_decl) |
| 546 | continue; |
| 547 | |
| 548 | if (found_interface_decl->getName() == interface_decl->getName()) |
| 549 | { |
| 550 | Decl *copied_decl = m_ast_importer->CopyDecl(&method_decl->getASTContext(), method_decl); |
| 551 | |
| 552 | if (!copied_decl) |
| 553 | continue; |
| 554 | |
| 555 | ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl); |
| 556 | |
| 557 | if (!copied_method_decl) |
| 558 | continue; |
| 559 | |
| 560 | if (log) |
| 561 | { |
| 562 | ASTDumper dumper((Decl*)copied_method_decl); |
| 563 | log->Printf(" CAS::FOMD[%d] found %s", current_id, dumper.GetCString()); |
| 564 | } |
| 565 | |
| 566 | context.AddNamedDecl(copied_method_decl); |
| 567 | } |
| 568 | } |
Sean Callanan | 9b71484 | 2011-11-09 19:33:21 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame] | 571 | void |
| 572 | ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map, |
| 573 | const ConstString &name, |
| 574 | ClangASTImporter::NamespaceMapSP &parent_map) const |
| 575 | { |
| 576 | static unsigned int invocation_id = 0; |
| 577 | unsigned int current_id = invocation_id++; |
| 578 | |
| 579 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 580 | |
| 581 | if (log) |
| 582 | { |
| 583 | if (parent_map && parent_map->size()) |
| 584 | log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s in namespace %s", |
| 585 | current_id, |
| 586 | name.GetCString(), |
| 587 | parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str()); |
| 588 | else |
| 589 | log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s", |
| 590 | current_id, |
| 591 | name.GetCString()); |
| 592 | } |
| 593 | |
| 594 | |
| 595 | if (parent_map) |
| 596 | { |
| 597 | for (ClangASTImporter::NamespaceMap::iterator i = parent_map->begin(), e = parent_map->end(); |
| 598 | i != e; |
| 599 | ++i) |
| 600 | { |
| 601 | ClangNamespaceDecl found_namespace_decl; |
| 602 | |
| 603 | lldb::ModuleSP module_sp = i->first; |
| 604 | ClangNamespaceDecl module_parent_namespace_decl = i->second; |
| 605 | |
| 606 | SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); |
| 607 | |
| 608 | if (!symbol_vendor) |
| 609 | continue; |
| 610 | |
| 611 | SymbolContext null_sc; |
| 612 | |
| 613 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &module_parent_namespace_decl); |
| 614 | |
| 615 | if (!found_namespace_decl) |
| 616 | continue; |
| 617 | |
| 618 | namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl)); |
| 619 | |
| 620 | if (log) |
| 621 | log->Printf(" CMN[%u] Found namespace %s in module %s", |
| 622 | current_id, |
| 623 | name.GetCString(), |
| 624 | module_sp->GetFileSpec().GetFilename().GetCString()); |
| 625 | } |
| 626 | } |
| 627 | else |
| 628 | { |
| 629 | ModuleList &images = m_target->GetImages(); |
| 630 | ClangNamespaceDecl null_namespace_decl; |
| 631 | |
| 632 | for (uint32_t i = 0, e = images.GetSize(); |
| 633 | i != e; |
| 634 | ++i) |
| 635 | { |
| 636 | lldb::ModuleSP image = images.GetModuleAtIndex(i); |
| 637 | |
| 638 | if (!image) |
| 639 | continue; |
| 640 | |
| 641 | ClangNamespaceDecl found_namespace_decl; |
| 642 | |
| 643 | SymbolVendor *symbol_vendor = image->GetSymbolVendor(); |
| 644 | |
| 645 | if (!symbol_vendor) |
| 646 | continue; |
| 647 | |
| 648 | SymbolContext null_sc; |
| 649 | |
| 650 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &null_namespace_decl); |
| 651 | |
| 652 | if (!found_namespace_decl) |
| 653 | continue; |
| 654 | |
| 655 | namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl)); |
| 656 | |
| 657 | if (log) |
| 658 | log->Printf(" CMN[%u] Found namespace %s in module %s", |
| 659 | current_id, |
| 660 | name.GetCString(), |
| 661 | image->GetFileSpec().GetFilename().GetCString()); |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | |
Sean Callanan | bb715f9 | 2011-10-29 02:28:18 +0000 | [diff] [blame] | 666 | NamespaceDecl * |
| 667 | ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls) |
| 668 | { |
| 669 | if (namespace_decls.empty()) |
| 670 | return NULL; |
| 671 | |
| 672 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 673 | |
| 674 | const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second; |
| 675 | |
| 676 | Decl *copied_decl = m_ast_importer->CopyDecl(namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl()); |
| 677 | |
| 678 | NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl); |
| 679 | |
| 680 | m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls); |
| 681 | |
| 682 | return dyn_cast<NamespaceDecl>(copied_decl); |
| 683 | } |
| 684 | |
Sean Callanan | 9394b5a | 2011-10-29 19:50:43 +0000 | [diff] [blame] | 685 | void * |
| 686 | ClangASTSource::GuardedCopyType (ASTContext *dest_context, |
| 687 | ASTContext *source_context, |
| 688 | void *clang_type) |
| 689 | { |
| 690 | SetImportInProgress(true); |
| 691 | |
| 692 | QualType ret_qual_type = m_ast_importer->CopyType (source_context, QualType::getFromOpaquePtr(clang_type)); |
| 693 | |
| 694 | void *ret = ret_qual_type.getAsOpaquePtr(); |
| 695 | |
| 696 | SetImportInProgress(false); |
| 697 | |
| 698 | return ret; |
| 699 | } |
| 700 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 701 | clang::NamedDecl * |
| 702 | NameSearchContext::AddVarDecl(void *type) |
| 703 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 704 | IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo(); |
Sean Callanan | 1ddd9fe | 2010-11-30 00:27:43 +0000 | [diff] [blame] | 705 | |
| 706 | assert (type && "Type for variable must be non-NULL!"); |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 707 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 708 | clang::NamedDecl *Decl = VarDecl::Create(*m_ast_source.m_ast_context, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 709 | const_cast<DeclContext*>(m_decl_context), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 710 | SourceLocation(), |
Sean Callanan | 279584c | 2011-03-15 00:17:19 +0000 | [diff] [blame] | 711 | SourceLocation(), |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 712 | ii, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 713 | QualType::getFromOpaquePtr(type), |
| 714 | 0, |
Sean Callanan | 47a5c4c | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 715 | SC_Static, |
| 716 | SC_Static); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 717 | m_decls.push_back(Decl); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 718 | |
| 719 | return Decl; |
| 720 | } |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 721 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 722 | clang::NamedDecl * |
| 723 | NameSearchContext::AddFunDecl (void *type) |
| 724 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 725 | clang::FunctionDecl *func_decl = FunctionDecl::Create (*m_ast_source.m_ast_context, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 726 | const_cast<DeclContext*>(m_decl_context), |
| 727 | SourceLocation(), |
Sean Callanan | 279584c | 2011-03-15 00:17:19 +0000 | [diff] [blame] | 728 | SourceLocation(), |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 729 | m_decl_name.getAsIdentifierInfo(), |
| 730 | QualType::getFromOpaquePtr(type), |
| 731 | NULL, |
| 732 | SC_Static, |
| 733 | SC_Static, |
| 734 | false, |
| 735 | true); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 736 | |
Sean Callanan | b291abe | 2010-08-12 23:45:38 +0000 | [diff] [blame] | 737 | // We have to do more than just synthesize the FunctionDecl. We have to |
| 738 | // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do |
| 739 | // this, we raid the function's FunctionProtoType for types. |
| 740 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 741 | QualType qual_type (QualType::getFromOpaquePtr(type)); |
| 742 | const FunctionProtoType *func_proto_type = qual_type->getAs<FunctionProtoType>(); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 743 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 744 | if (func_proto_type) |
Sean Callanan | 3c821cc | 2010-06-23 18:58:10 +0000 | [diff] [blame] | 745 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 746 | unsigned NumArgs = func_proto_type->getNumArgs(); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 747 | unsigned ArgIndex; |
| 748 | |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 749 | SmallVector<ParmVarDecl *, 5> parm_var_decls; |
| 750 | |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 751 | for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) |
| 752 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 753 | QualType arg_qual_type (func_proto_type->getArgType(ArgIndex)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 754 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 755 | 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] | 756 | const_cast<DeclContext*>(m_decl_context), |
| 757 | SourceLocation(), |
| 758 | SourceLocation(), |
| 759 | NULL, |
| 760 | arg_qual_type, |
| 761 | NULL, |
| 762 | SC_Static, |
| 763 | SC_Static, |
| 764 | NULL)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 767 | func_decl->setParams(ArrayRef<ParmVarDecl*>(parm_var_decls)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 768 | } |
| 769 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 770 | m_decls.push_back(func_decl); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 771 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 772 | return func_decl; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 773 | } |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 774 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 775 | clang::NamedDecl * |
| 776 | NameSearchContext::AddGenericFunDecl() |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 777 | { |
Sean Callanan | ad29309 | 2011-01-18 23:32:05 +0000 | [diff] [blame] | 778 | FunctionProtoType::ExtProtoInfo proto_info; |
| 779 | |
| 780 | proto_info.Variadic = true; |
| 781 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 782 | QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType (m_ast_source.m_ast_context->UnknownAnyTy, // result |
| 783 | NULL, // argument types |
| 784 | 0, // number of arguments |
| 785 | proto_info)); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 786 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 787 | return AddFunDecl(generic_function_type.getAsOpaquePtr()); |
| 788 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 789 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 790 | clang::NamedDecl * |
| 791 | NameSearchContext::AddTypeDecl(void *type) |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 792 | { |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 793 | if (type) |
| 794 | { |
| 795 | QualType qual_type = QualType::getFromOpaquePtr(type); |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 796 | |
Sean Callanan | d5b3c35 | 2011-01-27 04:42:51 +0000 | [diff] [blame] | 797 | if (const TagType *tag_type = dyn_cast<clang::TagType>(qual_type)) |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 798 | { |
| 799 | TagDecl *tag_decl = tag_type->getDecl(); |
| 800 | |
| 801 | m_decls.push_back(tag_decl); |
| 802 | |
| 803 | return tag_decl; |
| 804 | } |
Sean Callanan | d5b3c35 | 2011-01-27 04:42:51 +0000 | [diff] [blame] | 805 | else if (const ObjCObjectType *objc_object_type = dyn_cast<clang::ObjCObjectType>(qual_type)) |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 806 | { |
| 807 | ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface(); |
| 808 | |
| 809 | m_decls.push_back((NamedDecl*)interface_decl); |
| 810 | |
| 811 | return (NamedDecl*)interface_decl; |
| 812 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 813 | } |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 814 | return NULL; |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 815 | } |
Greg Clayton | e6d72ca | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 816 | |
| 817 | void |
| 818 | NameSearchContext::AddLookupResult (clang::DeclContextLookupConstResult result) |
| 819 | { |
| 820 | for (clang::NamedDecl * const *decl_iterator = result.first; |
| 821 | decl_iterator != result.second; |
| 822 | ++decl_iterator) |
| 823 | m_decls.push_back (*decl_iterator); |
| 824 | } |
| 825 | |
| 826 | void |
| 827 | NameSearchContext::AddNamedDecl (clang::NamedDecl *decl) |
| 828 | { |
| 829 | m_decls.push_back (decl); |
| 830 | } |