]> granicus.if.org Git - clang/commitdiff
Move 3 helper function to Linkage.h
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 May 2013 14:14:42 +0000 (14:14 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 May 2013 14:14:42 +0000 (14:14 +0000)
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

include/clang/AST/Decl.h
include/clang/Basic/Linkage.h
lib/AST/Decl.cpp

index fbbb21c7ab41ccfa0c1072a9c75a23d3359341ce..8120d7bdabe56e95bc96a1e0dc8383f55d5677c7 100644 (file)
@@ -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.
index 7f9ce6a9092a8677a5ec58576563ed70f1345c44..699620784ecdcc1210192fdae7741079a54b44b2 100644 (file)
@@ -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
index fd0f72513767088cd9c3ee7502648a701dc57758..5e0ffdacf091ffbb29bc451d9159d3c70a6e8586 100644 (file)
@@ -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<EnumConstantDecl>(D)) {
     LinkageInfo EnumLV = getLVForDecl(cast<NamedDecl>(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<RecordDecl>(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.