Skip to content

[gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] #2053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/modules/SwiftSharedCMakeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
get_filename_component(CMARK_LIBRARY_DIR "${${product}_CMARK_LIBRARY_DIR}"
ABSOLUTE)

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

check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
if(CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types")
endif()
endmacro()
Expand Down
2 changes: 1 addition & 1 deletion docs/Generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Polymorphism
------------

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

func +(x : Int, y : Int) -> Int { add... }
Expand Down
2 changes: 1 addition & 1 deletion docs/StringDesign.rst
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ Indexing
.. Admonition:: Example

.. parsed-literal::
s[beginning...ending] // [s substringWithRange: NSMakeRange( beginning, ending )]
s[beginning...ending] // [s substringWithRange: NSMakeRange(beginning, ending)]
s[beginning...] // [s substringFromIndex: beginning]
s[...ending] // [s substringToIndex: ending]

Expand Down
14 changes: 7 additions & 7 deletions docs/TextFormatting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ Formatting Variants
(e.g. number types) *additionally* support a ``format(…)`` method
parameterized according to that type's axes of variability::

print( offset )
print( offset.format() ) // equivalent to previous line
print( offset.format(radix: 16, width: 5, precision: 3) )
print(offset)
print(offset.format()) // equivalent to previous line
print(offset.format(radix: 16, width: 5, precision: 3))

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

print( offset.hex() )
print(offset.hex())


Design Details
Expand Down Expand Up @@ -342,7 +342,7 @@ adapter that transforms its input to upper case before writing it to
an underlying stream::

struct UpperStream<UnderlyingStream:OutputStream> : OutputStream {
func append(x: String) { base.append( x.toUpper() ) }
func append(x: String) { base.append(x.toUpper()) }
var base: UnderlyingStream
}

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

.. parsed-literal::

print( n.format(radix:16)\ **.toUpper()** )
print(n.format(radix:16)\ **.toUpper()**)

The complexity of this back-and-forth adapter dance is daunting, and
might well be better handled in the language once we have some formal
Expand All @@ -402,7 +402,7 @@ more sense to build the important transformations directly into

.. parsed-literal::

print( n.format(radix:16, **case:.upper** ) )
print(n.format(radix:16, **case:.upper**))

Possible Simplifications
------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/proposals/Concurrency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ Here is another example of async calls using trailing closures and enums.
}}

//CHECK: Shape: Oval
print("Shape: \( res.await() )")
print("Shape: \(res.await())")

Notice that the swift compiler infers that ``Shape`` and `String` can be sent
between the threads.
Expand Down
2 changes: 1 addition & 1 deletion docs/proposals/ValueSemantics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ linked list::

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

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

This is why so many generic algorithms seem to work on both
``class``\ es and non-``class``\ es: ``class`` *identities*
Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,9 +1138,9 @@ class GenericParamList final :

unsigned size() const { return NumParams; }
iterator begin() { return getParams().begin(); }
iterator end() { return getParams().end(); }
iterator end() { return getParams().end(); }
const_iterator begin() const { return getParams().begin(); }
const_iterator end() const { return getParams().end(); }
const_iterator end() const { return getParams().end(); }

