diff options
author | Justin Lebar <jlebar@google.com> | 2016-10-13 20:52:17 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-10-13 20:52:17 +0000 |
commit | 606f01f3092da36b761f9df694e8c8eab9dde603 (patch) | |
tree | 4c42d62bbfa0e69c4ab99519260fe7a1732c24d5 | |
parent | 23d954241b42e9c7d7d515a7dee308a720006c3e (diff) | |
download | bcm5719-llvm-606f01f3092da36b761f9df694e8c8eab9dde603.tar.gz bcm5719-llvm-606f01f3092da36b761f9df694e8c8eab9dde603.zip |
Add and use isDiscardableGVALinkage function.
Reviewers: rnk
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25571
llvm-svn: 284159
-rw-r--r-- | clang/include/clang/Basic/Linkage.h | 4 | ||||
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCUDA.cpp | 2 |
3 files changed, 7 insertions, 10 deletions
diff --git a/clang/include/clang/Basic/Linkage.h b/clang/include/clang/Basic/Linkage.h index 8b15c8ed6ee..e96fb568c00 100644 --- a/clang/include/clang/Basic/Linkage.h +++ b/clang/include/clang/Basic/Linkage.h @@ -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; } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b75de00d562..e2fe6d25918 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -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. diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index 5333a442752..18751d41048 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -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 |