Skip to content

Commit 267e32d

Browse files
Merge pull request #32118 from AnthonyLatsis/post-increment-cleanup
[NFC] Pre- increment and decrement where possible
2 parents 09a5c7d + 9fd1aa5 commit 267e32d

File tree

162 files changed

+398
-397
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+398
-397
lines changed

include/swift/Remote/Failure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class Failure {
255255
result.append(text, next - text);
256256

257257
// Skip the '%'.
258-
next++;
258+
++next;
259259

260260
// Do something based on the character after '%'.
261261
char c = *next++;

include/swift/Runtime/Concurrent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ template <class ElemTy> struct ConcurrentReadableArray {
434434
}
435435

436436
void deallocate() {
437-
for (size_t i = 0; i < Count; i++) {
437+
for (size_t i = 0; i < Count; ++i) {
438438
data()[i].~ElemTy();
439439
}
440440
free(this);

include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ swift_reflection_interop_loadFunctions(struct SwiftReflectionInteropContext *Con
486486
LOAD(dumpInfoForTypeRef);
487487

488488
Library->IsLegacy = IsLegacy;
489-
Context->LibraryCount++;
489+
++Context->LibraryCount;
490490

491491
return 1;
492492

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3846,7 +3846,7 @@ void SubstitutionMap::Storage::Profile(
38463846
id.AddPointer(replacementTypes[i].getPointer());
38473847
else
38483848
id.AddPointer(nullptr);
3849-
i++;
3849+
++i;
38503850
});
38513851

38523852
// Conformances.

lib/AST/ASTDemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Type ASTBuilder::createBoundGenericType(GenericTypeDecl *decl,
304304
auto *aliasDecl = cast<TypeAliasDecl>(decl);
305305

306306
auto genericSig = aliasDecl->getGenericSignature();
307-
for (unsigned i = 0, e = args.size(); i < e; i++) {
307+
for (unsigned i = 0, e = args.size(); i < e; ++i) {
308308
auto origTy = genericSig->getInnermostGenericParams()[i];
309309
auto substTy = args[i];
310310

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ void PrintAST::printGenericSignature(
14361436
// Move index to genericParams.
14371437
unsigned lastParamIdx = paramIdx;
14381438
do {
1439-
lastParamIdx++;
1439+
++lastParamIdx;
14401440
} while (lastParamIdx < numParam &&
14411441
genericParams[lastParamIdx]->getDepth() == depth);
14421442

lib/AST/ASTVerifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ class Verifier : public ASTWalker {
16921692
// Look through optional evaluations.
16931693
if (auto *optionalEval = dyn_cast<OptionalEvaluationExpr>(subExpr)) {
16941694
subExpr = optionalEval->getSubExpr();
1695-
optionalDepth++;
1695+
++optionalDepth;
16961696
continue;
16971697
}
16981698

@@ -3165,7 +3165,7 @@ class Verifier : public ASTWalker {
31653165
unsigned NumDestructors = 0;
31663166
for (auto Member : CD->getMembers()) {
31673167
if (isa<DestructorDecl>(Member)) {
3168-
NumDestructors++;
3168+
++NumDestructors;
31693169
}
31703170
}
31713171
if (NumDestructors > 1) {

lib/AST/Builtins.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ getBuiltinGenericFunction(Identifier Id,
195195
DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin);
196196

197197
SmallVector<ParamDecl*, 4> params;
198-
for (unsigned i = 0, e = ArgParamTypes.size(); i < e; i++) {
198+
for (unsigned i = 0, e = ArgParamTypes.size(); i < e; ++i) {
199199
auto paramIfaceType = ArgParamTypes[i].getPlainType();
200200
auto specifier =
201201
ParamDecl::getParameterSpecifierForValueOwnership(
@@ -2004,11 +2004,11 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
20042004

20052005
// Accept weak, volatile, and singlethread if present.
20062006
if (NextPart != Parts.end() && *NextPart == "weak")
2007-
NextPart++;
2007+
++NextPart;
20082008
if (NextPart != Parts.end() && *NextPart == "volatile")
2009-
NextPart++;
2009+
++NextPart;
20102010
if (NextPart != Parts.end() && *NextPart == "singlethread")
2011-
NextPart++;
2011+
++NextPart;
20122012
// Nothing else is allowed in the name.
20132013
if (NextPart != Parts.end())
20142014
return nullptr;

lib/AST/ClangTypeConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ clang::QualType ClangTypeConverter::visitTupleType(TupleType *type) {
359359
return ClangASTContext.VoidTy;
360360

361361
Type eltTy = type->getElementType(0);
362-
for (unsigned i = 1; i < tupleNumElements; i++) {
362+
for (unsigned i = 1; i < tupleNumElements; ++i) {
363363
if (!eltTy->isEqual(type->getElementType(i)))
364364
// Only tuples where all element types are equal map to fixed-size
365365
// arrays.

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5036,7 +5036,7 @@ ProtocolDecl::setLazyRequirementSignature(LazyMemberLoader *lazyLoader,
50365036
++NumLazyRequirementSignatures;
50375037
// FIXME: (transitional) increment the redundant "always-on" counter.
50385038
if (auto *Stats = getASTContext().Stats)
5039-
Stats->getFrontendCounters().NumLazyRequirementSignatures++;
5039+
++Stats->getFrontendCounters().NumLazyRequirementSignatures;
50405040
}
50415041

50425042
ArrayRef<Requirement> ProtocolDecl::getCachedRequirementSignature() const {
@@ -5196,7 +5196,7 @@ AbstractStorageDecl::AccessorRecord::create(ASTContext &ctx,
51965196
case AccessorKind::ID: \
51975197
if (!has##ID) { \
51985198
has##ID = true; \
5199-
numMissingOpaque--; \
5199+
--numMissingOpaque; \
52005200
} \
52015201
continue;
52025202
#include "swift/AST/AccessorKinds.def"

lib/AST/DeclContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ void IterableDeclContext::loadAllMembers() const {
924924
--NumUnloadedLazyIterableDeclContexts;
925925
// FIXME: (transitional) decrement the redundant "always-on" counter.
926926
if (auto s = ctx.Stats)
927-
s->getFrontendCounters().NumUnloadedLazyIterableDeclContexts--;
927+
--s->getFrontendCounters().NumUnloadedLazyIterableDeclContexts;
928928
}
929929

930930
bool IterableDeclContext::wasDeserialized() const {

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ void DiagnosticEngine::emitDiagnostic(const Diagnostic &diagnostic) {
993993
SmallString<128> notePath(getDiagnosticDocumentationPath());
994994
llvm::sys::path::append(notePath, *associatedNotes);
995995
educationalNotePaths.push_back(notePath.str().str());
996-
associatedNotes++;
996+
++associatedNotes;
997997
}
998998
info->EducationalNotePaths = educationalNotePaths;
999999

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ GenericSignatureImpl::GenericSignatureImpl(
6565
count = 0;
6666
}
6767
assert(param->getIndex() == count && "Generic parameter index mismatch");
68-
count++;
68+
++count;
6969
}
7070
#endif
7171

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,7 +3432,7 @@ EquivalenceClass::EquivalenceClass(PotentialArchetype *representative)
34323432
}
34333433

34343434
void EquivalenceClass::modified(GenericSignatureBuilder &builder) {
3435-
builder.Impl->Generation++;
3435+
++builder.Impl->Generation;
34363436

34373437
// Transfer any delayed requirements to the primary queue, because they
34383438
// might be resolvable now.
@@ -3445,7 +3445,7 @@ GenericSignatureBuilder::GenericSignatureBuilder(
34453445
ASTContext &ctx)
34463446
: Context(ctx), Diags(Context.Diags), Impl(new Implementation) {
34473447
if (auto *Stats = Context.Stats)
3448-
Stats->getFrontendCounters().NumGenericSignatureBuilders++;
3448+
++Stats->getFrontendCounters().NumGenericSignatureBuilders;
34493449
}
34503450

34513451
GenericSignatureBuilder::GenericSignatureBuilder(
@@ -3823,7 +3823,7 @@ static ConstraintResult visitInherited(
38233823
unsigned index = 0;
38243824
for (auto memberType : compositionType->getMembers()) {
38253825
visitInherited(memberType, composition->getTypes()[index]);
3826-
index++;
3826+
++index;
38273827
}
38283828

38293829
return;

lib/AST/ImportCache.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ ImportCache::getImportSet(ASTContext &ctx,
109109

110110
if (ImportSet *result = ImportSets.FindNodeOrInsertPos(ID, InsertPos)) {
111111
if (ctx.Stats)
112-
ctx.Stats->getFrontendCounters().ImportSetFoldHit++;
112+
++ctx.Stats->getFrontendCounters().ImportSetFoldHit;
113113
return *result;
114114
}
115115

116116
if (ctx.Stats)
117-
ctx.Stats->getFrontendCounters().ImportSetFoldMiss++;
117+
++ctx.Stats->getFrontendCounters().ImportSetFoldMiss;
118118

119119
SmallVector<ModuleDecl::ImportedModule, 4> stack;
120120
for (auto next : topLevelImports) {
@@ -166,12 +166,12 @@ ImportSet &ImportCache::getImportSet(const DeclContext *dc) {
166166
auto found = ImportSetForDC.find(dc);
167167
if (found != ImportSetForDC.end()) {
168168
if (ctx.Stats)
169-
ctx.Stats->getFrontendCounters().ImportSetCacheHit++;
169+
++ctx.Stats->getFrontendCounters().ImportSetCacheHit;
170170
return *found->second;
171171
}
172172

173173
if (ctx.Stats)
174-
ctx.Stats->getFrontendCounters().ImportSetCacheMiss++;
174+
++ctx.Stats->getFrontendCounters().ImportSetCacheMiss;
175175

176176
SmallVector<ModuleDecl::ImportedModule, 4> imports;
177177

@@ -213,12 +213,12 @@ ImportCache::getAllVisibleAccessPaths(const ModuleDecl *mod,
213213
auto found = VisibilityCache.find(key);
214214
if (found != VisibilityCache.end()) {
215215
if (ctx.Stats)
216-
ctx.Stats->getFrontendCounters().ModuleVisibilityCacheHit++;
216+
++ctx.Stats->getFrontendCounters().ModuleVisibilityCacheHit;
217217
return found->second;
218218
}
219219

220220
if (ctx.Stats)
221-
ctx.Stats->getFrontendCounters().ModuleVisibilityCacheMiss++;
221+
++ctx.Stats->getFrontendCounters().ModuleVisibilityCacheMiss;
222222

223223
SmallVector<ModuleDecl::AccessPathTy, 1> accessPaths;
224224
for (auto next : getImportSet(dc).getAllImports()) {
@@ -251,12 +251,12 @@ ImportCache::getAllAccessPathsNotShadowedBy(const ModuleDecl *mod,
251251
auto found = ShadowCache.find(key);
252252
if (found != ShadowCache.end()) {
253253
if (ctx.Stats)
254-
ctx.Stats->getFrontendCounters().ModuleShadowCacheHit++;
254+
++ctx.Stats->getFrontendCounters().ModuleShadowCacheHit;
255255
return found->second;
256256
}
257257

258258
if (ctx.Stats)
259-
ctx.Stats->getFrontendCounters().ModuleShadowCacheMiss++;
259+
++ctx.Stats->getFrontendCounters().ModuleShadowCacheMiss;
260260

261261
SmallVector<ModuleDecl::ImportedModule, 4> stack;
262262
llvm::SmallDenseSet<ModuleDecl::ImportedModule, 32> visited;

lib/AST/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void ModuleDecl::lookupValue(DeclName Name, NLKind LookupKind,
554554
SmallVectorImpl<ValueDecl*> &Result) const {
555555
auto *stats = getASTContext().Stats;
556556
if (stats)
557-
stats->getFrontendCounters().NumModuleLookupValue++;
557+
++stats->getFrontendCounters().NumModuleLookupValue;
558558

559559
if (isParsedModule(this)) {
560560
getSourceLookupCache().lookupValue(Name, LookupKind, Result);
@@ -710,7 +710,7 @@ void ModuleDecl::lookupClassMember(AccessPathTy accessPath,
710710
SmallVectorImpl<ValueDecl*> &results) const {
711711
auto *stats = getASTContext().Stats;
712712
if (stats)
713-
stats->getFrontendCounters().NumModuleLookupClassMember++;
713+
++stats->getFrontendCounters().NumModuleLookupClassMember;
714714

715715
if (isParsedModule(this)) {
716716
FrontendStatsTracer tracer(getASTContext().Stats,

lib/AST/NameLookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ void LookupResult::filter(
7878
Results.erase(std::remove_if(Results.begin(), Results.end(),
7979
[&](LookupResultEntry result) -> bool {
8080
auto isInner = index < originalFirstOuter;
81-
index++;
81+
++index;
8282
if (pred(result, !isInner))
8383
return false;
8484

8585
// Need to remove this, which means, if it is
8686
// an inner result, the outer results need to
8787
// shift down.
8888
if (isInner)
89-
IndexOfFirstOuterResult--;
89+
--IndexOfFirstOuterResult;
9090
return true;
9191
}),
9292
Results.end());

lib/AST/RequirementEnvironment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ RequirementEnvironment::RequirementEnvironment(
7373
// appear in the synthetic signature.
7474
unsigned depth = 0;
7575
if (covariantSelf) {
76-
depth++;
76+
++depth;
7777
}
7878
if (conformanceSig) {
7979
depth += conformanceSig->getGenericParams().back()->getDepth() + 1;

lib/AST/SubstitutionMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
333333
reqt.getSecondType()->isEqual(proto->getDeclaredType()))
334334
return getConformances()[index];
335335

336-
index++;
336+
++index;
337337
}
338338
}
339339

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4008,7 +4008,7 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
40084008
// Continue looking into the parent.
40094009
if (auto protocolTy = baseTy->getAs<ProtocolType>()) {
40104010
baseTy = protocolTy->getParent();
4011-
n--;
4011+
--n;
40124012
continue;
40134013
}
40144014

lib/Basic/Mangler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static llvm::StringMap<OpStatEntry> OpStats;
5959
void Mangler::recordOpStatImpl(StringRef op, size_t OldPos) {
6060
if (PrintSwiftManglingStats) {
6161
OpStatEntry &E = OpStats[op];
62-
E.num++;
62+
++E.num;
6363
E.size += Storage.size() - OldPos;
6464
}
6565
}
@@ -218,15 +218,15 @@ bool Mangler::tryMangleSubstitution(const void *ptr) {
218218
void Mangler::mangleSubstitution(unsigned Idx) {
219219
if (Idx >= 26) {
220220
#ifndef NDEBUG
221-
numLargeSubsts++;
221+
++numLargeSubsts;
222222
#endif
223223
return appendOperator("A", Index(Idx - 26));
224224
}
225225

226226
char Subst = Idx + 'A';
227227
if (SubstMerging.tryMergeSubst(*this, Subst, /*isStandardSubst*/ false)) {
228228
#ifndef NDEBUG
229-
mergedSubsts++;
229+
++mergedSubsts;
230230
#endif
231231
} else {
232232
appendOperator("A", StringRef(&Subst, 1));

lib/Basic/PrimitiveParsing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ unsigned swift::measureNewline(const char *BufferPtr, const char *BufferEnd) {
3030
assert(*BufferPtr == '\r');
3131
unsigned Bytes = 1;
3232
if (BufferPtr != BufferEnd && *BufferPtr == '\n')
33-
Bytes++;
33+
++Bytes;
3434
return Bytes;
3535
}
3636

lib/Basic/Statistic.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ class UnifiedStatsReporter::RecursionSafeTimers {
162162
if (T.RecursionDepth == 0) {
163163
T.Timer.emplace(Name);
164164
}
165-
T.RecursionDepth++;
165+
++T.RecursionDepth;
166166
}
167167

168168
void endTimer(StringRef Name) {
169169
auto I = Timers.find(Name);
170170
assert(I != Timers.end());
171171
RecursionSafeTimer &T = I->getValue();
172172
assert(T.RecursionDepth != 0);
173-
T.RecursionDepth--;
173+
--T.RecursionDepth;
174174
if (T.RecursionDepth == 0) {
175175
T.Timer.reset();
176176
}
@@ -651,10 +651,10 @@ UnifiedStatsReporter::~UnifiedStatsReporter()
651651
if (currentProcessExitStatus != EXIT_SUCCESS) {
652652
if (FrontendCounters) {
653653
auto &C = getFrontendCounters();
654-
C.NumProcessFailures++;
654+
++C.NumProcessFailures;
655655
} else {
656656
auto &C = getDriverCounters();
657-
C.NumProcessFailures++;
657+
++C.NumProcessFailures;
658658
}
659659
}
660660

0 commit comments

Comments
 (0)