[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 May 9 09:35:35 PDT 2023
ABataev added inline comments.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:14473
+ // directive and has static storage duration.
+ if (auto *VD = dyn_cast_or_null<VarDecl>(D);
+ LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
----------------
В is already checked that is not nullptr, so just a dyn_cast should be enough
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:23094-23095
+public:
+ SmallVector<Decl *> DeclVector;
+ Decl *TargetDecl;
+ void VisitDeclRefExpr(const DeclRefExpr *Node) {
----------------
Why public?
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:23098
+ Decl *DeclVar = nullptr;
+ if (const VarDecl *VD = dyn_cast<VarDecl>(Node->getDecl())) {
+ DeclVar = (Decl *)Node->getDecl();
----------------
const auto *VD
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:23099
+ if (const VarDecl *VD = dyn_cast<VarDecl>(Node->getDecl())) {
+ DeclVar = (Decl *)Node->getDecl();
+ DeclVar->addAttr((this->TargetDecl)->getAttr<OMPDeclareTargetDeclAttr>());
----------------
Use VD instead of this and drop const
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:23100-23101
+ DeclVar = (Decl *)Node->getDecl();
+ DeclVar->addAttr((this->TargetDecl)->getAttr<OMPDeclareTargetDeclAttr>());
+ (this->DeclVector).push_back(DeclVar);
+ }
----------------
Drop this and extra parens
================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:23107-23110
+ if (isa<Expr>(*it))
+ VisitExpr(dyn_cast<Expr>(*it));
+ if (isa<DeclRefExpr>(*it))
+ Visit(*it);
----------------
Just Visit(*it)?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146418/new/
https://reviews.llvm.org/D146418
More information about the cfe-commits
mailing list