Linkage getLinkage() const;
/// \brief Determine the visibility of this type.
- Visibility getVisibility() const;
+ Visibility getVisibility() const {
+ return getLinkageAndVisibility().visibility();
+ }
/// \brief Return true if the visibility was explicitly set is the code.
- bool isVisibilityExplicit() const;
+ bool isVisibilityExplicit() const {
+ return getLinkageAndVisibility().visibilityExplicit();
+ }
/// \brief Determine the linkage and visibility of this type.
- std::pair<Linkage,Visibility> getLinkageAndVisibility() const;
+ LinkageInfo getLinkageAndVisibility() const;
/// \brief Note that the linkage is no longer known.
void ClearLinkageCache();
return None;
}
-static LinkageInfo getLVForType(QualType T) {
- std::pair<Linkage,Visibility> P = T->getLinkageAndVisibility();
- return LinkageInfo(P.first, P.second, T->isVisibilityExplicit());
-}
-
/// \brief Get the most restrictive linkage for the types in the given
/// template parameter list. For visibility purposes, template
/// parameters are part of the signature of a template.
// Handle the non-pack case first.
if (!NTTP->isExpandedParameterPack()) {
if (!NTTP->getType()->isDependentType()) {
- LV.merge(getLVForType(NTTP->getType()));
+ LV.merge(NTTP->getType()->getLinkageAndVisibility());
}
continue;
}
for (unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
QualType type = NTTP->getExpansionType(i);
if (!type->isDependentType())
- LV.merge(getLVForType(type));
+ LV.merge(type->getLinkageAndVisibility());
}
continue;
}
continue;
case TemplateArgument::Type:
- LV.merge(getLVForType(arg.getAsType()));
+ LV.merge(arg.getAsType()->getLinkageAndVisibility());
continue;
case TemplateArgument::Declaration:
continue;
case TemplateArgument::NullPtr:
- LV.merge(getLVForType(arg.getNullPtrType()));
+ LV.merge(arg.getNullPtrType()->getLinkageAndVisibility());
continue;
case TemplateArgument::Template:
// because of this, but unique-external linkage suits us.
if (Context.getLangOpts().CPlusPlus &&
!Var->getDeclContext()->isExternCContext()) {
- LinkageInfo TypeLV = getLVForType(Var->getType());
+ LinkageInfo TypeLV = Var->getType()->getLinkageAndVisibility();
if (TypeLV.linkage() != ExternalLinkage)
return LinkageInfo::uniqueExternal();
if (!LV.visibilityExplicit())
} else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
// Modify the variable's linkage by its type, but ignore the
// type's visibility unless it's a definition.
- LinkageInfo typeLV = getLVForType(VD->getType());
+ LinkageInfo typeLV = VD->getType()->getLinkageAndVisibility();
LV.mergeMaybeWithVisibility(typeLV,
!LV.visibilityExplicit() && !classLV.visibilityExplicit());
return TypeBits.getLinkage();
}
-/// \brief Determine the linkage of this type.
-Visibility Type::getVisibility() const {
- Cache::ensure(this);
- return TypeBits.getVisibility();
-}
-
-bool Type::isVisibilityExplicit() const {
- Cache::ensure(this);
- return TypeBits.isVisibilityExplicit();
-}
-
bool Type::hasUnnamedOrLocalType() const {
Cache::ensure(this);
return TypeBits.hasLocalOrUnnamedType();
}
-std::pair<Linkage,Visibility> Type::getLinkageAndVisibility() const {
+LinkageInfo Type::getLinkageAndVisibility() const {
Cache::ensure(this);
- return std::make_pair(TypeBits.getLinkage(), TypeBits.getVisibility());
+ LinkageInfo LV(TypeBits.getLinkage(), TypeBits.getVisibility(),
+ TypeBits.isVisibilityExplicit());
+ return LV;
}
void Type::ClearLinkageCache() {