Exemplo n.º 1
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());
}