diff options
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5f94cf2cec6..91e9f3ed873 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -9774,6 +9774,12 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { const auto *VD = cast<VarDecl>(D); assert(VD->isFileVarDecl() && "Expected file scoped var"); + // If the decl is marked as `declare target to`, it should be emitted for the + // host and for the device. + if (LangOpts.OpenMP && + OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD)) + return true; + if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly && !isMSStaticDataMemberInlineDefinition(VD)) return false; @@ -9805,11 +9811,6 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (DeclMustBeEmitted(BindingVD)) return true; - // If the decl is marked as `declare target`, it should be emitted. - if (const llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = - OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD)) - return *Res != OMPDeclareTargetDeclAttr::MT_Link; - return false; } |