r182735 - Move 3 helper function to Linkage.h

Rafael Espindola rafael.espindola at gmail.com
Mon May 27 07:14:43 PDT 2013


Author: rafael
Date: Mon May 27 09:14:42 2013
New Revision: 182735

URL: http://llvm.org/viewvc/llvm-project?rev=182735&view=rev
Log:
Move 3 helper function to Linkage.h

This removes a duplicate from Decl.cpp and a followup patch will use
isExternallyVisible.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/Basic/Linkage.h
    cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=182735&r1=182734&r2=182735&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon May 27 09:14:42 2013
@@ -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.

Modified: cfe/trunk/include/clang/Basic/Linkage.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Linkage.h?rev=182735&r1=182734&r2=182735&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Linkage.h (original)
+++ cfe/trunk/include/clang/Basic/Linkage.h Mon May 27 09:14:42 2013
@@ -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

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=182735&r1=182734&r2=182735&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon May 27 09:14:42 2013
@@ -495,10 +495,6 @@ static bool isSingleLineExternC(const De
   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 getLVForNamespaceScop
   } 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(c
 
   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.





More information about the cfe-commits mailing list