]> granicus.if.org Git - clang/commitdiff
Add a hasExternalLinkage helper. No functionality change.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 7 Mar 2013 02:00:27 +0000 (02:00 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 7 Mar 2013 02:00:27 +0000 (02:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176607 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/ARCMigrate/TransUnbridgedCasts.cpp
lib/ARCMigrate/Transforms.cpp
lib/Sema/Sema.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp

index 68d7d565853def94b0efb5b50dc518aac7b00fdd..d969acd8072f590ac735fd3371eaf532303b5f75 100644 (file)
@@ -214,6 +214,11 @@ public:
   /// \brief Determine what kind of linkage this entity has.
   Linkage getLinkage() const;
 
+  /// \brief True if this decl has external linkage.
+  bool hasExternalLinkage() const {
+    return getLinkage() == ExternalLinkage;
+  }
+
   /// \brief Determines the visibility of this entity.
   Visibility getVisibility() const {
     return getLinkageAndVisibility().getVisibility();
index 429a705a1f0125137eb3d984caba301463e35dd4..fc4a75fdb8385127cf0e2683c43eeb2138d3fea8 100644 (file)
@@ -148,7 +148,7 @@ private:
             if (FD->getName() == "CFRetain" && 
                 FD->getNumParams() == 1 &&
                 FD->getParent()->isTranslationUnit() &&
-                FD->getLinkage() == ExternalLinkage) {
+                FD->hasExternalLinkage()) {
               Expr *Arg = callE->getArg(0);
               if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
                 const Expr *sub = ICE->getSubExpr();
@@ -413,7 +413,7 @@ private:
             FD = dyn_cast_or_null<FunctionDecl>(callE->getCalleeDecl()))
         if (FD->getName() == "CFRetain" && FD->getNumParams() == 1 &&
             FD->getParent()->isTranslationUnit() &&
-            FD->getLinkage() == ExternalLinkage)
+            FD->hasExternalLinkage())
           return true;
 
     return false;
index 136f618787f73dd416849b8864ab568e644e3ce9..087219535a18a2032a83591c5fbe35d50606bc30 100644 (file)
@@ -94,7 +94,7 @@ bool trans::isPlusOne(const Expr *E) {
       if (FD->isGlobal() &&
           FD->getIdentifier() &&
           FD->getParent()->isTranslationUnit() &&
-          FD->getLinkage() == ExternalLinkage &&
+          FD->hasExternalLinkage() &&
           ento::cocoa::isRefType(callE->getType(), "CF",
                                  FD->getIdentifier()->getName())) {
         StringRef fname = FD->getIdentifier()->getName();
@@ -198,7 +198,7 @@ bool trans::isGlobalVar(Expr *E) {
   E = E->IgnoreParenCasts();
   if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
     return DRE->getDecl()->getDeclContext()->isFileContext() &&
-           DRE->getDecl()->getLinkage() == ExternalLinkage;
+           DRE->getDecl()->hasExternalLinkage();
   if (ConditionalOperator *condOp = dyn_cast<ConditionalOperator>(E))
     return isGlobalVar(condOp->getTrueExpr()) &&
            isGlobalVar(condOp->getFalseExpr());
index 8c79d822cf2a710427a99c52a6ec5a5a0f5e0422..6239172a096a2152a3c241d6135b53e3eb490c22 100644 (file)
@@ -360,7 +360,7 @@ static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
       return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
   }
 
-  if (D->getLinkage() == ExternalLinkage)
+  if (D->hasExternalLinkage())
     return true;
 
   return false;
@@ -402,13 +402,13 @@ void Sema::getUndefinedButUsed(
     if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
       if (FD->isDefined())
         continue;
-      if (FD->getLinkage() == ExternalLinkage &&
+      if (FD->hasExternalLinkage() &&
           !FD->getMostRecentDecl()->isInlined())
         continue;
     } else {
       if (cast<VarDecl>(ND)->hasDefinition() != VarDecl::DeclarationOnly)
         continue;
-      if (ND->getLinkage() == ExternalLinkage)
+      if (ND->hasExternalLinkage())
         continue;
     }
 
index 78f1784ad12c2a1661da797730402084f7ce7596..82d216ee01cc63152db0f22d7b7a53682bbe1b76 100644 (file)
@@ -1223,7 +1223,7 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const {
   }
 
   // Only warn for unused decls internal to the translation unit.
-  if (D->getLinkage() == ExternalLinkage)
+  if (D->hasExternalLinkage())
     return false;
 
   return true;
@@ -1584,7 +1584,7 @@ static void filterNonConflictingPreviousDecls(ASTContext &context,
     return;
 
   // If this declaration has external
-  bool hasExternalLinkage = (decl->getLinkage() == ExternalLinkage);
+  bool hasExternalLinkage = decl->hasExternalLinkage();
 
   LookupResult::Filter filter = previous.makeFilter();
   while (filter.hasNext()) {
@@ -4577,7 +4577,7 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
     }
   }
   if (WeakRefAttr *Attr = ND.getAttr<WeakRefAttr>()) {
-    if (ND.getLinkage() == ExternalLinkage) {
+    if (ND.hasExternalLinkage()) {
       S.Diag(Attr->getLocation(), diag::err_attribute_weakref_not_static);
       ND.dropAttr<WeakRefAttr>();
     }
@@ -6388,7 +6388,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
 
   // If there's a #pragma GCC visibility in scope, and this isn't a class
   // member, set the visibility of this function.
-  if (NewFD->getLinkage() == ExternalLinkage && !DC->isRecord())
+  if (NewFD->hasExternalLinkage() && !DC->isRecord())
     AddPushedVisibilityAttribute(NewFD);
 
   // If there's a #pragma clang arc_cf_code_audited in scope, consider
@@ -7782,7 +7782,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
   }
 
   if (var->isThisDeclarationADefinition() &&
-      var->getLinkage() == ExternalLinkage &&
+      var->hasExternalLinkage() &&
       getDiagnostics().getDiagnosticLevel(
                        diag::warn_missing_variable_declarations,
                        var->getLocation())) {
@@ -7880,7 +7880,7 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) {
   const DeclContext *DC = VD->getDeclContext();
   // If there's a #pragma GCC visibility in scope, and this isn't a class
   // member, set the visibility of this variable.
-  if (VD->getLinkage() == ExternalLinkage && !DC->isRecord())
+  if (VD->hasExternalLinkage() && !DC->isRecord())
     AddPushedVisibilityAttribute(VD);
 
   if (VD->isFileVarDecl())
index 46010e4bdb78e9af3f92a60be5a032c977682d86..22a31e0af54bfb542fcfd1f19d64c075989f5b9a 100644 (file)
@@ -11364,7 +11364,7 @@ bool Sema::DefineUsedVTables() {
     Consumer.HandleVTable(Class, VTablesUsed[Canonical]);
 
     // Optionally warn if we're emitting a weak vtable.
-    if (Class->getLinkage() == ExternalLinkage &&
+    if (Class->hasExternalLinkage() &&
         Class->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
       const FunctionDecl *KeyFunctionDef = 0;
       if (!KeyFunction ||