[Openmp-commits] [PATCH] D100621: [OpenMP] Ensure the DefaultMapperId has a location

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 15 23:12:29 PDT 2021


jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, ABataev, grokos.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

A user reported an assertion (below) but without a reproducer. I failed to
create a test myself but from the assertion one can derive the problem.
I set the DefaultMapperId location now to make sure this doesn't cause
trouble.

  clang-13: .../DeclTemplate.h:1940:
  void clang::ClassTemplateSpecializationDecl::setPointOfInstantiation(clang::SourceLocation):
  Assertion `Loc.isValid() && "point of instantiation must be valid!"' failed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100621

Files:
  clang/lib/Sema/SemaOpenMP.cpp


Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -5557,9 +5557,6 @@
   if (S.getLangOpts().OpenMP < 50)
     return;
   SmallVector<OMPClause *, 4> ImplicitMaps;
-  DeclarationNameInfo DefaultMapperId;
-  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
-      &S.Context.Idents.get("default")));
   for (int Cnt = 0, EndCnt = Clauses.size(); Cnt < EndCnt; ++Cnt) {
     auto *C = dyn_cast<OMPMapClause>(Clauses[Cnt]);
     if (!C)
@@ -5615,6 +5612,10 @@
         if (It == Visited.end()) {
           // Try to find the associated user-defined mapper.
           CXXScopeSpec MapperIdScopeSpec;
+          DeclarationNameInfo DefaultMapperId;
+          DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
+                                  &S.Context.Idents.get("default")));
+          DefaultMapperId.setLoc(E->getExprLoc());
           ExprResult ER = buildUserDefinedMapperRef(
               S, Stack->getCurScope(), MapperIdScopeSpec, DefaultMapperId,
               BaseType, /*UnresolvedMapper=*/nullptr);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100621.337997.patch
Type: text/x-patch
Size: 1174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210416/9e8bac10/attachment.bin>


More information about the Openmp-commits mailing list