From: Rafael Espindola Date: Mon, 27 May 2013 14:14:42 +0000 (+0000) Subject: Move 3 helper function to Linkage.h X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88ce12aaf6f0a5a55a458ad152218b4072456ee6;p=clang Move 3 helper function to Linkage.h This removes a duplicate from Decl.cpp and a followup patch will use isExternallyVisible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182735 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index fbbb21c7ab..8120d7bdab 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -221,21 +221,16 @@ public: /// \brief Get the linkage from a semantic point of view. Entities in /// anonymous namespaces are external (in c++98). Linkage getFormalLinkage() const { - Linkage L = getLinkageInternal(); - if (L == UniqueExternalLinkage) - return ExternalLinkage; - if (L == VisibleNoLinkage) - return NoLinkage; - return L; + return clang::getFormalLinkage(getLinkageInternal()); } /// \brief True if this decl has external linkage. bool hasExternalFormalLinkage() const { - return getFormalLinkage() == ExternalLinkage; + return isExternalFormalLinkage(getLinkageInternal()); } + bool isExternallyVisible() const { - Linkage L = getLinkageInternal(); - return L == ExternalLinkage || L == VisibleNoLinkage; + return clang::isExternallyVisible(getLinkageInternal()); } /// \brief Determines the visibility of this entity. diff --git a/include/clang/Basic/Linkage.h b/include/clang/Basic/Linkage.h index 7f9ce6a909..699620784e 100644 --- a/include/clang/Basic/Linkage.h +++ b/include/clang/Basic/Linkage.h @@ -66,6 +66,22 @@ enum GVALinkage { GVA_ExplicitTemplateInstantiation }; +inline bool isExternallyVisible(Linkage L) { + return L == ExternalLinkage || L == VisibleNoLinkage; +} + +inline Linkage getFormalLinkage(Linkage L) { + if (L == UniqueExternalLinkage) + return ExternalLinkage; + if (L == VisibleNoLinkage) + return NoLinkage; + return L; +} + +inline bool isExternalFormalLinkage(Linkage L) { + return getFormalLinkage(L) == ExternalLinkage; +} + /// \brief Compute the minimum linkage given two linkages. /// /// The linkage can be interpreted as a pair formed by the formal linkage and diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index fd0f725137..5e0ffdacf0 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -495,10 +495,6 @@ static bool isSingleLineExternC(const Decl &D) { return false; } -static bool isExternalLinkage(Linkage L) { - return L == UniqueExternalLinkage || L == ExternalLinkage; -} - static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVComputationKind computation) { assert(D->getDeclContext()->getRedeclContext()->isFileContext() && @@ -722,7 +718,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, } else if (isa(D)) { LinkageInfo EnumLV = getLVForDecl(cast(D->getDeclContext()), computation); - if (!isExternalLinkage(EnumLV.getLinkage())) + if (!isExternalFormalLinkage(EnumLV.getLinkage())) return LinkageInfo::none(); LV.merge(EnumLV); @@ -793,7 +789,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LinkageInfo classLV = getLVForDecl(cast(D->getDeclContext()), classComputation); - if (!isExternalLinkage(classLV.getLinkage())) + if (!isExternalFormalLinkage(classLV.getLinkage())) return LinkageInfo::none(); // If the class already has unique-external linkage, we can't improve.