[OPENMP]Improve detection of omp_allocator_handle_t type and predefined
allocators.
It is better to deduce omp_allocator_handle_t type from the predefined
allocators, because omp.h header might not define it explicitly. Plus,
it allows to identify the predefined allocators correctly when trying to
build the allcoator for the global variables.
llvm-svn: 356607
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index f37372f..32bd82d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4490,10 +4490,15 @@
ReadSourceRange()));
break;
- case UPD_DECL_MARKED_OPENMP_ALLOCATE:
+ case UPD_DECL_MARKED_OPENMP_ALLOCATE: {
+ auto AllocatorKind =
+ static_cast<OMPAllocateDeclAttr::AllocatorTypeTy>(Record.readInt());
+ Expr *Allocator = Record.readExpr();
+ SourceRange SR = ReadSourceRange();
D->addAttr(OMPAllocateDeclAttr::CreateImplicit(
- Reader.getContext(), Record.readExpr(), ReadSourceRange()));
+ Reader.getContext(), AllocatorKind, Allocator, SR));
break;
+ }
case UPD_DECL_EXPORTED: {
unsigned SubmoduleID = readSubmoduleID();
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 0395605..c593dd9 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5290,10 +5290,13 @@
D->getAttr<OMPThreadPrivateDeclAttr>()->getRange());
break;
- case UPD_DECL_MARKED_OPENMP_ALLOCATE:
- Record.AddStmt(D->getAttr<OMPAllocateDeclAttr>()->getAllocator());
- Record.AddSourceRange(D->getAttr<OMPAllocateDeclAttr>()->getRange());
+ case UPD_DECL_MARKED_OPENMP_ALLOCATE: {
+ auto *A = D->getAttr<OMPAllocateDeclAttr>();
+ Record.push_back(A->getAllocatorType());
+ Record.AddStmt(A->getAllocator());
+ Record.AddSourceRange(A->getRange());
break;
+ }
case UPD_DECL_MARKED_OPENMP_DECLARETARGET:
Record.push_back(D->getAttr<OMPDeclareTargetDeclAttr>()->getMapType());