Skip to content

Commit 2fffc28

Browse files
committed
Format code within namespaces to workaround clang-format limitation
1 parent e838d09 commit 2fffc28

File tree

2 files changed

+184
-183
lines changed

2 files changed

+184
-183
lines changed

llvm/lib/Analysis/CaptureTracking.cpp

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -72,126 +72,126 @@ bool CaptureTracker::isDereferenceableOrNull(Value *O, const DataLayout &DL) {
7272
}
7373

7474
namespace {
75-
struct SimpleCaptureTracker : public CaptureTracker {
76-
explicit SimpleCaptureTracker(bool ReturnCaptures)
77-
: ReturnCaptures(ReturnCaptures) {}
75+
struct SimpleCaptureTracker : public CaptureTracker {
76+
explicit SimpleCaptureTracker(bool ReturnCaptures)
77+
: ReturnCaptures(ReturnCaptures) {}
7878

79-
void tooManyUses() override {
80-
LLVM_DEBUG(dbgs() << "Captured due to too many uses\n");
81-
Captured = true;
82-
}
79+
void tooManyUses() override {
80+
LLVM_DEBUG(dbgs() << "Captured due to too many uses\n");
81+
Captured = true;
82+
}
8383

84-
bool captured(const Use *U) override {
85-
if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
86-
return false;
84+
bool captured(const Use *U) override {
85+
if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
86+
return false;
8787

88-
LLVM_DEBUG(dbgs() << "Captured by: " << *U->getUser() << "\n");
88+
LLVM_DEBUG(dbgs() << "Captured by: " << *U->getUser() << "\n");
8989

90-
Captured = true;
91-
return true;
92-
}
90+
Captured = true;
91+
return true;
92+
}
9393

94-
bool ReturnCaptures;
94+
bool ReturnCaptures;
9595

96-
bool Captured = false;
97-
};
96+
bool Captured = false;
97+
};
9898

99-
/// Only find pointer captures which happen before the given instruction. Uses
100-
/// the dominator tree to determine whether one instruction is before another.
101-
/// Only support the case where the Value is defined in the same basic block
102-
/// as the given instruction and the use.
103-
struct CapturesBefore : public CaptureTracker {
99+
/// Only find pointer captures which happen before the given instruction. Uses
100+
/// the dominator tree to determine whether one instruction is before another.
101+
/// Only support the case where the Value is defined in the same basic block
102+
/// as the given instruction and the use.
103+
struct CapturesBefore : public CaptureTracker {
104104

105-
CapturesBefore(bool ReturnCaptures, const Instruction *I,
106-
const DominatorTree *DT, bool IncludeI, const LoopInfo *LI)
107-
: BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
108-
IncludeI(IncludeI), LI(LI) {}
105+
CapturesBefore(bool ReturnCaptures, const Instruction *I,
106+
const DominatorTree *DT, bool IncludeI, const LoopInfo *LI)
107+
: BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
108+
IncludeI(IncludeI), LI(LI) {}
109109

110-
void tooManyUses() override { Captured = true; }
110+
void tooManyUses() override { Captured = true; }
111111

112-
bool isSafeToPrune(Instruction *I) {
113-
if (BeforeHere == I)
114-
return !IncludeI;
112+
bool isSafeToPrune(Instruction *I) {
113+
if (BeforeHere == I)
114+
return !IncludeI;
115115

116-
// We explore this usage only if the usage can reach "BeforeHere".
117-
// If use is not reachable from entry, there is no need to explore.
118-
if (!DT->isReachableFromEntry(I->getParent()))
119-
return true;
116+
// We explore this usage only if the usage can reach "BeforeHere".
117+
// If use is not reachable from entry, there is no need to explore.
118+
if (!DT->isReachableFromEntry(I->getParent()))
119+
return true;
120120

121-
// Check whether there is a path from I to BeforeHere.
122-
return !isPotentiallyReachable(I, BeforeHere, nullptr, DT, LI);
123-
}
121+
// Check whether there is a path from I to BeforeHere.
122+
return !isPotentiallyReachable(I, BeforeHere, nullptr, DT, LI);
123+
}
124124

125-
bool captured(const Use *U) override {
126-
Instruction *I = cast<Instruction>(U->getUser());
127-
if (isa<ReturnInst>(I) && !ReturnCaptures)
128-
return false;
125+
bool captured(const Use *U) override {
126+
Instruction *I = cast<Instruction>(U->getUser());
127+
if (isa<ReturnInst>(I) && !ReturnCaptures)
128+
return false;
129129

130-
// Check isSafeToPrune() here rather than in shouldExplore() to avoid
131-
// an expensive reachability query for every instruction we look at.
132-
// Instead we only do one for actual capturing candidates.
133-
if (isSafeToPrune(I))
134-
return false;
130+
// Check isSafeToPrune() here rather than in shouldExplore() to avoid
131+
// an expensive reachability query for every instruction we look at.
132+
// Instead we only do one for actual capturing candidates.
133+
if (isSafeToPrune(I))
134+
return false;
135135

136-
Captured = true;
137-
return true;
138-
}
136+
Captured = true;
137+
return true;
138+
}
139139

140-
const Instruction *BeforeHere;
141-
const DominatorTree *DT;
140+
const Instruction *BeforeHere;
141+
const DominatorTree *DT;
142142

143-
bool ReturnCaptures;
144-
bool IncludeI;
143+
bool ReturnCaptures;
144+
bool IncludeI;
145145

146-
bool Captured = false;
146+
bool Captured = false;
147147

148-
const LoopInfo *LI;
149-
};
148+
const LoopInfo *LI;
149+
};
150150

151-
/// Find the 'earliest' instruction before which the pointer is known not to
152-
/// be captured. Here an instruction A is considered earlier than instruction
153-
/// B, if A dominates B. If 2 escapes do not dominate each other, the
154-
/// terminator of the common dominator is chosen. If not all uses cannot be
155-
/// analyzed, the earliest escape is set to the first instruction in the
156-
/// function entry block.
157-
// NOTE: Users have to make sure instructions compared against the earliest
158-
// escape are not in a cycle.
159-
struct EarliestCaptures : public CaptureTracker {
160-
161-
EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT)
162-
: DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}
163-
164-
void tooManyUses() override {
165-
Captured = true;
166-
EarliestCapture = &*F.getEntryBlock().begin();
167-
}
151+
/// Find the 'earliest' instruction before which the pointer is known not to
152+
/// be captured. Here an instruction A is considered earlier than instruction
153+
/// B, if A dominates B. If 2 escapes do not dominate each other, the
154+
/// terminator of the common dominator is chosen. If not all uses cannot be
155+
/// analyzed, the earliest escape is set to the first instruction in the
156+
/// function entry block.
157+
// NOTE: Users have to make sure instructions compared against the earliest
158+
// escape are not in a cycle.
159+
struct EarliestCaptures : public CaptureTracker {
168160

169-
bool captured(const Use *U) override {
170-
Instruction *I = cast<Instruction>(U->getUser());
171-
if (isa<ReturnInst>(I) && !ReturnCaptures)
172-
return false;
161+
EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT)
162+
: DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}
173163

