[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions
Alexey Bataev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 28 07:29:44 PDT 2023
ABataev added inline comments.
================
Comment at: clang/lib/Parse/ParseDecl.cpp:2093-2115
+void ParseImplicitDeclareTargetAttr(Decl *TargetDecl) {
+ if (TargetDecl && TargetDecl->hasAttr<OMPDeclareTargetDeclAttr>() &&
+ isa<VarDecl>(TargetDecl)) {
+ VarDecl *TargetVarDecl = cast<VarDecl>(TargetDecl);
+ Expr *Ex = TargetVarDecl->getInit()->IgnoreCasts();
+ const DeclRefExpr *DeclRef = nullptr;
+ if (Ex && isa<UnaryOperator>(Ex) && TargetVarDecl->hasGlobalStorage()) {
----------------
RitanyaB wrote:
> ABataev wrote:
> > RitanyaB wrote:
> > > ABataev wrote:
> > > > RitanyaB wrote:
> > > > > ABataev wrote:
> > > > > > It has nothing to do with parsing, sema analysis. Make it part of Sema::checkDeclIsAllowedInOpenMPTarget
> > > > > The Declaration in Sema::checkDeclIsAllowedInOpenMPTarget is incomplete.
> > > > >
> > > > > ```
> > > > > VarDecl 0x1582b278 <test3.c:6:1, col:7> col:7 ptr1 'int **'
> > > > > `-OMPDeclareTargetDeclAttr 0x1582b2e0 <line:5:21> Implicit MT_To DT_Any 1
> > > > > `-<<<NULL>>>
> > > > >
> > > > > ```
> > > > > At this point, I do not have access to the initializer expression. Any suggestions?
> > > > The try to do it ActOnOpenMPDeclareTargetName
> > > In the absence of a declare target clause, this function is not invoked (in the examples used above, the function is never called). Do you have any suggestions?
> > For such decls use checkDeclIsAllowedInOpenMPTarget
> As mentioned in my previous comment, the Decl in checkDeclIsAllowedInOpenMPTarget is not complete and I don't have access to the initializer expression hence I am unable to move my functionality into checkDeclIsAllowedInOpenMPTarget.
> After ParseDeclarationAfterDeclaratorAndAttributes returns, the Decl is complete and I can process it accordingly.
For decls, explicitly marked as DeclareTarget, use The try to do it ActOnOpenMPDeclareTargetName. For decls, referenced in the initializers, use checkDeclIsAllowedInOpenMPTarget.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146418/new/
https://reviews.llvm.org/D146418
More information about the cfe-commits
mailing list