]> granicus.if.org Git - clang/commitdiff
Add and use isDiscardableGVALinkage function.
authorJustin Lebar <jlebar@google.com>
Thu, 13 Oct 2016 20:52:17 +0000 (20:52 +0000)
committerJustin Lebar <jlebar@google.com>
Thu, 13 Oct 2016 20:52:17 +0000 (20:52 +0000)
Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25571

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284159 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Linkage.h
lib/AST/ASTContext.cpp
lib/Sema/SemaCUDA.cpp

index 8b15c8ed6ee858e9e363378b69237c7b2d40c54c..e96fb568c0099224625c7550dbc408d121572eab 100644 (file)
@@ -69,6 +69,10 @@ enum GVALinkage {
   GVA_StrongODR
 };
 
+inline bool isDiscardableGVALinkage(GVALinkage L) {
+  return L <= GVA_DiscardableODR;
+}
+
 inline bool isExternallyVisible(Linkage L) {
   return L == ExternalLinkage || L == VisibleNoLinkage;
 }
index b75de00d562b4ec8d5209765bb7e08936305de36..e2fe6d259185baaa149b696f4927cb34e590559d 100644 (file)
@@ -8824,15 +8824,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
       }
     }
 
-    GVALinkage Linkage = GetGVALinkageForFunction(FD);
-
     // static, static inline, always_inline, and extern inline functions can
     // always be deferred.  Normal inline functions can be deferred in C99/C++.
     // Implicit template instantiations can also be deferred in C++.
-    if (Linkage == GVA_Internal || Linkage == GVA_AvailableExternally ||
-        Linkage == GVA_DiscardableODR)
-      return false;
-    return true;
+    return !isDiscardableGVALinkage(GetGVALinkageForFunction(FD));
   }
   
   const VarDecl *VD = cast<VarDecl>(D);
@@ -8843,9 +8838,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
     return false;
 
   // Variables that can be needed in other TUs are required.
-  GVALinkage L = GetGVALinkageForVariable(VD);
-  if (L != GVA_Internal && L != GVA_AvailableExternally &&
-      L != GVA_DiscardableODR)
+  if (!isDiscardableGVALinkage(GetGVALinkageForVariable(VD)))
     return true;
 
   // Variables that have destruction with side-effects are required.
index 5333a4427526a70ca2b0a47fe9f8f1d9d1e86216..18751d41048665be9df2c071f0555ff6ec09fad8 100644 (file)
@@ -546,7 +546,7 @@ static bool IsKnownEmitted(Sema &S, FunctionDecl *FD) {
     return false;
 
   // Externally-visible and similar functions are always emitted.
-  if (S.getASTContext().GetGVALinkageForFunction(FD) > GVA_DiscardableODR)
+  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
     return true;
 
   // Otherwise, the function is known-emitted if it's in our set of