[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
================
@@ -8139,6 +8433,104 @@ class MappableExprsHandler {
}
}
+ /// Returns the address corresponding to \p PointerExpr.
+ static Address getAttachPtrAddr(const Expr *PointerExpr,
+ CodeGenFunction &CGF) {
+ assert(PointerExpr && "Cannot get addr from null attach-ptr expr");
+ Address AttachPtrAddr = Address::invalid();
+
+ if (auto *DRE = dyn_cast<DeclRefExpr>(PointerExpr)) {
+ // If the pointer is a variable, we can use its address directly.
+ AttachPtrAddr = CGF.EmitLValue(DRE).getAddress();
+ } else if (auto *OASE = dyn_cast<ArraySectionExpr>(PointerExpr)) {
+ AttachPtrAddr =
+ CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/true).getAddress();
+ } else if (auto *ASE = dyn_cast<ArraySubscriptExpr>(PointerExpr)) {
+ AttachPtrAddr = CGF.EmitLValue(ASE).getAddress();
+ } else if (auto *ME = dyn_cast<MemberExpr>(PointerExpr)) {
+ AttachPtrAddr = CGF.EmitMemberExpr(ME).getAddress();
+ } else if (auto *UO = dyn_cast<UnaryOperator>(PointerExpr)) {
+ if (UO->getOpcode() == UO_Deref)
----------------
alexey-bataev wrote:
Looks like this should be an assertion
https://github.com/llvm/llvm-project/pull/155625
More information about the cfe-commits
mailing list