Index: clang/include/clang/Basic/Linkage.h =================================================================== --- clang/include/clang/Basic/Linkage.h +++ clang/include/clang/Basic/Linkage.h @@ -69,6 +69,10 @@ GVA_StrongODR }; +inline bool isDiscardableGVALinkage(GVALinkage L) { + return L <= GVA_DiscardableODR; +} + inline bool isExternallyVisible(Linkage L) { return L == ExternalLinkage || L == VisibleNoLinkage; } Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -9241,7 +9241,7 @@ /// discover that a function is known-emitted, we remove it and everything it /// transitively calls from this set and add those functions to /// CUDAKnownEmittedFns. - llvm::DenseMap> CUDACallGraph; + llvm::DenseMap> CUDACallGraph; /// Diagnostic builder for CUDA errors which may or may not be deferred. /// Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -8802,15 +8802,10 @@ } } - 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(D); @@ -8821,9 +8816,7 @@ 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: clang/lib/Sema/SemaCUDA.cpp =================================================================== --- clang/lib/Sema/SemaCUDA.cpp +++ clang/lib/Sema/SemaCUDA.cpp @@ -543,7 +543,7 @@ 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