Skip to content

Commit 81291a6

Browse files
VoltrexKeyvaAlexisPerry
authored andcommitted
[llvm] format and terminate namespaces with closing comment (llvm#94917)
Namespaces are terminated with a closing comment in the majority of the codebase so do the same here for consistency. Also format code within some namespaces to make clang-format happy.
1 parent 82351f1 commit 81291a6

12 files changed

+197
-196
lines changed

llvm/lib/Analysis/CallGraphSCCPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using namespace llvm;
4646
namespace llvm {
4747
cl::opt<unsigned> MaxDevirtIterations("max-devirt-iterations", cl::ReallyHidden,
4848
cl::init(4));
49-
}
49+
} // namespace llvm
5050

5151
STATISTIC(MaxSCCIterations, "Maximum CGSCCPassMgr iterations on one SCC");
5252

llvm/lib/Analysis/CallPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace llvm;
2929

3030
namespace llvm {
3131
template <class GraphType> struct GraphTraits;
32-
}
32+
} // namespace llvm
3333

3434
// This option shows static (relative) call counts.
3535
// FIXME:
@@ -215,7 +215,7 @@ struct DOTGraphTraits<CallGraphDOTInfo *> : public DefaultDOTGraphTraits {
215215
}
216216
};
217217

218-
} // end llvm namespace
218+
} // namespace llvm
219219

220220
namespace {
221221
void doCallGraphDOTPrinting(

llvm/lib/Analysis/CaptureTracking.cpp

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -72,127 +72,127 @@ 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-
};
195-
}
189+
bool ReturnCaptures;
190+
191+
bool Captured = false;
192+
193+
Function &F;
194+
};
195+
} // namespace
196196

197197
/// PointerMayBeCaptured - Return true if this pointer value may be captured
198198
/// by the enclosing function (which is required to exist). This routine can

llvm/lib/Analysis/CycleAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace llvm;
1515

1616
namespace llvm {
1717
class Module;
18-
}
18+
} // namespace llvm
1919

2020
CycleInfo CycleAnalysis::run(Function &F, FunctionAnalysisManager &) {
2121
CycleInfo CI;

llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cl::opt<unsigned> MediumBasicBlockInstructionThreshold(
3939
"medium-basic-block-instruction-threshold", cl::Hidden, cl::init(15),
4040
cl::desc("The minimum number of instructions a basic block should contain "
4141
"before being considered medium-sized."));
42-
}
42+
} // namespace llvm
4343

4444
static cl::opt<unsigned> CallWithManyArgumentsThreshold(
4545
"call-with-many-arguments-threshold", cl::Hidden, cl::init(4),

llvm/lib/Analysis/ImportedFunctionsInliningStatistics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cl::opt<InlinerFunctionImportStatsOpts> InlinerFunctionImportStats(
3232
clEnumValN(InlinerFunctionImportStatsOpts::Verbose, "verbose",
3333
"printing of statistics for each inlined function")),
3434
cl::Hidden, cl::desc("Enable inliner stats for imported functions"));
35-
}
35+
} // namespace llvm
3636

3737
ImportedFunctionsInliningStatistics::InlineGraphNode &
3838
ImportedFunctionsInliningStatistics::createInlineGraphNode(const Function &F) {

llvm/lib/Analysis/InlineAdvisor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static cl::opt<bool>
6464

6565
namespace llvm {
6666
extern cl::opt<InlinerFunctionImportStatsOpts> InlinerFunctionImportStats;
67-
}
67+
} // namespace llvm
6868

6969
namespace {
7070
using namespace llvm::ore;

0 commit comments

Comments
 (0)