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/Serialization | |
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/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 2b8cfac88d9..47484f8b38b 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2708,7 +2708,8 @@ static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) { return !D->getDeclContext()->isFunctionOrMethod(); if (const auto *Var = dyn_cast<VarDecl>(D)) return Var->isFileVarDecl() && - Var->isThisDeclarationADefinition() == VarDecl::Definition; + (Var->isThisDeclarationADefinition() == VarDecl::Definition || + OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Var)); if (const auto *Func = dyn_cast<FunctionDecl>(D)) return Func->doesThisDeclarationHaveABody() || HasBody; @@ -4385,6 +4386,12 @@ void ASTDeclReader::UpdateDecl(Decl *D, } case UPD_DECL_MARKED_OPENMP_DECLARETARGET: + D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit( + Reader.getContext(), + static_cast<OMPDeclareTargetDeclAttr::MapTypeTy>(Record.readInt()), + ReadSourceRange())); + break; + case UPD_ADDED_ATTR_TO_RECORD: AttrVec Attrs; Record.readAttributes(Attrs); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index ea3a75da48a..99606fcca53 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -5296,6 +5296,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) { break; case UPD_DECL_MARKED_OPENMP_DECLARETARGET: + Record.push_back(D->getAttr<OMPDeclareTargetDeclAttr>()->getMapType()); Record.AddSourceRange( D->getAttr<OMPDeclareTargetDeclAttr>()->getRange()); break; diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 2d90c98faaa..8eb6c61525d 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -2237,8 +2237,7 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context, // File scoped assembly or obj-c or OMP declare target implementation must be // seen. - if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) || - D->hasAttr<OMPDeclareTargetDeclAttr>()) + if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D)) return true; if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) { |