[clang] [llvm] [OpenMP]Generate implicit default mapper for mapping array section. (PR #101101)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 14:50:21 PDT 2024


================
@@ -20796,6 +20796,150 @@ struct MappableVarListInfo {
 };
 } // namespace
 
+static std::pair<DeclRefExpr *, VarDecl *>
+buildImplicitMap(Sema &S, QualType BaseType, DSAStackTy *Stack,
+                 SmallVectorImpl<OMPClause *> &Maps) {
+
+  const RecordDecl *RD = BaseType->getAsRecordDecl();
+  // AST context is RD's ParentASTContext().
+  ASTContext &Ctx = RD->getParentASTContext();
+  // DeclContext is RD's DeclContext.
+  DeclContext *DCT = const_cast<DeclContext *>(RD->getDeclContext());
+  SourceRange Range = RD->getSourceRange();
+  DeclarationNameInfo ImplicitName;
+  // Dummy variable _s for Mapper.
+  ImplicitName.setName(
+      Ctx.DeclarationNames.getIdentifier(&Ctx.Idents.get("_s")));
+  DeclarationName VN = ImplicitName.getName();
+  TypeSourceInfo *TInfo =
+      Ctx.getTrivialTypeSourceInfo(BaseType, Range.getEnd());
+  VarDecl *VD =
+      VarDecl::Create(Ctx, DCT, Range.getEnd(), Range.getEnd(),
+                      VN.getAsIdentifierInfo(), BaseType, TInfo, SC_None);
----------------
alexey-bataev wrote:

```suggestion
  VarDecl *VD = buildVarDecl(S, Range.getEnd(), BaseType, "_s");
```

https://github.com/llvm/llvm-project/pull/101101


More information about the llvm-commits mailing list