[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 05:08:40 PDT 2023


ABataev added a comment.

Did you try instead fix the OMPDeclareTargetDeclAttr::getActiveAttr() function to make it look through all the declarations and return the attribute from the first found instead of adding a new attribute?



================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:22993-22999
+  if (auto *CD = dyn_cast<NamedDecl>(ND->getCanonicalDecl())) {
+    if (!CD->hasAttr<OMPDeclareTargetDeclAttr>()) {
+      CD->addAttr(A);
+      if (ASTMutationListener *ML = Context.getASTMutationListener())
+        ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+    }
+  }
----------------
Here it would be better to reconstruct the attribute and make it implicit attribute.


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:23105-23112
+        // If this was not a canonical definition we need to update it as well.
+        if (auto *CD = dyn_cast<NamedDecl>(D->getCanonicalDecl())) {
+          if (!CD->hasAttr<OMPDeclareTargetDeclAttr>()) {
+            CD->addAttr(A);
+            if (ASTMutationListener *ML = Context.getASTMutationListener())
+              ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+          }
----------------
Here it would be better to reconstruct the attribute and make it implicit attribute


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153369/new/

https://reviews.llvm.org/D153369



More information about the cfe-commits mailing list