/// Get the total number of parameters, including those from parent generic
/// parameter lists.
Expand Down
24 changes: 12 additions & 12 deletions include/swift/Basic/JSONSerialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct ScalarTraits {
/// return seq.size();
/// }
/// static MyType& element(Output &, std::vector<MyType> &seq, size_t index) {
/// if ( index >= seq.size() )
/// if (index >= seq.size())
/// seq.resize(index+1);
/// return seq[index];
/// }
Expand Down Expand Up @@ -339,14 +339,14 @@ class Output {

template <typename T>
void enumCase(T &Val, const char* Str, const T ConstVal) {
if ( matchEnumScalar(Str, Val == ConstVal) ) {
if (matchEnumScalar(Str, Val == ConstVal)) {
Val = ConstVal;
}
}

template <typename T>
void bitSetCase(T &Val, const char* Str, const T ConstVal) {
if ( bitSetMatch(Str, (Val & ConstVal) == ConstVal) ) {
if (bitSetMatch(Str, (Val & ConstVal) == ConstVal)) {
Val = Val | ConstVal;
}
}
Expand All @@ -373,7 +373,7 @@ class Output {
typename std::enable_if<has_ArrayTraits<T>::value,void>::type
mapOptional(const char* Key, T& Val) {
// omit key/value instead of outputting empty array
if ( this->canElideEmptyArray() && !(Val.begin() != Val.end()) )
if (this->canElideEmptyArray() && !(Val.begin() != Val.end()))
return;
this->processKey(Key, Val, false);
}
Expand Down Expand Up @@ -421,12 +421,12 @@ class Output {
void *SaveInfo;
bool UseDefault;
const bool sameAsDefault = Val == DefaultValue;
if ( this->preflightKey(Key, Required, sameAsDefault, UseDefault,
SaveInfo) ) {
if (this->preflightKey(Key, Required, sameAsDefault, UseDefault,
SaveInfo)) {
jsonize(*this, Val, Required);
this->postflightKey(SaveInfo);
} else {
if ( UseDefault )
if (UseDefault)
Val = DefaultValue;
}
}
Expand All @@ -435,7 +435,7 @@ class Output {
void processKey(const char *Key, T &Val, bool Required) {
void *SaveInfo;
bool UseDefault;
if ( this->preflightKey(Key, Required, false, UseDefault, SaveInfo) ) {
if (this->preflightKey(Key, Required, false, UseDefault, SaveInfo)) {
jsonize(*this, Val, Required);
this->postflightKey(SaveInfo);
}
Expand Down Expand Up @@ -535,8 +535,8 @@ template<typename T>
typename std::enable_if<has_ScalarBitSetTraits<T>::value,void>::type
jsonize(Output &out, T &Val, bool) {
bool DoClear;
if ( out.beginBitSetScalar(DoClear) ) {
if ( DoClear )
if (out.beginBitSetScalar(DoClear)) {
if (DoClear)
Val = static_cast<T>(0);
ScalarBitSetTraits<T>::bitset(out, Val);
out.endBitSetScalar();
Expand Down Expand Up @@ -592,9 +592,9 @@ jsonize(Output &out, T &Seq, bool) {
{
out.beginArray();
unsigned count = ArrayTraits<T>::size(out, Seq);
for(unsigned i=0; i < count; ++i) {
for (unsigned i=0; i < count; ++i) {
void *SaveInfo;
if ( out.preflightElement(i, SaveInfo) ) {
if (out.preflightElement(i, SaveInfo)) {
jsonize(out, ArrayTraits<T>::element(out, Seq, i), true);
out.postflightElement(SaveInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ SILCloner<ImplClass>::visitSwitchValueInst(SwitchValueInst *Inst) {
if (Inst->hasDefault())
DefaultBB = getOpBasicBlock(Inst->getDefaultBB());
SmallVector<std::pair<SILValue, SILBasicBlock*>, 8> CaseBBs;
for(int i = 0, e = Inst->getNumCases(); i != e; ++i)
for (int i = 0, e = Inst->getNumCases(); i != e; ++i)
CaseBBs.push_back(std::make_pair(getOpValue(Inst->getCase(i).first),
getOpBasicBlock(Inst->getCase(i).second)));
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4459,7 +4459,7 @@ class ApplySite {
default: \
llvm_unreachable("not an apply instruction!"); \
} \
} while(0)
} while (0)

/// Return the callee operand.
SILValue getCallee() const {
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SILOptimizer/Analysis/CallerAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CallerAnalysis : public SILAnalysis {
public:
CallerAnalysis(SILModule *M) : SILAnalysis(AnalysisKind::Caller), Mod(*M) {
// Make sure we compute everything first time called.
for(auto &F : Mod) {
for (auto &F : Mod) {
CallInfo.FindAndConstruct(&F);
RecomputeFunctionList.insert(&F);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ class CallerAnalysis : public SILAnalysis {

CallInfo.clear();
RecomputeFunctionList.clear();
for(auto &F : Mod) {
for (auto &F : Mod) {
RecomputeFunctionList.insert(&F);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void RequirementRepr::dump() const {

Optional<std::tuple<StringRef, StringRef, RequirementReprKind>>
RequirementRepr::getAsAnalyzedWrittenString() const {
if(AsWrittenString.empty())
if (AsWrittenString.empty())
return None;
auto Pair = AsWrittenString.split("==");
auto Kind = RequirementReprKind::SameType;
Expand Down
20 changes: 10 additions & 10 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ collectNameTypeMap(Type Ty, const DeclContext *DC) {
assert(ParamDecls.size() == Args.size());

// Map type parameter names with their instantiating arguments.
for(unsigned I = 0, N = ParamDecls.size(); I < N; I ++) {
for (unsigned I = 0, N = ParamDecls.size(); I < N; I ++) {
(*IdMap)[ParamDecls[I]->getName().str()] = Args[I];
}
} while ((BaseTy = BaseTy->getSuperclass(nullptr)));
Expand Down Expand Up @@ -154,7 +154,7 @@ class ArchetypeSelfTransformer : public PrinterArchetypeTransformer {
auto ATT = cast<ArchetypeType>(Ty.getPointer());
ArchetypeType *Self = ATT;
std::vector<Identifier> Names;
for(; Self->getParent(); Self = Self->getParent()) {
for (; Self->getParent(); Self = Self->getParent()) {
Names.insert(Names.begin(), Self->getName());
}
if (!Self->getSelfProtocol() || Names.empty())
Expand Down Expand Up @@ -371,7 +371,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
Text = Text.trim();
auto ParamStart = Text.find_first_of('<');
auto ParamEnd = Text.find_last_of('>');
if(StringRef::npos == ParamStart) {
if (StringRef::npos == ParamStart) {
return checkElementType(Text);
}
Type GenericType = checkElementType(StringRef(Text.data(), ParamStart));
Expand Down Expand Up @@ -461,7 +461,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
auto Written = Req.getAsWrittenString();
switch (Kind) {
case RequirementReprKind::TypeConstraint:
if(!canPossiblyConvertTo(First, Second, *DC))
if (!canPossiblyConvertTo(First, Second, *DC))
return {Result, MergeInfo};
else if (isConvertibleTo(First, Second, *DC))
Result.KnownSatisfiedRequirements.push_back(Written);
Expand Down Expand Up @@ -546,7 +546,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
for (auto TL : Target->getInherited()) {
addTypeLocNominal(TL);
}
while(!Unhandled.empty()) {
while (!Unhandled.empty()) {
NominalTypeDecl* Back = Unhandled.back();
Unhandled.pop_back();
for (ExtensionDecl *E : Back->getExtensions()) {
Expand Down Expand Up @@ -600,8 +600,8 @@ SynthesizedExtensionAnalyzer::~SynthesizedExtensionAnalyzer() {delete &Impl;}

bool SynthesizedExtensionAnalyzer::
isInSynthesizedExtension(const ValueDecl *VD) {
if(auto Ext = dyn_cast_or_null<ExtensionDecl>(VD->getDeclContext()->
getInnermostTypeContext())) {
if (auto Ext = dyn_cast_or_null<ExtensionDecl>(VD->getDeclContext()->
getInnermostTypeContext())) {
return Impl.InfoMap->count(Ext) != 0 &&
Impl.InfoMap->find(Ext)->second.IsSynthesized;
}
Expand Down Expand Up @@ -771,7 +771,7 @@ ValueDecl* ASTPrinter::findConformancesWithDocComment(ValueDecl *VD) {
assert(VD->getRawComment().isEmpty());
std::queue<ValueDecl*> AllConformances;
AllConformances.push(VD);
while(!AllConformances.empty()) {
while (!AllConformances.empty()) {
auto *VD = AllConformances.front();
AllConformances.pop();
if (VD->getRawComment().isEmpty()) {
Expand Down Expand Up @@ -3689,7 +3689,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
}

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

void printFunctionExtInfo(SILFunctionType::ExtInfo info) {
if(Options.SkipAttributes)
if (Options.SkipAttributes)
return;

if (Options.PrintFunctionRepresentationAttrs) {
Expand Down
6 changes: 3 additions & 3 deletions lib/AST/ASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
}

bool visitNominalTypeDecl(NominalTypeDecl *NTD) {
if(auto GPS = NTD->getGenericParams()) {
if (auto GPS = NTD->getGenericParams()) {
for (auto GP : GPS->getParams()) {
if (doIt(GP))
return true;
Expand Down Expand Up @@ -240,7 +240,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
for (auto &P : AFD->getGenericParams()->getParams()) {
if (doIt(P))
return true;
for(auto Inherit : P->getInherited()) {
for (auto Inherit : P->getInherited()) {
if (doIt(Inherit))
return true;
}
Expand Down Expand Up @@ -336,7 +336,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
} \
return NODE; \
} \
} while(false)
} while (false)

Expr *visitErrorExpr(ErrorExpr *E) { return E; }
Expr *visitCodeCompletionExpr(CodeCompletionExpr *E) { return E; }
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ArchetypeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ auto ArchetypeBuilder::PotentialArchetype::getNestedType(
if (identifiers.size()) {
// Go down our PAs until we find the referenced PA.
auto existingPA = this;
while(identifiers.size()) {
while (identifiers.size()) {
auto identifier = identifiers.back();
// If we end up looking for ourselves, don't recurse.
if (existingPA == this && identifier == nestedName) {
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ void SourceFile::print(ASTPrinter &Printer, const PrintOptions &PO) {
// For a major decl, we print an empty line before it.
if (MajorDeclKinds.find(decl->getKind()) != MajorDeclKinds.end())
Printer << "\n";
if(decl->print(Printer, PO))
if (decl->print(Printer, PO))
Printer << "\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/SourceEntityWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ std::pair<bool, Stmt *> SemaAnnotator::walkToStmtPre(Stmt *S) {
if (SEWalker.shouldWalkInactiveConfigRegion()) {
if (auto *ICS = dyn_cast<IfConfigStmt>(S)) {
TraverseChildren = false;
for(auto Clause : ICS->getClauses()) {
for (auto Clause : ICS->getClauses()) {
for (auto Member : Clause.Elements) {
Member.walk(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
unsigned major, minor, micro;
if (triple.isiOS()) {
triple.getiOSVersion(major, minor, micro);
} else if(triple.isWatchOS()) {
} else if (triple.isWatchOS()) {
triple.getWatchOSVersion(major, minor, micro);
} else {
assert(triple.isMacOSX());
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ getSwiftStdlibType(const clang::TypedefNameDecl *D,

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

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

Expand Down
Loading