From: Rafael Espindola Date: Wed, 27 Feb 2013 02:27:19 +0000 (+0000) Subject: Change Type::getLinkageAndVisibility to return a LinkageInfo. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18895dc4fd29f0071eeb591be820338f16407906;p=clang Change Type::getLinkageAndVisibility to return a LinkageInfo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176157 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index df285101e3..302651f998 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1775,13 +1775,17 @@ public: 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 getLinkageAndVisibility() const; + LinkageInfo getLinkageAndVisibility() const; /// \brief Note that the linkage is no longer known. void ClearLinkageCache(); diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index e4688f09a3..3553e0e2f3 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -211,11 +211,6 @@ static Optional getVisibilityOf(const NamedDecl *D, return None; } -static LinkageInfo getLVForType(QualType T) { - std::pair 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. @@ -239,7 +234,7 @@ getLVForTemplateParameterList(const TemplateParameterList *params) { // Handle the non-pack case first. if (!NTTP->isExpandedParameterPack()) { if (!NTTP->getType()->isDependentType()) { - LV.merge(getLVForType(NTTP->getType())); + LV.merge(NTTP->getType()->getLinkageAndVisibility()); } continue; } @@ -248,7 +243,7 @@ getLVForTemplateParameterList(const TemplateParameterList *params) { 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; } @@ -296,7 +291,7 @@ getLVForTemplateArgumentList(ArrayRef args) { continue; case TemplateArgument::Type: - LV.merge(getLVForType(arg.getAsType())); + LV.merge(arg.getAsType()->getLinkageAndVisibility()); continue; case TemplateArgument::Declaration: @@ -307,7 +302,7 @@ getLVForTemplateArgumentList(ArrayRef args) { continue; case TemplateArgument::NullPtr: - LV.merge(getLVForType(arg.getNullPtrType())); + LV.merge(arg.getNullPtrType()->getLinkageAndVisibility()); continue; case TemplateArgument::Template: @@ -627,7 +622,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // 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()) @@ -819,7 +814,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, } else if (const VarDecl *VD = dyn_cast(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()); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 9ca48d5355..b7376db493 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -2170,25 +2170,16 @@ Linkage Type::getLinkage() const { 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 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() {