}
bool lookup_function_decl (HirId id, tree *fn, DefId dId = UNKNOWN_DEFID,
- const TyTy::BaseType *ref = nullptr)
+ const TyTy::BaseType *ref = nullptr,
+ const std::string &asm_name = std::string ())
{
// for for any monomorphized fns
if (ref != nullptr)
{
const TyTy::BaseType *r = e.first;
tree f = e.second;
+
if (ref->is_equal (*r))
{
*fn = f;
return true;
}
+
+ if (DECL_ASSEMBLER_NAME_SET_P (f) && !asm_name.empty ())
+ {
+ tree raw = DECL_ASSEMBLER_NAME_RAW (f);
+ const char *rptr = IDENTIFIER_POINTER (raw);
+
+ bool lengths_match_p
+ = IDENTIFIER_LENGTH (raw) == asm_name.size ();
+ if (lengths_match_p
+ && strncmp (rptr, asm_name.c_str (),
+ IDENTIFIER_LENGTH (raw))
+ == 0)
+ {
+ *fn = f;
+ return true;
+ }
+ }
}
return false;
}
}
}
+ const Resolver::CanonicalPath *canonical_path = nullptr;
+ bool ok = ctx->get_mappings ()->lookup_canonical_path (
+ function.get_mappings ().get_nodeid (), &canonical_path);
+ rust_assert (ok);
+
+ const std::string asm_name = ctx->mangle_item (fntype, *canonical_path);
+
// items can be forward compiled which means we may not need to invoke this
// code. We might also have already compiled this generic function as well.
tree lookup = NULL_TREE;
if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup,
- fntype->get_id (), fntype))
+ fntype->get_id (), fntype, asm_name))
{
// has this been added to the list then it must be finished
if (ctx->function_completed (lookup))
fntype->override_context ();
}
- const Resolver::CanonicalPath *canonical_path = nullptr;
- bool ok = ctx->get_mappings ()->lookup_canonical_path (
- function.get_mappings ().get_nodeid (), &canonical_path);
- rust_assert (ok);
-
if (function.get_qualifiers ().is_const ())
ctx->push_const_context ();