[clang] [NFC][Clang][OpenMP] Add helper functions/utils for finding/comparing attach base-ptrs. (PR #155625)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 25 10:19:50 PDT 2025
================
@@ -6848,6 +7082,45 @@ class MappableExprsHandler {
bool HasCompleteRecord = false;
};
+ /// A struct to store the attach pointer and pointee information, to be used
+ /// when emitting an attach entry.
+ struct AttachInfoTy {
+ Address AttachPtrAddr = Address::invalid();
+ Address AttachPteeAddr = Address::invalid();
+ const ValueDecl *AttachPtrDecl = nullptr;
+ const Expr *AttachMapExpr = nullptr;
+
+ bool isValid() const {
+ return AttachPtrAddr.isValid() && AttachPteeAddr.isValid();
+ }
+ };
+
+ /// Check if there's any component list where the attach pointer expression
+ /// matches the given captured variable.
+ bool hasAttachEntryForCapturedVar(const ValueDecl *VD) const {
+ for (const auto &AttachEntry : AttachPtrExprMap) {
+ if (AttachEntry.second) {
+ // Check if the attach pointer expression is a DeclRefExpr that
+ // references the captured variable
+ if (const auto *DRE = dyn_cast<DeclRefExpr>(AttachEntry.second))
+ if (DRE->getDecl() == VD)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /// Get the previously-cached attach pointer for a component list, if-any.
+ const Expr *getAttachPtrExpr(
+ OMPClauseMappableExprCommon::MappableExprComponentListRef Components)
+ const {
+ auto It = AttachPtrExprMap.find(Components);
----------------
alexey-bataev wrote:
```suggestion
const auto It = AttachPtrExprMap.find(Components);
```
https://github.com/llvm/llvm-project/pull/155625
More information about the cfe-commits
mailing list