uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
uint32_t max_matches,
- std::vector<CompilerDecl> &decls) {
+ std::vector<clang::NamedDecl *> &decls) {
if (!append)
decls.clear();
- std::vector<clang::NamedDecl *> named_decls;
- uint32_t ret = FindDecls(name, /*append*/ false, max_matches, named_decls);
- for (auto *named_decl : named_decls) {
- decls.push_back(CompilerDecl(
- ClangASTContext::GetASTContext(&named_decl->getASTContext()),
- named_decl));
+ std::vector<CompilerDecl> compiler_decls;
+ uint32_t ret = FindDecls(name, /*append*/ false, max_matches, compiler_decls);
+ for (CompilerDecl compiler_decl : compiler_decls) {
+ clang::Decl *d =
+ reinterpret_cast<clang::Decl *>(compiler_decl.GetOpaqueDecl());
+ clang::NamedDecl *nd = llvm::cast<clang::NamedDecl>(d);
+ decls.push_back(nd);
}
return ret;
}
virtual ~ClangDeclVendor() {}
- uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
- std::vector<CompilerDecl> &decls) override;
+ using DeclVendor::FindDecls;
- virtual uint32_t FindDecls(ConstString name, bool append,
- uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls) = 0;
+ uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
+ std::vector<clang::NamedDecl *> &decls);
static bool classof(const DeclVendor *vendor) {
return vendor->GetKind() >= eClangDeclVendor &&
Stream &error_stream) override;
uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls) override;
+ std::vector<CompilerDecl> &decls) override;
void ForEachMacro(const ModuleVector &modules,
std::function<bool(const std::string &)> handler) override;
uint32_t
ClangModulesDeclVendorImpl::FindDecls(ConstString name, bool append,
uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls) {
+ std::vector<CompilerDecl> &decls) {
if (!m_enabled) {
return 0;
}
if (num_matches >= max_matches)
return num_matches;
- decls.push_back(named_decl);
+ decls.push_back(CompilerDecl(m_ast_context.get(), named_decl));
++num_matches;
}
return true;
}
-uint32_t
-AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
- uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls) {
+uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
+ uint32_t max_matches,
+ std::vector<CompilerDecl> &decls) {
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
current_id, result_iface_type.getAsString(), isa_value);
}
- decls.push_back(result_iface_decl);
+ decls.push_back(CompilerDecl(&m_ast_ctx, result_iface_decl));
ret++;
break;
} else {
new_iface_type.getAsString(), (uint64_t)isa);
}
- decls.push_back(iface_decl);
+ decls.push_back(CompilerDecl(&m_ast_ctx, iface_decl));
ret++;
break;
} while (false);
}
uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls) override;
+ std::vector<CompilerDecl> &decls) override;
friend class AppleObjCExternalASTSource;