Esempio n. 1
0
/// Process Decl, recursively deserializing any thing Decl may reference.
bool SILLinkerVisitor::processDeclRef(SILDeclRef Decl) {
  if (Mode == LinkingMode::LinkNone)
    return false;

  // If F is a declaration, first deserialize it.
  auto *NewFn =
      isAvailableExternally(Decl.getLinkage(ForDefinition_t::NotForDefinition))
          ? Loader->lookupSILFunction(Decl)
          : nullptr;
  if (!NewFn || NewFn->isExternalDeclaration())
    return false;

  if (!shouldImportFunction(NewFn)) {
    return false;
  }

  ++NumFuncLinked;

  // Try to transitively deserialize everything referenced by NewFn.
  Worklist.push_back(NewFn);
  process();

  // Since we successfully processed at least one function, return true.
  return true;
}
Esempio n. 2
0
void TBDGenVisitor::addSymbol(SILDeclRef declRef, bool checkSILOnly) {
  bool isPrivate = !hasPublicVisibility(declRef.getLinkage(ForDefinition));
  // Even private methods of open classes (specifically, private methods that
  // are in the vtable) have public symbols, because external subclasses
  // currently need to refer to them by symbol for their own vtable.
  switch (declRef.getSubclassScope()) {
  case SubclassScope::External:
    // Allocating constructors retain their normal linkage behavior.
    if (declRef.kind == SILDeclRef::Kind::Allocator)
      break;

    // Unlike the "truly" public things, private things have public symbols
    // unconditionally, even if they're theoretically SIL only.
    if (isPrivate) {
      isPrivate = false;
      checkSILOnly = false;
    }
    break;
  case SubclassScope::Internal:
  case SubclassScope::NotApplicable:
    break;
  }
  if (isPrivate)
    return;

  // (Most) transparent things don't exist, even if they're public.
  // FIXME: isTransparent should really be "is SIL only".
  if (checkSILOnly && declRef.isTransparent())
    return;

  addSymbol(declRef.mangle());
}
Esempio n. 3
0
void TBDGenVisitor::addSymbol(SILDeclRef declRef) {
  bool isPrivate = !hasPublicVisibility(declRef.getLinkage(ForDefinition));
  // Even private methods of open classes (specifically, private methods that
  // are in the vtable) have public symbols, because external subclasses
  // currently need to refer to them by symbol for their own vtable.
  switch (declRef.getSubclassScope()) {
  case SubclassScope::External:
    // Unlike the "truly" public things, private things have public symbols
    // unconditionally, even if they're theoretically SIL only.
    if (isPrivate) {
      isPrivate = false;
    }
    break;
  case SubclassScope::Internal:
  case SubclassScope::NotApplicable:
    break;
  }
  if (isPrivate)
    return;

  // FIXME: this includes too many symbols. There are some that are considered
  // SIL-only, but it isn't obvious how to determine this (e.g. it seems that
  // many, but not all, transparent functions result in object-file symbols)

  addSymbol(declRef.mangle());
}
Esempio n. 4
0
void TBDGenVisitor::addSymbol(SILDeclRef declRef) {
  auto linkage = effectiveLinkageForClassMember(
    declRef.getLinkage(ForDefinition),
    declRef.getSubclassScope());
  if (linkage == SILLinkage::Public)
    addSymbol(declRef.mangle());
}