From: Alexander Kornienko Date: Fri, 23 Jan 2015 15:36:10 +0000 (+0000) Subject: Replace size() calls on containers with empty() calls where appropriate. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8785e3e9a01de095f794d7f81ea00e70a337dee0;p=clang Replace size() calls on containers with empty() calls where appropriate. NFC http://reviews.llvm.org/D7090 Patch by Gábor Horváth! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226914 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/examples/PrintFunctionNames/PrintFunctionNames.cpp b/examples/PrintFunctionNames/PrintFunctionNames.cpp index e8a361dbee..b554caeb2a 100644 --- a/examples/PrintFunctionNames/PrintFunctionNames.cpp +++ b/examples/PrintFunctionNames/PrintFunctionNames.cpp @@ -55,7 +55,7 @@ protected: return false; } } - if (args.size() && args[0] == "help") + if (!args.empty() && args[0] == "help") PrintHelp(llvm::errs()); return true; diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index ec93bc80af..ead6bd62a6 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -432,7 +432,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { BackendArgs.data()); std::string FeaturesStr; - if (TargetOpts.Features.size()) { + if (!TargetOpts.Features.empty()) { SubtargetFeatures Features; for (std::vector::const_iterator it = TargetOpts.Features.begin(), diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index c0dc3b8002..da95260123 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -2366,7 +2366,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { std::vector Elements; llvm::Constant *Statics = NULLPtr; // Generate statics list: - if (ConstantStrings.size()) { + if (!ConstantStrings.empty()) { llvm::ArrayType *StaticsArrayTy = llvm::ArrayType::get(PtrToInt8Ty, ConstantStrings.size() + 1); ConstantStrings.push_back(NULLPtr); diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 2625ae1fdc..b8e44a2124 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -6945,7 +6945,7 @@ CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { CXTUResourceUsage usage = { (void*) entries.get(), (unsigned) entries->size(), - entries->size() ? &(*entries)[0] : nullptr }; + !entries->empty() ? &(*entries)[0] : nullptr }; entries.release(); return usage; } diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index a73be2e081..83629ec360 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -1207,7 +1207,7 @@ writePrettyPrintFunction(Record &R, static unsigned getSpellingListIndex(const std::vector &SpellingList, const FlattenedSpelling &Spelling) { - assert(SpellingList.size() && "Spelling list is empty!"); + assert(!SpellingList.empty() && "Spelling list is empty!"); for (unsigned Index = 0; Index < SpellingList.size(); ++Index) { const FlattenedSpelling &S = SpellingList[Index]; @@ -1231,7 +1231,7 @@ static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) { std::vector Spellings = GetFlattenedSpellings(*Accessor); std::vector SpellingList = GetFlattenedSpellings(R); - assert(SpellingList.size() && + assert(!SpellingList.empty() && "Attribute with empty spelling list can't have accessors!"); OS << " bool " << Name << "() const { return SpellingListIndex == "; diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp index a8e8e39419..d243672119 100644 --- a/utils/TableGen/NeonEmitter.cpp +++ b/utils/TableGen/NeonEmitter.cpp @@ -1393,7 +1393,7 @@ void Intrinsic::emitBody(StringRef CallPrefix) { } } - assert(Lines.size() && "Empty def?"); + assert(!Lines.empty() && "Empty def?"); if (!RetVar.getType().isVoid()) Lines.back().insert(0, RetVar.getName() + " = ");