Merge pull request #15040 from ikesyo/gardening-not-empty

[gardening] Use `!empty()` over `size() > 0`
diff --git a/include/swift/AST/ExistentialLayout.h b/include/swift/AST/ExistentialLayout.h
index 4ca31e3..ca19649 100644
--- a/include/swift/AST/ExistentialLayout.h
+++ b/include/swift/AST/ExistentialLayout.h
@@ -50,10 +50,8 @@
 
   bool isObjC() const {
     // FIXME: Does the superclass have to be @objc?
-    return ((superclass ||
-             hasExplicitAnyObject ||
-             getProtocols().size() > 0)
-            && !containsNonObjCProtocol);
+    return ((superclass || hasExplicitAnyObject || !getProtocols().empty()) &&
+            !containsNonObjCProtocol);
   }
 
   /// Whether the existential requires a class, either via an explicit
diff --git a/include/swift/Migrator/Replacement.h b/include/swift/Migrator/Replacement.h
index e8a7f7c..ab51d8e 100644
--- a/include/swift/Migrator/Replacement.h
+++ b/include/swift/Migrator/Replacement.h
@@ -24,13 +24,9 @@
     return Remove > 0;
   }
 
-  bool isInsert() const {
-    return Remove == 0 && Text.size() > 0;
-  }
+  bool isInsert() const { return Remove == 0 && !Text.empty(); }
 
-  bool isReplace() const {
-    return Remove > 0 && Text.size() > 0;
-  }
+  bool isReplace() const { return Remove > 0 && !Text.empty(); }
 
   size_t endOffset() const {
     if (isInsert()) {
diff --git a/include/swift/SIL/SILFunction.h b/include/swift/SIL/SILFunction.h
index 3daab84..668c350 100644
--- a/include/swift/SIL/SILFunction.h
+++ b/include/swift/SIL/SILFunction.h
@@ -473,7 +473,7 @@
   /// \returns True if the function is marked with the @_semantics attribute
   /// and has special semantics that the optimizer can use to optimize the
   /// function.
-  bool hasSemanticsAttrs() const { return SemanticsAttrSet.size() > 0; }
+  bool hasSemanticsAttrs() const { return !SemanticsAttrSet.empty(); }
 
   /// \returns True if the function has a semantic attribute that starts with a
   /// specific string.
diff --git a/include/swift/SILOptimizer/Analysis/ClassHierarchyAnalysis.h b/include/swift/SILOptimizer/Analysis/ClassHierarchyAnalysis.h
index fbc5109..76f6ec6 100644
--- a/include/swift/SILOptimizer/Analysis/ClassHierarchyAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/ClassHierarchyAnalysis.h
@@ -93,7 +93,7 @@
   /// in this module.
   bool hasKnownIndirectSubclasses(ClassDecl *C) {
     return IndirectSubclassesCache.count(C) &&
-           IndirectSubclassesCache[C].size() > 0;
+           !IndirectSubclassesCache[C].empty();
   }
 
   /// Returns true if the protocol is implemented by any class in this module.
diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp
index 39128d3..ddc5cc7 100644
--- a/lib/AST/ASTMangler.cpp
+++ b/lib/AST/ASTMangler.cpp
@@ -1609,7 +1609,7 @@
       else
         appendOperator("_");
     }
-  } else if (parameters.size() > 0) {
+  } else if (!parameters.empty()) {
     appendOperator("y");
   }
 
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 53255a2..69cebce 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1090,7 +1090,7 @@
 VarDecl *PatternBindingEntry::getAnchoringVarDecl() const {
   SmallVector<VarDecl *, 8> variables;
   getPattern()->collectVariables(variables);
-  assert(variables.size() > 0);
+  assert(!variables.empty());
   return variables[0];
 }
 
@@ -1685,8 +1685,8 @@
   // If one is a compound name and the other is not, they do not conflict
   // if one is a property and the other is a non-nullary function.
   if (sig1.Name.isCompoundName() != sig2.Name.isCompoundName()) {
-    return !((sig1.IsProperty && sig2.Name.getArgumentNames().size() > 0) ||
-             (sig2.IsProperty && sig1.Name.getArgumentNames().size() > 0));
+    return !((sig1.IsProperty && !sig2.Name.getArgumentNames().empty()) ||
+             (sig2.IsProperty && !sig1.Name.getArgumentNames().empty()));
   }
   
   return sig1.Name == sig2.Name;
