Skip to content

Commit abfecfd

Browse files
[gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y]
1 parent 336b719 commit abfecfd

File tree

85 files changed

+214
-214
lines changed

Some content is hidden

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

85 files changed

+214
-214
lines changed

cmake/modules/SwiftSharedCMakeConfig.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
197197
get_filename_component(CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}"
198198
ABSOLUTE)
199199

200-
if( NOT EXISTS "${${product}_PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h" )
200+
if(NOT EXISTS "${${product}_PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h")
201201
message(FATAL_ERROR "Please set ${product}_PATH_TO_CLANG_SOURCE to the root directory of Clang's source code.")
202202
else()
203203
get_filename_component(CLANG_MAIN_SRC_DIR ${${product}_PATH_TO_CLANG_SOURCE}
@@ -320,7 +320,7 @@ macro(swift_common_unified_build_config product)
320320
"${CMARK_BUILD_INCLUDE_DIR}")
321321

322322
check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
323-
if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
323+
if(CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
324324
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types")
325325
endif()
326326
endmacro()

docs/Generics.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Polymorphism
8989
------------
9090

9191
Polymorphism allows one to use different data types with a uniform
92-
interface. Overloading already allows a form of polymorphism ( ad hoc
92+
interface. Overloading already allows a form of polymorphism (ad hoc
9393
polymorphism) in Swift. For example, given::
9494

9595
func +(x : Int, y : Int) -> Int { add... }

docs/StringDesign.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ Indexing
781781
.. Admonition:: Example
782782

783783
.. parsed-literal::
784-
s[beginning...ending] // [s substringWithRange: NSMakeRange( beginning, ending )]
784+
s[beginning...ending] // [s substringWithRange: NSMakeRange(beginning, ending)]
785785
s[beginning...] // [s substringFromIndex: beginning]
786786
s[...ending] // [s substringToIndex: ending]
787787

docs/TextFormatting.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ Formatting Variants
9393
(e.g. number types) *additionally* support a ``format(…)`` method
9494
parameterized according to that type's axes of variability::
9595

96-
print( offset )
97-
print( offset.format() ) // equivalent to previous line
98-
print( offset.format(radix: 16, width: 5, precision: 3) )
96+
print(offset)
97+
print(offset.format()) // equivalent to previous line
98+
print(offset.format(radix: 16, width: 5, precision: 3))
9999

100100
Although ``format(…)`` is intended to provide the most general
101101
interface, specialized formatting interfaces are also possible::
102102

103-
print( offset.hex() )
103+
print(offset.hex())
104104

105105

106106
Design Details
@@ -342,7 +342,7 @@ adapter that transforms its input to upper case before writing it to
342342
an underlying stream::
343343

344344
struct UpperStream<UnderlyingStream:OutputStream> : OutputStream {
345-
func append(x: String) { base.append( x.toUpper() ) }
345+
func append(x: String) { base.append(x.toUpper()) }
346346
var base: UnderlyingStream
347347
}
348348

@@ -392,7 +392,7 @@ and, finally, we'd be able to write:
392392

393393
.. parsed-literal::
394394
395-
print( n.format(radix:16)\ **.toUpper()** )
395+
print(n.format(radix:16)\ **.toUpper()**)
396396
397397
The complexity of this back-and-forth adapter dance is daunting, and
398398
might well be better handled in the language once we have some formal
@@ -402,7 +402,7 @@ more sense to build the important transformations directly into
402402

403403
.. parsed-literal::
404404
405-
print( n.format(radix:16, **case:.upper** ) )
405+
print(n.format(radix:16, **case:.upper**))
406406
407407
Possible Simplifications
408408
------------------------

docs/proposals/Concurrency.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ Here is another example of async calls using trailing closures and enums.
436436
}}
437437
438438
//CHECK: Shape: Oval
439-
print("Shape: \( res.await() )")
439+
print("Shape: \(res.await())")
440440
441441
Notice that the swift compiler infers that ``Shape`` and `String` can be sent
442442
between the threads.

docs/proposals/ValueSemantics.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ linked list::
272272

273273
We can measure the length of a cycle in these nodes as follows::
274274

275-
cycle_length( someNode, (x: [inout] Node){ x = x.next } )
275+
cycle_length(someNode, (x: [inout] Node){ x = x.next })
276276

277277
This is why so many generic algorithms seem to work on both
278278
``class``\ es and non-``class``\ es: ``class`` *identities*

include/swift/AST/Decl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1138,9 +1138,9 @@ class GenericParamList final :
11381138

11391139
unsigned size() const { return NumParams; }
11401140
iterator begin() { return getParams().begin(); }
1141-
iterator end() { return getParams().end(); }
1141+
iterator end() { return getParams().end(); }
11421142
const_iterator begin() const { return getParams().begin(); }
1143-
const_iterator end() const { return getParams().end(); }
1143+
const_iterator end() const { return getParams().end(); }
11441144

