diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2018-08-15 19:45:12 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-08-15 19:45:12 +0000 |
| commit | d01b74974ba2e87cfc1f05a08ccad54feb9ceb49 (patch) | |
| tree | 1c8fee61f2d911f49c7aee8b7d60881a88cebaa9 /clang/lib/AST | |
| parent | dfb4f61d971a52c0c859b6483a16199aa4d2103b (diff) | |
| download | bcm5719-llvm-d01b74974ba2e87cfc1f05a08ccad54feb9ceb49.tar.gz bcm5719-llvm-d01b74974ba2e87cfc1f05a08ccad54feb9ceb49.zip | |
[OPENMP] FIx processing of declare target variables.
The compiler may produce unexpected error messages/crashes when declare
target variables were used. Patch fixes problems with the declarations
marked as declare target to or link.
llvm-svn: 339805
Diffstat (limited to 'clang/lib/AST')
| -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; } |