diff --git a/lib/AST/Identifier.cpp b/lib/AST/Identifier.cpp
index e75142a..35f6674 100644
--- a/lib/AST/Identifier.cpp
+++ b/lib/AST/Identifier.cpp
@@ -157,7 +157,7 @@
   if (skipEmptyArgumentNames) {
     // If there is more than one argument yet none of them have names,
     // we're done.
-    if (getArgumentNames().size() > 0) {
+    if (!getArgumentNames().empty()) {
       bool anyNonEmptyNames = false;
       for (auto c : getArgumentNames()) {
         if (!c.empty()) {
diff --git a/lib/AST/NameLookupImpl.h b/lib/AST/NameLookupImpl.h
index 4426ab9..447e696 100644
--- a/lib/AST/NameLookupImpl.h
+++ b/lib/AST/NameLookupImpl.h
@@ -225,7 +225,7 @@
         }
       }
     }
-    if (!inPatterns && items.size() > 0)
+    if (!inPatterns && !items.empty())
       checkPattern(items[0].getPattern(), DeclVisibilityKind::LocalVariable);
     visit(body);
   }
diff --git a/lib/Basic/Unix/TaskQueue.inc b/lib/Basic/Unix/TaskQueue.inc
index 28e78d1..45b00e0 100644
--- a/lib/Basic/Unix/TaskQueue.inc
+++ b/lib/Basic/Unix/TaskQueue.inc
@@ -346,7 +346,7 @@
       ExecutingTasks[Pid] = std::move(T);
     }
 
-    assert(PollFds.size() > 0 &&
+    assert(!PollFds.empty() &&
            "We should only call poll() if we have fds to watch!");
     int ReadyFdCount = poll(PollFds.data(), PollFds.size(), -1);
     if (ReadyFdCount == -1) {
diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp
index b2d18ca..b43cc42 100644
--- a/lib/ClangImporter/ClangImporter.cpp
+++ b/lib/ClangImporter/ClangImporter.cpp
@@ -3402,8 +3402,7 @@
   // prohibitively complex (also they're not stored in by-name lookup, for
   // reasons unclear).
   if (forEachLookupTable([&](SwiftLookupTable &table) -> bool {
-        return (table.lookupGlobalsAsMembers(
-                  effectiveClangContext).size() > 0);
+        return (!table.lookupGlobalsAsMembers(effectiveClangContext).empty());
       }))
     return None;
 
diff --git a/lib/Demangling/Demangler.cpp b/lib/Demangling/Demangler.cpp
index ec1b8c0..ae82735 100644
--- a/lib/Demangling/Demangler.cpp
+++ b/lib/Demangling/Demangler.cpp
@@ -1895,8 +1895,8 @@
           return nullptr;
         StringRef Text = Name->getText();
         if (ParamKind ==
-              FunctionSigSpecializationParamKind::ConstantPropString &&
-            Text.size() > 0 && Text[0] == '_') {
+                FunctionSigSpecializationParamKind::ConstantPropString &&
+            !Text.empty() && Text[0] == '_') {
           // A '_' escapes a leading digit or '_' of a string constant.
           Text = Text.drop_front(1);
         }
diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp
index 78359cf..0090b6b 100644
--- a/lib/Demangling/Remangler.cpp
+++ b/lib/Demangling/Remangler.cpp
@@ -414,7 +414,7 @@
     Buffer << ListSeparator;
     ListSeparator = "";
   }
-  if (Chain.size() > 0)
+  if (!Chain.empty())
     addSubstitution(entry);
   return {(int)Chain.size(), node};
 }
