[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 11 08:50:55 PDT 2025


================
@@ -6920,6 +7202,22 @@ class MappableExprsHandler {
   /// Map between lambda declarations and their map type.
   llvm::DenseMap<const ValueDecl *, const OMPMapClause *> LambdasMap;
 
+  /// Map from component lists to their attach pointer expressions.
+  mutable llvm::DenseMap<
+      OMPClauseMappableExprCommon::MappableExprComponentListRef, const Expr *>
+      AttachPtrExprMap;
+
+  /// Map from attach pointer expressions to their component depth.
+  /// nullptr key has std::nullopt depth. This can be used to order attach-ptr
+  /// expressions with increasing/decreasing depth.
+  /// The component-depth of `nullptr` (i.e. no attach-ptr) is `std::nullopt`.
+  /// TODO: Not urgent, but we should ideally use the number of pointer
+  /// dereferences in an expr as an indicator of its complexity, instead of the
+  /// component-depth. That would be needed for us to treat `p[10]`,
+  /// `*(p + 10)`, `*(p + 5 + 5)` together.
+  mutable llvm::DenseMap<const Expr *, std::optional<size_t>>
+      AttachPtrComponentDepthMap = {{nullptr, std::nullopt}};
----------------
alexey-bataev wrote:

Why do they need to be mutable?

https://github.com/llvm/llvm-project/pull/155625


More information about the cfe-commits mailing list