[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:49 PDT 2025
================
@@ -6771,6 +6771,240 @@ LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
// code for that information.
class MappableExprsHandler {
public:
+ /// Custom comparator for attach-pointer expressions that compares them by
+ /// complexity (i.e. their component-depth) first, then by the order in which
+ /// they were computed by collectAttachPtrExprInfo(), if they are semantically
+ /// different.
+ struct AttachPtrExprComparator {
+ const MappableExprsHandler *Handler;
+ // Cache of previous equality comparison results.
+ mutable llvm::DenseMap<std::pair<const Expr *, const Expr *>, bool>
+ CachedEqualityComparisons;
+
+ AttachPtrExprComparator(const MappableExprsHandler *H) : Handler(H) {}
+
+ // Return true iff LHS is "less than" RHS.
+ bool operator()(const Expr *LHS, const Expr *RHS) const {
+ if (LHS == RHS)
+ return false;
+
+ // First, compare by complexity (depth)
+ auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
+ auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
----------------
alexey-bataev wrote:
```suggestion
const auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
const auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
```
https://github.com/llvm/llvm-project/pull/155625
More information about the cfe-commits
mailing list