11451145
/// Get the total number of parameters, including those from parent generic
11461146
/// parameter lists.

include/swift/Basic/JSONSerialization.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct ScalarTraits {
117117
/// return seq.size();
118118
/// }
119119
/// static MyType& element(Output &, std::vector<MyType> &seq, size_t index) {
120-
/// if ( index >= seq.size() )
120+
/// if (index >= seq.size())
121121
/// seq.resize(index+1);
122122
/// return seq[index];
123123
/// }
@@ -339,14 +339,14 @@ class Output {
339339

340340
template <typename T>
341341
void enumCase(T &Val, const char* Str, const T ConstVal) {
342-
if ( matchEnumScalar(Str, Val == ConstVal) ) {
342+
if (matchEnumScalar(Str, Val == ConstVal)) {
343343
Val = ConstVal;
344344
}
345345
}
346346

347347
template <typename T>
348348
void bitSetCase(T &Val, const char* Str, const T ConstVal) {
349-
if ( bitSetMatch(Str, (Val & ConstVal) == ConstVal) ) {
349+
if (bitSetMatch(Str, (Val & ConstVal) == ConstVal)) {
350350
Val = Val | ConstVal;
351351
}
352352
}
@@ -373,7 +373,7 @@ class Output {
373373
typename std::enable_if<has_ArrayTraits<T>::value,void>::type
374374
mapOptional(const char* Key, T& Val) {
375375
// omit key/value instead of outputting empty array
376-
if ( this->canElideEmptyArray() && !(Val.begin() != Val.end()) )
376+
if (this->canElideEmptyArray() && !(Val.begin() != Val.end()))
377377
return;
378378
this->processKey(Key, Val, false);
379379
}
@@ -421,12 +421,12 @@ class Output {
421421
void *SaveInfo;
422422
bool UseDefault;
423423
const bool sameAsDefault = Val == DefaultValue;
424-
if ( this->preflightKey(Key, Required, sameAsDefault, UseDefault,
425-
SaveInfo) ) {
424+
if (this->preflightKey(Key, Required, sameAsDefault, UseDefault,
425+
SaveInfo)) {
426426
jsonize(*this, Val, Required);
427427
this->postflightKey(SaveInfo);
428428
} else {
429-
if ( UseDefault )
429+
if (UseDefault)
430430
Val = DefaultValue;
431431
}
432432
}
@@ -435,7 +435,7 @@ class Output {
435435
void processKey(const char *Key, T &Val, bool Required) {
436436
void *SaveInfo;
437437
bool UseDefault;
438-
if ( this->preflightKey(Key, Required, false, UseDefault, SaveInfo) ) {
438+
if (this->preflightKey(Key, Required, false, UseDefault, SaveInfo)) {
439439
jsonize(*this, Val, Required);
440440
this->postflightKey(SaveInfo);
441441
}
@@ -535,8 +535,8 @@ template<typename T>
535535
typename std::enable_if<has_ScalarBitSetTraits<T>::value,void>::type
536536
jsonize(Output &out, T &Val, bool) {
537537
bool DoClear;
538-
if ( out.beginBitSetScalar(DoClear) ) {
539-
if ( DoClear )
538+
if (out.beginBitSetScalar(DoClear)) {
539+
if (DoClear)
540540
Val = static_cast<T>(0);
541541
ScalarBitSetTraits<T>::bitset(out, Val);
542542
out.endBitSetScalar();
@@ -592,9 +592,9 @@ jsonize(Output &out, T &Seq, bool) {
592592
{
593593
out.beginArray();
594594
unsigned count = ArrayTraits<T>::size(out, Seq);
595-
for(unsigned i=0; i < count; ++i) {
595+
for (unsigned i=0; i < count; ++i) {
596596
void *SaveInfo;
597-
if ( out.preflightElement(i, SaveInfo) ) {
597+
if (out.preflightElement(i, SaveInfo)) {
598598
jsonize(out, ArrayTraits<T>::element(out, Seq, i), true);
599599
out.postflightElement(SaveInfo);
600600
}

include/swift/SIL/SILCloner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ SILCloner<ImplClass>::visitSwitchValueInst(SwitchValueInst *Inst) {
17321732
if (Inst->hasDefault())
17331733
DefaultBB = getOpBasicBlock(Inst->getDefaultBB());
17341734
SmallVector<std::pair<SILValue, SILBasicBlock*>, 8> CaseBBs;
1735-
for(int i = 0, e = Inst->getNumCases(); i != e; ++i)
1735+
for (int i = 0, e = Inst->getNumCases(); i != e; ++i)
17361736
CaseBBs.push_back(std::make_pair(getOpValue(Inst->getCase(i).first),
17371737
getOpBasicBlock(Inst->getCase(i).second)));
17381738
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));

include/swift/SIL/SILInstruction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4459,7 +4459,7 @@ class ApplySite {
44594459
default: \
44604460
llvm_unreachable("not an apply instruction!"); \
44614461
} \
4462-
} while(0)
4462+
} while (0)
44634463

44644464
/// Return the callee operand.
44654465
SILValue getCallee() const {

include/swift/SILOptimizer/Analysis/CallerAnalysis.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class CallerAnalysis : public SILAnalysis {
7373
public:
7474
CallerAnalysis(SILModule *M) : SILAnalysis(AnalysisKind::Caller), Mod(*M) {
7575
// Make sure we compute everything first time called.
76-
for(auto &F : Mod) {
76+
for (auto &F : Mod) {
7777
CallInfo.FindAndConstruct(&F);
7878
RecomputeFunctionList.insert(&F);
7979
}
@@ -113,7 +113,7 @@ class CallerAnalysis : public SILAnalysis {
113113

114114
CallInfo.clear();
115115
RecomputeFunctionList.clear();
116-
for(auto &F : Mod) {
116+
for (auto &F : Mod) {
117117
RecomputeFunctionList.insert(&F);
118118
}
119119
}

lib/AST/ASTDumper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void RequirementRepr::dump() const {
9191

9292
Optional<std::tuple<StringRef, StringRef, RequirementReprKind>>
9393
RequirementRepr::getAsAnalyzedWrittenString() const {
94-
if(AsWrittenString.empty())
94+
if (AsWrittenString.empty())
9595
return None;
9696
auto Pair = AsWrittenString.split("==");
9797
auto Kind = RequirementReprKind::SameType;

lib/AST/ASTPrinter.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ collectNameTypeMap(Type Ty, const DeclContext *DC) {
6868
assert(ParamDecls.size() == Args.size());
6969

7070
// Map type parameter names with their instantiating arguments.
71-
for(unsigned I = 0, N = ParamDecls.size(); I < N; I ++) {
71+
for (unsigned I = 0, N = ParamDecls.size(); I < N; I ++) {
7272
(*IdMap)[ParamDecls[I]->getName().str()] = Args[I];
7373
}
7474
} while ((BaseTy = BaseTy->getSuperclass(nullptr)));
@@ -154,7 +154,7 @@ class ArchetypeSelfTransformer : public PrinterArchetypeTransformer {
154154
auto ATT = cast<ArchetypeType>(Ty.getPointer());
155155
ArchetypeType *Self = ATT;
156156
std::vector<Identifier> Names;
157-
for(; Self->getParent(); Self = Self->getParent()) {
157+
for (; Self->getParent(); Self = Self->getParent()) {
158158
Names.insert(Names.begin(), Self->getName());
159159
}
160160
if (!Self->getSelfProtocol() || Names.empty())
@@ -371,7 +371,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
371371
Text = Text.trim();
372372
auto ParamStart = Text.find_first_of('<');
373373
auto ParamEnd = Text.find_last_of('>');
374-
if(StringRef::npos == ParamStart) {
374+
if (StringRef::npos == ParamStart) {
375375
return checkElementType(Text);
376376
}
377377
Type GenericType = checkElementType(StringRef(Text.data(), ParamStart));
@@ -461,7 +461,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
461461
auto Written = Req.getAsWrittenString();
462462
switch (Kind) {
463463
case RequirementReprKind::TypeConstraint:
464-
if(!canPossiblyConvertTo(First, Second, *DC))
464+
if (!canPossiblyConvertTo(First, Second, *DC))
465465
return {Result, MergeInfo};
466466
else if (isConvertibleTo(First, Second, *DC))
467467
Result.KnownSatisfiedRequirements.push_back(Written);
@@ -546,7 +546,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
546546
for (auto TL : Target->getInherited()) {
547547
addTypeLocNominal(TL);
548548
}
549-
while(!Unhandled.empty()) {
549+
while (!Unhandled.empty()) {
550550
NominalTypeDecl* Back = Unhandled.back();
551551
Unhandled.pop_back();
552552
for (ExtensionDecl *E : Back->getExtensions()) {
@@ -600,8 +600,8 @@ SynthesizedExtensionAnalyzer::~SynthesizedExtensionAnalyzer() {delete &Impl;}
600600

601601
bool SynthesizedExtensionAnalyzer::
602602
isInSynthesizedExtension(const ValueDecl *VD) {
603-
if(auto Ext = dyn_cast_or_null<ExtensionDecl>(VD->getDeclContext()->
604-
getInnermostTypeContext())) {
603+
if (auto Ext = dyn_cast_or_null<ExtensionDecl>(VD->getDeclContext()->
604+
getInnermostTypeContext())) {
605605
return Impl.InfoMap->count(Ext) != 0 &&
606606
Impl.InfoMap->find(Ext)->second.IsSynthesized;
607607
}
@@ -771,7 +771,7 @@ ValueDecl* ASTPrinter::findConformancesWithDocComment(ValueDecl *VD) {
771771
assert(VD->getRawComment().isEmpty());
772772
std::queue<ValueDecl*> AllConformances;
773773
AllConformances.push(VD);
774-
while(!AllConformances.empty()) {
774+
while (!AllConformances.empty()) {
775775
auto *VD = AllConformances.front();
776776
AllConformances.pop();
777777
if (VD->getRawComment().isEmpty()) {
@@ -3689,7 +3689,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
36893689
}
36903690

36913691
void printFunctionExtInfo(AnyFunctionType::ExtInfo info) {
3692-
if(Options.SkipAttributes)
3692+
if (Options.SkipAttributes)
36933693
return;
36943694
auto IsAttrExcluded = [&](DeclAttrKind Kind) {
36953695
return Options.ExcludeAttrList.end() != std::find(Options.ExcludeAttrList.
@@ -3732,7 +3732,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
37323732
}
37333733

37343734
void printFunctionExtInfo(SILFunctionType::ExtInfo info) {
3735-
if(Options.SkipAttributes)
3735+
if (Options.SkipAttributes)
37363736
return;
37373737

37383738
if (Options.PrintFunctionRepresentationAttrs) {

lib/AST/ASTWalker.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
198198
}
199199

200200
bool visitNominalTypeDecl(NominalTypeDecl *NTD) {
201-
if(auto GPS = NTD->getGenericParams()) {
201+
if (auto GPS = NTD->getGenericParams()) {
202202
for (auto GP : GPS->getParams()) {
203203
if (doIt(GP))
204204
return true;
@@ -240,7 +240,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
240240
for (auto &P : AFD->getGenericParams()->getParams()) {
241241
if (doIt(P))
242242
return true;
243-
for(auto Inherit : P->getInherited()) {
243+
for (auto Inherit : P->getInherited()) {
244244
if (doIt(Inherit))
245245
return true;
246246
}
@@ -336,7 +336,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
336336
} \
337337
return NODE; \
338338
} \
339-
} while(false)
339+
} while (false)
340340

341341
Expr *visitErrorExpr(ErrorExpr *E) { return E; }
342342
Expr *visitCodeCompletionExpr(CodeCompletionExpr *E) { return E; }

lib/AST/ArchetypeBuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ auto ArchetypeBuilder::PotentialArchetype::getNestedType(
502502
if (identifiers.size()) {
503503
// Go down our PAs until we find the referenced PA.
504504
auto existingPA = this;
505-
while(identifiers.size()) {
505+
while (identifiers.size()) {
506506
auto identifier = identifiers.back();
507507
// If we end up looking for ourselves, don't recurse.
508508
if (existingPA == this && identifier == nestedName) {

lib/AST/Module.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ void SourceFile::print(ASTPrinter &Printer, const PrintOptions &PO) {
14171417
// For a major decl, we print an empty line before it.
14181418
if (MajorDeclKinds.find(decl->getKind()) != MajorDeclKinds.end())
14191419
Printer << "\n";
1420-
if(decl->print(Printer, PO))
1420+
if (decl->print(Printer, PO))
14211421
Printer << "\n";
14221422
}
14231423
}

lib/AST/SourceEntityWalker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ std::pair<bool, Stmt *> SemaAnnotator::walkToStmtPre(Stmt *S) {
160160
if (SEWalker.shouldWalkInactiveConfigRegion()) {
161161
if (auto *ICS = dyn_cast<IfConfigStmt>(S)) {
162162
TraverseChildren = false;
163-
for(auto Clause : ICS->getClauses()) {
163+
for (auto Clause : ICS->getClauses()) {
164164
for (auto Member : Clause.Elements) {
165165
Member.walk(*this);
166166
}

lib/ClangImporter/ClangImporter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
422422
unsigned major, minor, micro;
423423
if (triple.isiOS()) {
424424
triple.getiOSVersion(major, minor, micro);
425-
} else if(triple.isWatchOS()) {
425+
} else if (triple.isWatchOS()) {
426426
triple.getWatchOSVersion(major, minor, micro);
427427
} else {
428428
assert(triple.isMacOSX());

lib/ClangImporter/ImportDecl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ getSwiftStdlibType(const clang::TypedefNameDecl *D,
141141

142142
// We did not find this type, thus it is not mapped.
143143
return std::make_pair(Type(), "");
144-
} while(0);
144+
} while (0);
145145

146146
clang::ASTContext &ClangCtx = Impl.getClangASTContext();
147147

0 commit comments

Comments
 (0)