@@ -922,7 +922,7 @@
         case FunctionSigSpecializationParamKind::ConstantPropString: {
           NodePointer TextNd = Param->getChild(2);
           StringRef Text = TextNd->getText();
-          if (Text.size() > 0 && (isDigit(Text[0]) || Text[0] == '_')) {
+          if (!Text.empty() && (isDigit(Text[0]) || Text[0] == '_')) {
             std::string Buffer = "_";
             Buffer.append(Text.data(), Text.size());
             TextNd = Factory.createNode(Node::Kind::Identifier, Buffer);
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp
index c670583..78107c0 100644
--- a/lib/Driver/Compilation.cpp
+++ b/lib/Driver/Compilation.cpp
@@ -761,7 +761,7 @@
         llvm::outs() << "Forming into " << Partition.size() << " batches\n";
       }
 
-      assert(Partition.size() > 0);
+      assert(!Partition.empty());
       maybeShuffleBatchable(Batchable);
 
       size_t i = 0;
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index bb5654b..54130b1 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -84,7 +84,7 @@
   std::string OptName;
   // However, the driver kind may be overridden if the first argument is
   // --driver-mode.
-  if (Args.size() > 0) {
+  if (!Args.empty()) {
     OptName = getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
 
     StringRef FirstArg(Args[0]);
diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp
index e99f468..40f726a 100644
--- a/lib/IDE/CodeCompletion.cpp
+++ b/lib/IDE/CodeCompletion.cpp
@@ -2855,7 +2855,7 @@
 
     // Add the argument labels.
     auto ArgLabels = AFD->getFullName().getArgumentNames();
-    if (ArgLabels.size() > 0) {
+    if (!ArgLabels.empty()) {
       if (!HaveLParen)
         Builder.addLeftParen();
       else
diff --git a/lib/IDE/TypeReconstruction.cpp b/lib/IDE/TypeReconstruction.cpp
index d894a1b..54be882 100644
--- a/lib/IDE/TypeReconstruction.cpp
+++ b/lib/IDE/TypeReconstruction.cpp
@@ -88,7 +88,7 @@
       m_decls.push_back(VD);
     }
     ~VisibleDeclsConsumer() override = default;
-    explicit operator bool() { return m_decls.size() > 0; }
+    explicit operator bool() { return !m_decls.empty(); }
 
     decltype(m_decls)::const_iterator begin() { return m_decls.begin(); }
 
@@ -1540,7 +1540,7 @@
 
     if (decl_ctx_result._decls.size() == 1) {
       var_decl = dyn_cast_or_null<VarDecl>(decl_ctx_result._decls[0]);
-    } else if (decl_ctx_result._decls.size() > 0) {
+    } else if (!decl_ctx_result._decls.empty()) {
       // TODO: can we use the type to pick the right one? can we really have
       // multiple variables with the same name?
       result._error = stringWithFormat(
@@ -1901,7 +1901,7 @@
     }
 
     if (protocol_types_result._error.empty() &&
-        protocol_types_result._types.size() > 0 &&
+        !protocol_types_result._types.empty() &&
         class_type_result._types.size() == 1) {
       SmallVector<Type, 2> members;
       members.push_back(class_type_result._types.front());
diff --git a/lib/IRGen/GenEnum.cpp b/lib/IRGen/GenEnum.cpp
index f07f4c9..f0efd44 100644
--- a/lib/IRGen/GenEnum.cpp
+++ b/lib/IRGen/GenEnum.cpp
@@ -296,7 +296,7 @@
       // - -1 -- if we have a payload
       // -  0 -- if there's no payload
       return llvm::ConstantInt::get(IGF.IGM.Int32Ty,
-          ElementsWithPayload.size() > 0 ? -1 : 0);
+                                    !ElementsWithPayload.empty() ? -1 : 0);
     }
 
     llvm::Value *
@@ -3502,7 +3502,7 @@
       
     found_empty_case:
       llvm::Value *match = IGF.Builder.CreateICmpEQ(parts.tag, tagValue);
-      if (CommonSpareBits.size() > 0) {
+      if (!CommonSpareBits.empty()) {
         auto payloadMatch = parts.payload
           .emitCompare(IGF, APInt::getAllOnesValue(CommonSpareBits.size()),
                        payloadValue);
@@ -3843,7 +3843,7 @@
         // If we have spare bits, pack the tag into the spare bits and
         // the tagIndex into the payload.
         payload = getEmptyCasePayload(IGM, tag, tagIndex);
-      } else if (CommonSpareBits.size() > 0) {
+      } else if (!CommonSpareBits.empty()) {
         // Otherwise the payload is just the index.
         payload = APInt(CommonSpareBits.size(), tagIndex);
       }
@@ -3886,7 +3886,7 @@
         // If we have spare bits, pack the tag into the spare bits and
         // the tagIndex into the payload.
         payload = getEmptyCasePayload(IGF, tag, tagIndex);
-      } else if (CommonSpareBits.size() > 0) {
+      } else if (!CommonSpareBits.empty()) {
         // Otherwise the payload is just the index.
         payload = EnumPayload::zero(IGM, PayloadSchema);
 #if defined(__BIG_ENDIAN__) && defined(__LP64__)
@@ -4755,8 +4755,8 @@
 
       std::tie(payloadPart, extraPart) = getNoPayloadCaseValue(index);
       ClusteredBitVector bits;
-      
-      if (CommonSpareBits.size() > 0)
+
+      if (!CommonSpareBits.empty())
         bits = getBitVectorFromAPInt(payloadPart);
 
       unsigned totalSize
diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp
index 236f9db..3ed7bce 100644
--- a/lib/IRGen/GenMeta.cpp
+++ b/lib/IRGen/GenMeta.cpp
@@ -436,9 +436,9 @@
   // Grab the substitutions.
   GenericArguments genericArgs;
   genericArgs.collect(IGF, theType);
-  assert((genericArgs.Values.size() > 0 ||
-          theDecl->getGenericSignature()->areAllParamsConcrete())
-         && "no generic args?!");
+  assert((!genericArgs.Values.empty() ||
+          theDecl->getGenericSignature()->areAllParamsConcrete()) &&
+         "no generic args?!");
 
   // Call the generic metadata accessor function.
   llvm::Function *accessor =
@@ -1302,9 +1302,9 @@
     callerArgArray = &arg;
   }
 
-  assert((genericArgs.Values.size() > 0 ||
-          nominal->getGenericSignature()->areAllParamsConcrete())
-         && "no generic args?!");
+  assert((!genericArgs.Values.empty() ||
+          nominal->getGenericSignature()->areAllParamsConcrete()) &&
+         "no generic args?!");
 
   Address argsBuffer;
   if (callerArgArray) {
diff --git a/lib/IRGen/GenValueWitness.cpp b/lib/IRGen/GenValueWitness.cpp
index c8cea57..5a823d1 100644
--- a/lib/IRGen/GenValueWitness.cpp
+++ b/lib/IRGen/GenValueWitness.cpp
@@ -605,7 +605,7 @@
     llvm::Value *value = getArg(argv, "value");
     getArgAsLocalSelfTypeMetadata(IGF, argv, abstractType);
 
-    if (strategy.getElementsWithPayload().size() > 0) {
+    if (!strategy.getElementsWithPayload().empty()) {
       strategy.destructiveProjectDataForLoad(
           IGF, concreteType,
           Address(value, type.getBestKnownAlignment()));
diff --git a/lib/LLVMPasses/LLVMInlineTree.cpp b/lib/LLVMPasses/LLVMInlineTree.cpp
index 0392659..57095d2 100644
--- a/lib/LLVMPasses/LLVMInlineTree.cpp
+++ b/lib/LLVMPasses/LLVMInlineTree.cpp
@@ -117,7 +117,7 @@
     bool isTopLevel = false;
 
     const NodeList &getChildren() {
-      if (SortedChildren.empty() && UnsortedChildren.size() > 0)
+      if (SortedChildren.empty() && !UnsortedChildren.empty())
         sortNodes(UnsortedChildren, SortedChildren);
       return SortedChildren;
     }
diff --git a/lib/Parse/Lexer.cpp b/lib/Parse/Lexer.cpp
index 4200e23..66829cd 100644
--- a/lib/Parse/Lexer.cpp
+++ b/lib/Parse/Lexer.cpp
@@ -1541,9 +1541,9 @@
     // These lines were valid; there's nothing to correct.
     return;
   }
-  
-  assert(LineStarts.size() > 0);
-  
+
+  assert(!LineStarts.empty());
+
   auto getLoc = [&](size_t offset) -> SourceLoc {
     return Lexer::getSourceLoc((const char *)Bytes.bytes_begin() + offset);
   };
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 2490296..cbc527d 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -290,7 +290,7 @@
           CodeCompletion->completeAssignmentRHS(assign);
         }
         consumeToken();
-        if (SequencedExprs.size() > 0 && (SequencedExprs.size() & 1) == 0) {
+        if (!SequencedExprs.empty() && (SequencedExprs.size() & 1) == 0) {
           // Make sure we have odd number of sequence exprs.
           SequencedExprs.pop_back();
         }
@@ -3189,7 +3189,7 @@
     diag.fixItReplaceChars(Range.getStart(), Range.getEnd(), NewName);
 
     // Try and construct a FixIt for the argument label.
-    if (argLabelLocs.size() > 0 && !argLabels[0].empty()) {
+    if (!argLabelLocs.empty() && !argLabels[0].empty()) {
       auto ArgLoc = argLabelLocs[0];
       auto FirstElementName = argLabels[0];
             
diff --git a/lib/ParseSIL/ParseSIL.cpp b/lib/ParseSIL/ParseSIL.cpp
index 6f41149..16740a8 100644
--- a/lib/ParseSIL/ParseSIL.cpp
+++ b/lib/ParseSIL/ParseSIL.cpp
@@ -3605,7 +3605,7 @@
     if (parseSILDebugLocation(InstLoc, B))
       return true;
 
-    if (IsObjC && ElementTypes.size() != 0) {
+    if (IsObjC && !ElementTypes.empty()) {
       P.diagnose(P.Tok, diag::sil_objc_with_tail_elements);
       return true;
     }
diff --git a/lib/PrintAsObjC/PrintAsObjC.cpp b/lib/PrintAsObjC/PrintAsObjC.cpp
index 912a35f..8eb8524 100644
--- a/lib/PrintAsObjC/PrintAsObjC.cpp
+++ b/lib/PrintAsObjC/PrintAsObjC.cpp
@@ -2019,7 +2019,7 @@
       return true;
 
     auto conformsTo = sig->getConformsTo(paramTy);
-    return conformsTo.size() > 0;
+    return !conformsTo.empty();
   }
 
   void visitBoundGenericType(BoundGenericType *boundGeneric) {
diff --git a/lib/SIL/SILPrinter.cpp b/lib/SIL/SILPrinter.cpp
index 0e08f8c..9f14596 100644
--- a/lib/SIL/SILPrinter.cpp
+++ b/lib/SIL/SILPrinter.cpp
@@ -1549,7 +1549,7 @@
     interleave(OI->getBaseElements(),
                [&](const SILValue &V) { *this << getIDAndType(V); },
                [&] { *this << ", "; });
-    if (OI->getTailElements().size() > 0) {
+    if (!OI->getTailElements().empty()) {
       *this << ", [tail_elems] ";
       interleave(OI->getTailElements(),
                  [&](const SILValue &V) { *this << getIDAndType(V); },
diff --git a/lib/SILOptimizer/Mandatory/DiagnoseUnreachable.cpp b/lib/SILOptimizer/Mandatory/DiagnoseUnreachable.cpp
index 4689182..751b88e 100644
--- a/lib/SILOptimizer/Mandatory/DiagnoseUnreachable.cpp
+++ b/lib/SILOptimizer/Mandatory/DiagnoseUnreachable.cpp
@@ -143,7 +143,7 @@
     }
 
     // After the first branch is processed, the arguments vector is populated.
-    assert(Args.size() > 0);
+    assert(!Args.empty());
     checkArgs = true;
   }
 
diff --git a/lib/SILOptimizer/Transforms/ObjectOutliner.cpp b/lib/SILOptimizer/Transforms/ObjectOutliner.cpp
index 2fc602b..7b846a8 100644
--- a/lib/SILOptimizer/Transforms/ObjectOutliner.cpp
+++ b/lib/SILOptimizer/Transforms/ObjectOutliner.cpp
@@ -286,7 +286,7 @@
   ArrayRef<Operand> TailCounts = ARI->getTailAllocatedCounts();
   SILType TailType;
   unsigned NumTailElems = 0;
-  if (TailCounts.size() > 0) {
+  if (!TailCounts.empty()) {
     // We only support a single tail allocated array.
     if (TailCounts.size() > 1)
       return false;
diff --git a/lib/SILOptimizer/Utils/SpecializationMangler.cpp b/lib/SILOptimizer/Utils/SpecializationMangler.cpp
index 4e4af44..591a1ea 100644
--- a/lib/SILOptimizer/Utils/SpecializationMangler.cpp
+++ b/lib/SILOptimizer/Utils/SpecializationMangler.cpp
@@ -211,7 +211,7 @@
     StringRef V = SLI->getValue();
     assert(V.size() <= 32 && "Cannot encode string of length > 32");
     std::string VBuffer;
-    if (V.size() > 0 && (isDigit(V[0]) || V[0] == '_')) {
+    if (!V.empty() && (isDigit(V[0]) || V[0] == '_')) {
       VBuffer = "_";
       VBuffer.append(V.data(), V.size());
       V = VBuffer;
diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp
index 4484168..badfe3f 100644
--- a/lib/Sema/CSApply.cpp
+++ b/lib/Sema/CSApply.cpp
@@ -7834,7 +7834,7 @@
     // If we're performing pattern matching, "as" means something completely different...
     if (auto binOpExpr = dyn_cast<BinaryExpr>(expr)) {
       auto overloadedFn = dyn_cast<OverloadedDeclRefExpr>(binOpExpr->getFn());
-      if (overloadedFn && overloadedFn->getDecls().size() > 0) {
+      if (overloadedFn && !overloadedFn->getDecls().empty()) {
         ValueDecl *decl0 = overloadedFn->getDecls()[0];
         if (decl0->getBaseName() == decl0->getASTContext().Id_MatchOperator)
           return false;
@@ -8132,7 +8132,7 @@
     // they are invalid or there are no arguments.
     SourceLoc TupleStartLoc = base->getStartLoc();
     SourceLoc TupleEndLoc = base->getEndLoc();
-    if (arguments.size() > 0) {
+    if (!arguments.empty()) {
       SourceLoc AltStartLoc = arguments.front()->getStartLoc();
       SourceLoc AltEndLoc = arguments.back()->getEndLoc();
       if (AltStartLoc.isValid() && AltEndLoc.isValid()) {
diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp
index 2c7b288..0318c5b 100644
--- a/lib/Sema/CSDiag.cpp
+++ b/lib/Sema/CSDiag.cpp
@@ -1293,7 +1293,7 @@
   if (auto binaryExpr = dyn_cast<BinaryExpr>(contextualTypeNode)) {
     if (auto overloadedFn
           = dyn_cast<OverloadedDeclRefExpr>(binaryExpr->getFn())) {
-      if (overloadedFn->getDecls().size() > 0) {
+      if (!overloadedFn->getDecls().empty()) {
         // Fetch any declaration to check if the name is '~='
         ValueDecl *decl0 = overloadedFn->getDecls()[0];
 
diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp
index ae6f86e..548bbe7 100644
--- a/lib/Sema/MiscDiagnostics.cpp
+++ b/lib/Sema/MiscDiagnostics.cpp
@@ -3330,7 +3330,7 @@
 
         // Only print the parentheses if there are some argument
         // names, because "()" would indicate a call.
-        if (argNames.size() > 0) {
+        if (!argNames.empty()) {
           out << "(";
           for (auto argName : argNames) {
             if (argName.empty()) out << "_";
diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp
index fd29f85..abb988d 100644
--- a/lib/Sema/TypeCheckAvailability.cpp
+++ b/lib/Sema/TypeCheckAvailability.cpp
@@ -928,7 +928,7 @@
     // PatternBindingDecl are added to all of the VarDecls for the pattern
     // binding.
     ArrayRef<PatternBindingEntry> Entries = PBD->getPatternList();
-    if (Entries.size() > 0) {
+    if (!Entries.empty()) {
       VarDecl *VD = Entries.front().getPattern()->getSingleVar();
       if (VD)
         return VD;
@@ -937,7 +937,7 @@
     // Similar to the PatternBindingDecl case above, we return the
     // first EnumElementDecl.
     ArrayRef<EnumElementDecl *> Elems = ECD->getElements();
-    if (Elems.size() > 0) {
+    if (!Elems.empty()) {
       return Elems.front();
     }
   }
diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp
index 53f2dc0..36c2746 100644
--- a/lib/Serialization/SerializeSIL.cpp
+++ b/lib/Serialization/SerializeSIL.cpp
@@ -339,7 +339,7 @@
 }
 
 void SILSerializer::processSILFunctionWorklist() {
-  while (Worklist.size() > 0) {
+  while (!Worklist.empty()) {
     const SILFunction *F = Worklist.back();
     Worklist.pop_back();
     assert(F != nullptr);
diff --git a/tools/SourceKit/lib/Support/FuzzyStringMatcher.cpp b/tools/SourceKit/lib/Support/FuzzyStringMatcher.cpp
index fd1fc75..463d541 100644
--- a/tools/SourceKit/lib/Support/FuzzyStringMatcher.cpp
+++ b/tools/SourceKit/lib/Support/FuzzyStringMatcher.cpp
@@ -496,7 +496,7 @@
   trialScore += patternLength / static_cast<double>(baseNameLength) * 0.25;
 
   // Exact matches are even better.
-  if (patternLength >= baseNameLength && runs.size() > 0 &&
+  if (patternLength >= baseNameLength && !runs.empty() &&
       runs[0].location == 0) {
     trialScore *= 1.1;
   }
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index 341c880..b3684a7 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -71,7 +71,7 @@
 static bool shouldRunAsSubcommand(StringRef ExecName,
                                   SmallString<256> &SubcommandName,
                                   SmallVectorImpl<const char *> &Args) {
-  assert(Args.size() > 0);
+  assert(!Args.empty());
 
   // If we are not run as 'swift', don't do anything special. This doesn't work
   // with symlinks with alternate names, but we can't detect 'swift' vs 'swiftc'