[clang] [NFC][Clang][OpenMP] Address minor review feedback from #155625. (PR #160746)
Abhinav Gaba via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 25 10:46:41 PDT 2025
https://github.com/abhinavgaba created https://github.com/llvm/llvm-project/pull/160746
None
>From c57fc392af1192c2e61c4259d3074a0fb1f5f30c Mon Sep 17 00:00:00 2001
From: Abhinav Gaba <abhinav.gaba at intel.com>
Date: Thu, 25 Sep 2025 10:38:31 -0700
Subject: [PATCH] [NFC][Clang][OpenMP] Address minor review feedback from
#155625.
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6c68311daf0ba..c90e1a487daf9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6804,7 +6804,7 @@ class MappableExprsHandler {
/// they were computed by collectAttachPtrExprInfo(), if they are semantically
/// different.
struct AttachPtrExprComparator {
- const MappableExprsHandler *Handler;
+ const MappableExprsHandler *Handler = nullptr;
// Cache of previous equality comparison results.
mutable llvm::DenseMap<std::pair<const Expr *, const Expr *>, bool>
CachedEqualityComparisons;
@@ -6817,8 +6817,8 @@ class MappableExprsHandler {
return false;
// First, compare by complexity (depth)
- auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
- auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
+ const auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
+ const auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
std::optional<size_t> DepthLHS =
(ItLHS != Handler->AttachPtrComponentDepthMap.end()) ? ItLHS->second
@@ -6856,7 +6856,7 @@ class MappableExprsHandler {
/// results, if available, otherwise does a recursive semantic comparison.
bool areEqual(const Expr *LHS, const Expr *RHS) const {
// Check cache first for faster lookup
- auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
+ const auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
if (CachedResultIt != CachedEqualityComparisons.end())
return CachedResultIt->second;
@@ -7142,7 +7142,7 @@ class MappableExprsHandler {
const Expr *getAttachPtrExpr(
OMPClauseMappableExprCommon::MappableExprComponentListRef Components)
const {
- auto It = AttachPtrExprMap.find(Components);
+ const auto It = AttachPtrExprMap.find(Components);
if (It != AttachPtrExprMap.end())
return It->second;
@@ -8478,8 +8478,9 @@ class MappableExprsHandler {
} 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)
- AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
+ assert(UO->getOpcode() == UO_Deref &&
+ "Unexpected unary-operator on attach-ptr-expr");
+ AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
}
assert(AttachPtrAddr.isValid() &&
"Failed to get address for attach pointer expression");
@@ -8524,12 +8525,10 @@ class MappableExprsHandler {
// Pointer attachment is needed at map-entering time or for declare
// mappers.
- if (!isa<const OMPDeclareMapperDecl *>(CurDir) &&
- !isOpenMPTargetMapEnteringDirective(
- cast<const OMPExecutableDirective *>(CurDir)->getDirectiveKind()))
- return false;
-
- return true;
+ return isa<const OMPDeclareMapperDecl *>(CurDir) ||
+ isOpenMPTargetMapEnteringDirective(
+ cast<const OMPExecutableDirective *>(CurDir)
+ ->getDirectiveKind());
}
/// Computes the attach-ptr expr for \p Components, and updates various maps
More information about the cfe-commits
mailing list