Skip to content

Commit 39ed57c

Browse files
authored
[NFC][Clang][OpenMP] Address minor review feedback from llvm#155625. (llvm#160746)
1 parent 57330c8 commit 39ed57c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6804,7 +6804,7 @@ class MappableExprsHandler {
68046804
/// they were computed by collectAttachPtrExprInfo(), if they are semantically
68056805
/// different.
68066806
struct AttachPtrExprComparator {
6807-
const MappableExprsHandler *Handler;
6807+
const MappableExprsHandler *Handler = nullptr;
68086808
// Cache of previous equality comparison results.
68096809
mutable llvm::DenseMap<std::pair<const Expr *, const Expr *>, bool>
68106810
CachedEqualityComparisons;
@@ -6817,8 +6817,8 @@ class MappableExprsHandler {
68176817
return false;
68186818

68196819
// First, compare by complexity (depth)
6820-
auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
6821-
auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
6820+
const auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
6821+
const auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
68226822

68236823
std::optional<size_t> DepthLHS =
68246824
(ItLHS != Handler->AttachPtrComponentDepthMap.end()) ? ItLHS->second
@@ -6856,7 +6856,7 @@ class MappableExprsHandler {
68566856
/// results, if available, otherwise does a recursive semantic comparison.
68576857
bool areEqual(const Expr *LHS, const Expr *RHS) const {
68586858
// Check cache first for faster lookup
6859-
auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
6859+
const auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
68606860
if (CachedResultIt != CachedEqualityComparisons.end())
68616861
return CachedResultIt->second;
68626862

@@ -7142,7 +7142,7 @@ class MappableExprsHandler {
71427142
const Expr *getAttachPtrExpr(
71437143
OMPClauseMappableExprCommon::MappableExprComponentListRef Components)
71447144
const {
7145-
auto It = AttachPtrExprMap.find(Components);
7145+
const auto It = AttachPtrExprMap.find(Components);
71467146
if (It != AttachPtrExprMap.end())
71477147
return It->second;
71487148

@@ -8478,8 +8478,9 @@ class MappableExprsHandler {
84788478
} else if (auto *ME = dyn_cast<MemberExpr>(PointerExpr)) {
84798479
AttachPtrAddr = CGF.EmitMemberExpr(ME).getAddress();
84808480
} else if (auto *UO = dyn_cast<UnaryOperator>(PointerExpr)) {
8481-
if (UO->getOpcode() == UO_Deref)
8482-
AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
8481+
assert(UO->getOpcode() == UO_Deref &&
8482+
"Unexpected unary-operator on attach-ptr-expr");
8483+
AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
84838484
}
84848485
assert(AttachPtrAddr.isValid() &&
84858486
"Failed to get address for attach pointer expression");
@@ -8524,12 +8525,10 @@ class MappableExprsHandler {
85248525

85258526
// Pointer attachment is needed at map-entering time or for declare
85268527
// mappers.
8527-
if (!isa<const OMPDeclareMapperDecl *>(CurDir) &&
8528-
!isOpenMPTargetMapEnteringDirective(
8529-
cast<const OMPExecutableDirective *>(CurDir)->getDirectiveKind()))
8530-
return false;
8531-
8532-
return true;
8528+
return isa<const OMPDeclareMapperDecl *>(CurDir) ||
8529+
isOpenMPTargetMapEnteringDirective(
8530+
cast<const OMPExecutableDirective *>(CurDir)
8531+
->getDirectiveKind());
85338532
}
85348533

85358534
/// Computes the attach-ptr expr for \p Components, and updates various maps

0 commit comments

Comments
 (0)