174-
if (!EarliestCapture)
175-
EarliestCapture = I;
176-
else
177-
EarliestCapture = DT.findNearestCommonDominator(EarliestCapture, I);
178-
Captured = true;
164+
void tooManyUses() override {
165+
Captured = true;
166+
EarliestCapture = &*F.getEntryBlock().begin();
167+
}
179168

180-
// Return false to continue analysis; we need to see all potential
181-
// captures.
169+
bool captured(const Use *U) override {
170+
Instruction *I = cast<Instruction>(U->getUser());
171+
if (isa<ReturnInst>(I) && !ReturnCaptures)
182172
return false;
183-
}
184173

185-
Instruction *EarliestCapture = nullptr;
174+
if (!EarliestCapture)
175+
EarliestCapture = I;
176+
else
177+
EarliestCapture = DT.findNearestCommonDominator(EarliestCapture, I);
178+
Captured = true;
186179

187-
const DominatorTree &DT;
180+
// Return false to continue analysis; we need to see all potential
181+
// captures.
182+
return false;
183+
}
188184

189-
bool ReturnCaptures;
185+
Instruction *EarliestCapture = nullptr;
190186

191-
bool Captured = false;
187+
const DominatorTree &DT;
192188

193-
Function &F;
194-
};
189+
bool ReturnCaptures;
190+
191+
bool Captured = false;
192+
193+
Function &F;
194+
};
195195
} // namespace
196196

197197
/// PointerMayBeCaptured - Return true if this pointer value may be captured

0 commit comments

Comments
 (0)