Skip to content

Commit 4c4e25f

Browse files
David Ungardavidungar
David Ungar
authored andcommitted
Added consts where helpful and deleted where not.
1 parent 617b506 commit 4c4e25f

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

Diff for: lib/FrontendTool/ReferenceDependencies.cpp

+31-31
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ class ReferenceDependenciesEmitter {
4646
static bool emit(DiagnosticEngine &diags, SourceFile *SF,
4747
const DependencyTracker &depTracker,
4848
StringRef outputPath);
49-
static void emit(SourceFile *const SF, const DependencyTracker &depTracker, llvm::raw_ostream &out);
49+
static void emit(SourceFile *SF, const DependencyTracker &depTracker, llvm::raw_ostream &out);
5050

5151
private:
5252
static std::unique_ptr<llvm::raw_fd_ostream> openFile(DiagnosticEngine &diags,
5353
StringRef OutputPath);
54-
void emit();
55-
void emitProvides();
56-
void emitDepends();
57-
void emitInterfaceHash();
54+
void emit() const;
55+
void emitProvides() const;
56+
void emitDepends() const;
57+
void emitInterfaceHash() const;
5858
};
5959

6060
class ProvidesEmitter {
@@ -65,7 +65,7 @@ class ProvidesEmitter {
6565
: SF(SF), out(out) {}
6666

6767
public:
68-
static void emit(const SourceFile * const SF, llvm::raw_ostream &out);
68+
static void emit(const SourceFile * SF, llvm::raw_ostream &out);
6969

7070
private:
7171
/// Collected and later written information.
@@ -77,24 +77,24 @@ class ProvidesEmitter {
7777
void findNominalsAndOperators(DeclRange members);
7878
};
7979

80-
void emit();
81-
CollectedProvidedDeclarations emitTopLevelNames();
82-
void emitNominalTypes(const llvm::MapVector<const NominalTypeDecl *, bool> &extendedNominals);
83-
void emitMembers(const CollectedProvidedDeclarations &cpd);
84-
void emitDynamicLookupMembers();
80+
void emit() const;
81+
CollectedProvidedDeclarations emitTopLevelNames() const;
82+
void emitNominalTypes(const llvm::MapVector<const NominalTypeDecl *, bool> &extendedNominals) const;
83+
void emitMembers(const CollectedProvidedDeclarations &cpd) const;
84+
void emitDynamicLookupMembers() const;
8585

86-
void emitTopLevelDecl(const Decl *D, CollectedProvidedDeclarations &cpd);
87-
void emitExtensionDecl(const ExtensionDecl *D, CollectedProvidedDeclarations &cpd);
88-
void emitNominalTypeDecl(const NominalTypeDecl *NTD, CollectedProvidedDeclarations &cpd);
89-
void emitValueDecl(const ValueDecl *VD);
86+
void emitTopLevelDecl(const Decl *D, CollectedProvidedDeclarations &cpd) const;
87+
void emitExtensionDecl(const ExtensionDecl *D, CollectedProvidedDeclarations &cpd) const;
88+
void emitNominalTypeDecl(const NominalTypeDecl *NTD, CollectedProvidedDeclarations &cpd) const;
89+
void emitValueDecl(const ValueDecl *VD) const;
9090

9191
static bool extendedTypeIsPrivate(TypeLoc inheritedType);
9292
static bool declIsPrivate(const Decl *member);
9393
};
9494

9595

9696
class DependsEmitter {
97-
const SourceFile *SF;
97+
const SourceFile *const SF;
9898
const DependencyTracker &depTracker;
9999
llvm::raw_ostream &out;
100100

@@ -171,13 +171,13 @@ bool ReferenceDependenciesEmitter::emit(DiagnosticEngine &diags,
171171
return false;
172172
}
173173

174-
void ReferenceDependenciesEmitter::emit(SourceFile *const SF,
174+
void ReferenceDependenciesEmitter::emit(SourceFile *SF,
175175
const DependencyTracker &depTracker,
176176
llvm::raw_ostream &out) {
177177
ReferenceDependenciesEmitter(SF, depTracker, out).emit();
178178
}
179179

180-
void ReferenceDependenciesEmitter::emit() {
180+
void ReferenceDependenciesEmitter::emit() const {
181181
assert(SF && "Cannot emit reference dependencies without a SourceFile");
182182
out << "### Swift dependencies file v0 ###\n";
183183
emitProvides();
@@ -186,13 +186,13 @@ void ReferenceDependenciesEmitter::emit() {
186186
}
187187

188188
bool swift::emitReferenceDependencies(DiagnosticEngine &diags,
189-
SourceFile *const SF,
189+
SourceFile *SF,
190190
const DependencyTracker &depTracker,
191191
StringRef outputPath) {
192192
return ReferenceDependenciesEmitter::emit(diags, SF, depTracker, outputPath);
193193
}
194194

195-
void ProvidesEmitter::emit() {
195+
void ProvidesEmitter::emit() const {
196196
out << "provides-top-level:\n";
197197

198198
CollectedProvidedDeclarations cpd = emitTopLevelNames();
@@ -205,21 +205,21 @@ void ProvidesEmitter::emit(const SourceFile *SF, llvm::raw_ostream &out) {
205205
ProvidesEmitter(SF, out).emit();
206206
}
207207

208-
void ReferenceDependenciesEmitter::emitProvides() {
208+
void ReferenceDependenciesEmitter::emitProvides() const {
209209
ProvidesEmitter::emit(SF, out);
210210
}
211211

212-
void ReferenceDependenciesEmitter::emitDepends() {
212+
void ReferenceDependenciesEmitter::emitDepends() const {
213213
DependsEmitter::emit(SF, depTracker, out);
214214
}
215215

216-
void ReferenceDependenciesEmitter::emitInterfaceHash() {
216+
void ReferenceDependenciesEmitter::emitInterfaceHash() const {
217217
llvm::SmallString<32> interfaceHash;
218218
SF->getInterfaceHash(interfaceHash);
219219
out << "interface-hash: \"" << interfaceHash << "\"\n";
220220
}
221221

222-
ProvidesEmitter::CollectedProvidedDeclarations ProvidesEmitter::emitTopLevelNames() {
222+
ProvidesEmitter::CollectedProvidedDeclarations ProvidesEmitter::emitTopLevelNames() const {
223223
CollectedProvidedDeclarations cpd;
224224
for (const Decl *D : SF->Decls)
225225
emitTopLevelDecl(D, cpd);
@@ -230,7 +230,7 @@ ProvidesEmitter::CollectedProvidedDeclarations ProvidesEmitter::emitTopLevelName
230230

231231
void ProvidesEmitter::emitTopLevelDecl(
232232
const Decl *const D,
233-
CollectedProvidedDeclarations &cpd) {
233+
CollectedProvidedDeclarations &cpd) const {
234234
switch (D->getKind()) {
235235
case DeclKind::Module:
236236
break;
@@ -290,7 +290,7 @@ void ProvidesEmitter::emitTopLevelDecl(
290290

291291
void ProvidesEmitter::emitExtensionDecl(
292292
const ExtensionDecl *const ED,
293-
CollectedProvidedDeclarations &cpd) {
293+
CollectedProvidedDeclarations &cpd) const {
294294
auto *NTD = ED->getExtendedType()->getAnyNominal();
295295
if (!NTD)
296296
return;
@@ -316,7 +316,7 @@ void ProvidesEmitter::emitExtensionDecl(
316316

317317
void ProvidesEmitter::emitNominalTypeDecl(
318318
const NominalTypeDecl *const NTD,
319-
CollectedProvidedDeclarations &cpd) {
319+
CollectedProvidedDeclarations &cpd) const {
320320
if (!NTD->hasName())
321321
return;
322322
if (NTD->hasAccess() && NTD->getFormalAccess() <= AccessLevel::FilePrivate) {
@@ -351,7 +351,7 @@ void ProvidesEmitter::CollectedProvidedDeclarations::findNominalsAndOperators(De
351351
}
352352
}
353353

354-
void ProvidesEmitter::emitValueDecl(const ValueDecl *const VD) {
354+
void ProvidesEmitter::emitValueDecl(const ValueDecl *const VD) const {
355355
if (!VD->hasName())
356356
return;
357357
if (VD->hasAccess() && VD->getFormalAccess() <= AccessLevel::FilePrivate) {
@@ -361,7 +361,7 @@ void ProvidesEmitter::emitValueDecl(const ValueDecl *const VD) {
361361
}
362362

363363
void ProvidesEmitter::emitNominalTypes(
364-
const llvm::MapVector<const NominalTypeDecl *, bool> &extendedNominals) {
364+
const llvm::MapVector<const NominalTypeDecl *, bool> &extendedNominals) const {
365365
out << "provides-nominal:\n";
366366
for (auto entry : extendedNominals) {
367367
if (!entry.second)
@@ -373,7 +373,7 @@ void ProvidesEmitter::emitNominalTypes(
373373
}
374374

375375
void ProvidesEmitter::emitMembers(
376-
const CollectedProvidedDeclarations &cpd) {
376+
const CollectedProvidedDeclarations &cpd) const {
377377
out << "provides-member:\n";
378378
for (auto entry : cpd.extendedNominals) {
379379
out << "- [\"";
@@ -398,7 +398,7 @@ void ProvidesEmitter::emitMembers(
398398
}
399399
}
400400

401-
void ProvidesEmitter::emitDynamicLookupMembers() {
401+
void ProvidesEmitter::emitDynamicLookupMembers() const {
402402
if (SF->getASTContext().LangOpts.EnableObjCInterop) {
403403
// FIXME: This requires a traversal of the whole file to compute.
404404
// We should (a) see if there's a cheaper way to keep it up to date,

0 commit comments

Comments
 (0)