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" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Expression/ClangASTSource.h" |
| 16 | #include "lldb/Expression/ClangExpression.h" |
| 17 | #include "lldb/Expression/ClangExpressionDeclMap.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 | |
| 75 | // These aren't looked up like this. |
| 76 | case DeclarationName::ObjCZeroArgSelector: |
| 77 | case DeclarationName::ObjCOneArgSelector: |
| 78 | case DeclarationName::ObjCMultiArgSelector: |
| 79 | return DeclContext::lookup_result(); |
| 80 | |
| 81 | // These aren't possible in the global context. |
| 82 | case DeclarationName::CXXConstructorName: |
| 83 | case DeclarationName::CXXDestructorName: |
| 84 | case DeclarationName::CXXConversionFunctionName: |
| 85 | return DeclContext::lookup_result(); |
| 86 | } |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 87 | |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 88 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 89 | if (!GetLookupsEnabled()) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 90 | { |
| 91 | // Wait until we see a '$' at the start of a name before we start doing |
| 92 | // any lookups so we can avoid lookup up all of the builtin types. |
| 93 | if (!decl_name.empty() && decl_name[0] == '$') |
| 94 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 95 | SetLookupsEnabled (true); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 96 | } |
| 97 | else |
| 98 | { |
| 99 | return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name); |
| 100 | } |
Greg Clayton | f4c7ae0 | 2010-10-15 03:36:13 +0000 | [diff] [blame] | 101 | } |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 102 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 103 | ConstString const_decl_name(decl_name.c_str()); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 104 | |
| 105 | const char *uniqued_const_decl_name = const_decl_name.GetCString(); |
| 106 | if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end()) |
| 107 | { |
| 108 | // We are currently looking up this name... |
| 109 | return DeclContext::lookup_result(); |
| 110 | } |
| 111 | m_active_lookups.insert(uniqued_const_decl_name); |
Greg Clayton | a8b278a | 2010-11-15 01:34:18 +0000 | [diff] [blame] | 112 | // static uint32_t g_depth = 0; |
| 113 | // ++g_depth; |
| 114 | // printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth, uniqued_const_decl_name); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 115 | llvm::SmallVector<NamedDecl*, 4> name_decls; |
| 116 | NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 117 | FindExternalVisibleDecls(name_search_context); |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 118 | DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls)); |
Greg Clayton | a8b278a | 2010-11-15 01:34:18 +0000 | [diff] [blame] | 119 | // --g_depth; |
Greg Clayton | 9ceed1e | 2010-11-13 04:18:24 +0000 | [diff] [blame] | 120 | m_active_lookups.erase (uniqued_const_decl_name); |
| 121 | return result; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 124 | void |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 125 | ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | void |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 130 | ClangASTSource::CompleteType (TagDecl *tag_decl) |
| 131 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | void |
| 135 | ClangASTSource::CompleteType (ObjCInterfaceDecl *objc_decl) |
| 136 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Sean Callanan | 9b6898f | 2011-07-30 02:42:06 +0000 | [diff] [blame] | 139 | clang::ExternalLoadResult |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 140 | ClangASTSource::FindExternalLexicalDecls |
| 141 | ( |
| 142 | const DeclContext *DC, |
| 143 | bool (*isKindWeWant)(Decl::Kind), |
| 144 | llvm::SmallVectorImpl<Decl*> &Decls |
| 145 | ) |
| 146 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 147 | return ELR_Success; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Sean Callanan | 73b520f | 2011-10-29 01:58:46 +0000 | [diff] [blame^] | 150 | void |
| 151 | ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map, |
| 152 | const ConstString &name, |
| 153 | ClangASTImporter::NamespaceMapSP &parent_map) const |
| 154 | { |
| 155 | static unsigned int invocation_id = 0; |
| 156 | unsigned int current_id = invocation_id++; |
| 157 | |
| 158 | lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
| 159 | |
| 160 | if (log) |
| 161 | { |
| 162 | if (parent_map && parent_map->size()) |
| 163 | log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s in namespace %s", |
| 164 | current_id, |
| 165 | name.GetCString(), |
| 166 | parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str()); |
| 167 | else |
| 168 | log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s", |
| 169 | current_id, |
| 170 | name.GetCString()); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | if (parent_map) |
| 175 | { |
| 176 | for (ClangASTImporter::NamespaceMap::iterator i = parent_map->begin(), e = parent_map->end(); |
| 177 | i != e; |
| 178 | ++i) |
| 179 | { |
| 180 | ClangNamespaceDecl found_namespace_decl; |
| 181 | |
| 182 | lldb::ModuleSP module_sp = i->first; |
| 183 | ClangNamespaceDecl module_parent_namespace_decl = i->second; |
| 184 | |
| 185 | SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); |
| 186 | |
| 187 | if (!symbol_vendor) |
| 188 | continue; |
| 189 | |
| 190 | SymbolContext null_sc; |
| 191 | |
| 192 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &module_parent_namespace_decl); |
| 193 | |
| 194 | if (!found_namespace_decl) |
| 195 | continue; |
| 196 | |
| 197 | namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl)); |
| 198 | |
| 199 | if (log) |
| 200 | log->Printf(" CMN[%u] Found namespace %s in module %s", |
| 201 | current_id, |
| 202 | name.GetCString(), |
| 203 | module_sp->GetFileSpec().GetFilename().GetCString()); |
| 204 | } |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | ModuleList &images = m_target->GetImages(); |
| 209 | ClangNamespaceDecl null_namespace_decl; |
| 210 | |
| 211 | for (uint32_t i = 0, e = images.GetSize(); |
| 212 | i != e; |
| 213 | ++i) |
| 214 | { |
| 215 | lldb::ModuleSP image = images.GetModuleAtIndex(i); |
| 216 | |
| 217 | if (!image) |
| 218 | continue; |
| 219 | |
| 220 | ClangNamespaceDecl found_namespace_decl; |
| 221 | |
| 222 | SymbolVendor *symbol_vendor = image->GetSymbolVendor(); |
| 223 | |
| 224 | if (!symbol_vendor) |
| 225 | continue; |
| 226 | |
| 227 | SymbolContext null_sc; |
| 228 | |
| 229 | found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &null_namespace_decl); |
| 230 | |
| 231 | if (!found_namespace_decl) |
| 232 | continue; |
| 233 | |
| 234 | namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl)); |
| 235 | |
| 236 | if (log) |
| 237 | log->Printf(" CMN[%u] Found namespace %s in module %s", |
| 238 | current_id, |
| 239 | name.GetCString(), |
| 240 | image->GetFileSpec().GetFilename().GetCString()); |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 245 | clang::NamedDecl * |
| 246 | NameSearchContext::AddVarDecl(void *type) |
| 247 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 248 | IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo(); |
Sean Callanan | 1ddd9fe | 2010-11-30 00:27:43 +0000 | [diff] [blame] | 249 | |
| 250 | assert (type && "Type for variable must be non-NULL!"); |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 251 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 252 | clang::NamedDecl *Decl = VarDecl::Create(*m_ast_source.m_ast_context, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 253 | const_cast<DeclContext*>(m_decl_context), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 254 | SourceLocation(), |
Sean Callanan | 279584c | 2011-03-15 00:17:19 +0000 | [diff] [blame] | 255 | SourceLocation(), |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 256 | ii, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 257 | QualType::getFromOpaquePtr(type), |
| 258 | 0, |
Sean Callanan | 47a5c4c | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 259 | SC_Static, |
| 260 | SC_Static); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 261 | m_decls.push_back(Decl); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 262 | |
| 263 | return Decl; |
| 264 | } |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 265 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 266 | clang::NamedDecl * |
| 267 | NameSearchContext::AddFunDecl (void *type) |
| 268 | { |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 269 | clang::FunctionDecl *func_decl = FunctionDecl::Create (*m_ast_source.m_ast_context, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 270 | const_cast<DeclContext*>(m_decl_context), |
| 271 | SourceLocation(), |
Sean Callanan | 279584c | 2011-03-15 00:17:19 +0000 | [diff] [blame] | 272 | SourceLocation(), |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 273 | m_decl_name.getAsIdentifierInfo(), |
| 274 | QualType::getFromOpaquePtr(type), |
| 275 | NULL, |
| 276 | SC_Static, |
| 277 | SC_Static, |
| 278 | false, |
| 279 | true); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 280 | |
Sean Callanan | b291abe | 2010-08-12 23:45:38 +0000 | [diff] [blame] | 281 | // We have to do more than just synthesize the FunctionDecl. We have to |
| 282 | // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do |
| 283 | // this, we raid the function's FunctionProtoType for types. |
| 284 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 285 | QualType qual_type (QualType::getFromOpaquePtr(type)); |
| 286 | const FunctionProtoType *func_proto_type = qual_type->getAs<FunctionProtoType>(); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 287 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 288 | if (func_proto_type) |
Sean Callanan | 3c821cc | 2010-06-23 18:58:10 +0000 | [diff] [blame] | 289 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 290 | unsigned NumArgs = func_proto_type->getNumArgs(); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 291 | unsigned ArgIndex; |
| 292 | |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 293 | SmallVector<ParmVarDecl *, 5> parm_var_decls; |
| 294 | |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 295 | for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) |
| 296 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 297 | QualType arg_qual_type (func_proto_type->getArgType(ArgIndex)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 298 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 299 | 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] | 300 | const_cast<DeclContext*>(m_decl_context), |
| 301 | SourceLocation(), |
| 302 | SourceLocation(), |
| 303 | NULL, |
| 304 | arg_qual_type, |
| 305 | NULL, |
| 306 | SC_Static, |
| 307 | SC_Static, |
| 308 | NULL)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Sean Callanan | c153518 | 2011-10-07 23:18:13 +0000 | [diff] [blame] | 311 | func_decl->setParams(ArrayRef<ParmVarDecl*>(parm_var_decls)); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 312 | } |
| 313 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 314 | m_decls.push_back(func_decl); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 315 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 316 | return func_decl; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 317 | } |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 318 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 319 | clang::NamedDecl * |
| 320 | NameSearchContext::AddGenericFunDecl() |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 321 | { |
Sean Callanan | ad29309 | 2011-01-18 23:32:05 +0000 | [diff] [blame] | 322 | FunctionProtoType::ExtProtoInfo proto_info; |
| 323 | |
| 324 | proto_info.Variadic = true; |
| 325 | |
Sean Callanan | f76afff | 2011-10-28 23:38:38 +0000 | [diff] [blame] | 326 | QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType (m_ast_source.m_ast_context->UnknownAnyTy, // result |
| 327 | NULL, // argument types |
| 328 | 0, // number of arguments |
| 329 | proto_info)); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 330 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 331 | return AddFunDecl(generic_function_type.getAsOpaquePtr()); |
| 332 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 333 | |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 334 | clang::NamedDecl * |
| 335 | NameSearchContext::AddTypeDecl(void *type) |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 336 | { |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 337 | if (type) |
| 338 | { |
| 339 | QualType qual_type = QualType::getFromOpaquePtr(type); |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 340 | |
Sean Callanan | d5b3c35 | 2011-01-27 04:42:51 +0000 | [diff] [blame] | 341 | if (const TagType *tag_type = dyn_cast<clang::TagType>(qual_type)) |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 342 | { |
| 343 | TagDecl *tag_decl = tag_type->getDecl(); |
| 344 | |
| 345 | m_decls.push_back(tag_decl); |
| 346 | |
| 347 | return tag_decl; |
| 348 | } |
Sean Callanan | d5b3c35 | 2011-01-27 04:42:51 +0000 | [diff] [blame] | 349 | 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] | 350 | { |
| 351 | ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface(); |
| 352 | |
| 353 | m_decls.push_back((NamedDecl*)interface_decl); |
| 354 | |
| 355 | return (NamedDecl*)interface_decl; |
| 356 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 357 | } |
Greg Clayton | a1aaaff | 2011-01-23 00:34:52 +0000 | [diff] [blame] | 358 | return NULL; |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 359 | } |
Greg Clayton | e6d72ca | 2011-06-25 00:44:06 +0000 | [diff] [blame] | 360 | |
| 361 | void |
| 362 | NameSearchContext::AddLookupResult (clang::DeclContextLookupConstResult result) |
| 363 | { |
| 364 | for (clang::NamedDecl * const *decl_iterator = result.first; |
| 365 | decl_iterator != result.second; |
| 366 | ++decl_iterator) |
| 367 | m_decls.push_back (*decl_iterator); |
| 368 | } |
| 369 | |
| 370 | void |
| 371 | NameSearchContext::AddNamedDecl (clang::NamedDecl *decl) |
| 372 | { |
| 373 | m_decls.push_back (decl); |
| 374 | } |