SILModule::isVisibleExternally utility for VarDecls. (#16834)

* SILModule::isVisibleExternally utility for VarDecls.

* Fix the SIL parser so it doesn't drop global variable decls.

This information was getting lost in SIL printing/parsing.
Some passes rely on it. Regardless of whether passes should rely on it,
it is totally unacceptable for the SIL passes to have subtle differences
in behavior depending on the frontend mode. So, if we don't want passes
to rely on global variable decls, that needs to be enforced by the API
independent of how the frontend is invoked or how SIL is serialized.

* Use custom DemangleOptions to lookup global variable identifiers.
This commit is contained in:
Andrew Trick
2018-06-26 12:27:26 -07:00
committed by GitHub
parent 21cf9b33c8
commit 7c4d15f96a
9 changed files with 162 additions and 57 deletions

View File

@@ -855,3 +855,22 @@ SILProperty *SILProperty::create(SILModule &M,
return prop;
}
// Definition from SILLinkage.h.
SILLinkage swift::getDeclSILLinkage(const ValueDecl *decl) {
AccessLevel access = decl->getEffectiveAccess();
SILLinkage linkage;
switch (access) {
case AccessLevel::Private:
case AccessLevel::FilePrivate:
linkage = SILLinkage::Private;
break;
case AccessLevel::Internal:
linkage = SILLinkage::Hidden;
break;
case AccessLevel::Public:
case AccessLevel::Open:
linkage = SILLinkage::Public;
break;
}
return linkage;
}