Index: clang/include/clang/AST/OpenMPClause.h =================================================================== --- clang/include/clang/AST/OpenMPClause.h +++ clang/include/clang/AST/OpenMPClause.h @@ -5772,12 +5772,11 @@ /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo), MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { - assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && + assert(llvm::size(MapTypeModifiers) == MapModifiers.size() && "Unexpected number of map type modifiers."); llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); - assert(llvm::array_lengthof(MapTypeModifiersLoc) == - MapModifiersLoc.size() && + assert(llvm::size(MapTypeModifiersLoc) == MapModifiersLoc.size() && "Unexpected number of map type modifier locations."); llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); } @@ -6694,12 +6693,11 @@ : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { - assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && + assert(llvm::size(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); - assert(llvm::array_lengthof(MotionModifiersLoc) == - TheMotionModifiersLoc.size() && + assert(llvm::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); } @@ -6896,12 +6894,11 @@ : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { - assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && + assert(llvm::size(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); - assert(llvm::array_lengthof(MotionModifiersLoc) == - TheMotionModifiersLoc.size() && + assert(llvm::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); } Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -6594,7 +6594,7 @@ uint64_t FromSize = getTypeSize(BT); QualType PromoteTypes[] = { IntTy, UnsignedIntTy, LongTy, UnsignedLongTy, LongLongTy, UnsignedLongLongTy }; - for (size_t Idx = 0; Idx < llvm::array_lengthof(PromoteTypes); ++Idx) { + for (size_t Idx = 0; Idx < llvm::size(PromoteTypes); ++Idx) { uint64_t ToSize = getTypeSize(PromoteTypes[Idx]); if (FromSize < ToSize || (FromSize == ToSize && Index: clang/lib/AST/AttrDocTable.cpp =================================================================== --- clang/lib/AST/AttrDocTable.cpp +++ clang/lib/AST/AttrDocTable.cpp @@ -21,7 +21,7 @@ }; llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) { - if(K < llvm::array_lengthof(AttrDoc)) + if (K < llvm::size(AttrDoc)) return AttrDoc[K]; return ""; } Index: clang/lib/AST/CommentCommandTraits.cpp =================================================================== --- clang/lib/AST/CommentCommandTraits.cpp +++ clang/lib/AST/CommentCommandTraits.cpp @@ -16,8 +16,8 @@ #include "clang/AST/CommentCommandInfo.inc" CommandTraits::CommandTraits(llvm::BumpPtrAllocator &Allocator, - const CommentOptions &CommentOptions) : - NextID(llvm::array_lengthof(Commands)), Allocator(Allocator) { + const CommentOptions &CommentOptions) + : NextID(llvm::size(Commands)), Allocator(Allocator) { registerCommentOptions(CommentOptions); } @@ -115,7 +115,7 @@ const CommandInfo *CommandTraits::getBuiltinCommandInfo( unsigned CommandID) { - if (CommandID < llvm::array_lengthof(Commands)) + if (CommandID < llvm::size(Commands)) return &Commands[CommandID]; return nullptr; } @@ -131,7 +131,7 @@ const CommandInfo *CommandTraits::getRegisteredCommandInfo( unsigned CommandID) const { - return RegisteredCommands[CommandID - llvm::array_lengthof(Commands)]; + return RegisteredCommands[CommandID - llvm::size(Commands)]; } } // end namespace comments Index: clang/lib/Basic/DiagnosticIDs.cpp =================================================================== --- clang/lib/Basic/DiagnosticIDs.cpp +++ clang/lib/Basic/DiagnosticIDs.cpp @@ -202,7 +202,7 @@ } // namespace -static const unsigned StaticDiagInfoSize = llvm::array_lengthof(StaticDiagInfo); +static const unsigned StaticDiagInfoSize = llvm::size(StaticDiagInfo); /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID, /// or null if the ID is invalid. @@ -317,7 +317,7 @@ /// getNumberOfCategories - Return the number of categories unsigned DiagnosticIDs::getNumberOfCategories() { - return llvm::array_lengthof(CategoryNameTable) - 1; + return llvm::size(CategoryNameTable) - 1; } /// getCategoryNameFromID - Given a category ID, return the name of the Index: clang/lib/Basic/Targets/NVPTX.h =================================================================== --- clang/lib/Basic/Targets/NVPTX.h +++ clang/lib/Basic/Targets/NVPTX.h @@ -159,7 +159,7 @@ /// DWARF. Optional getDWARFAddressSpace(unsigned AddressSpace) const override { - if (AddressSpace >= llvm::array_lengthof(NVPTXDWARFAddrSpaceMap) || + if (AddressSpace >= llvm::size(NVPTXDWARFAddrSpaceMap) || NVPTXDWARFAddrSpaceMap[AddressSpace] < 0) return llvm::None; return NVPTXDWARFAddrSpaceMap[AddressSpace]; Index: clang/lib/CodeGen/CGExpr.cpp =================================================================== --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3206,7 +3206,7 @@ assert(IsSanitizerScope); assert(Checked.size() > 0); assert(CheckHandler >= 0 && - size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers)); + size_t(CheckHandler) < llvm::size(SanitizerHandlers)); const StringRef CheckName = SanitizerHandlers[CheckHandler].Name; llvm::Value *FatalCond = nullptr; Index: clang/lib/CodeGen/CGObjC.cpp =================================================================== --- clang/lib/CodeGen/CGObjC.cpp +++ clang/lib/CodeGen/CGObjC.cpp @@ -1749,7 +1749,7 @@ &CGM.getContext().Idents.get("count") }; Selector FastEnumSel = - CGM.getContext().Selectors.getSelector(llvm::array_lengthof(II), &II[0]); + CGM.getContext().Selectors.getSelector(llvm::size(II), &II[0]); QualType ItemsTy = getContext().getConstantArrayType(getContext().getObjCIdType(), Index: clang/lib/Driver/Compilation.cpp =================================================================== --- clang/lib/Driver/Compilation.cpp +++ clang/lib/Driver/Compilation.cpp @@ -278,7 +278,7 @@ options::OPT_o, options::OPT_MD, options::OPT_MMD, options::OPT_M, options::OPT_MM, options::OPT_MF, options::OPT_MG, options::OPT_MJ, options::OPT_MQ, options::OPT_MT, options::OPT_MV}; - for (unsigned i = 0, e = llvm::array_lengthof(OutputOpts); i != e; ++i) { + for (unsigned i = 0, e = llvm::size(OutputOpts); i != e; ++i) { if (TranslatedArgs->hasArg(OutputOpts[i])) TranslatedArgs->eraseArg(OutputOpts[i]); } Index: clang/lib/Driver/ToolChain.cpp =================================================================== --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -151,7 +151,7 @@ {"flang", "--driver-mode=flang"}, }; - for (size_t i = 0; i < llvm::array_lengthof(DriverSuffixes); ++i) { + for (size_t i = 0; i < llvm::size(DriverSuffixes); ++i) { StringRef Suffix(DriverSuffixes[i].Suffix); if (ProgName.endswith(Suffix)) { Pos = ProgName.size() - Suffix.size(); Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -1694,7 +1694,7 @@ "TVOS_DEPLOYMENT_TARGET", "WATCHOS_DEPLOYMENT_TARGET", }; - static_assert(llvm::array_lengthof(EnvVars) == Darwin::LastDarwinPlatform + 1, + static_assert(llvm::size(EnvVars) == Darwin::LastDarwinPlatform + 1, "Missing platform"); for (const auto &I : llvm::enumerate(llvm::makeArrayRef(EnvVars))) { if (char *Env = ::getenv(I.value())) @@ -1715,11 +1715,11 @@ Targets[Darwin::TvOS] = ""; } else { // Don't allow conflicts in any other platform. - unsigned FirstTarget = llvm::array_lengthof(Targets); - for (unsigned I = 0; I != llvm::array_lengthof(Targets); ++I) { + unsigned FirstTarget = llvm::size(Targets); + for (unsigned I = 0; I != llvm::size(Targets); ++I) { if (Targets[I].empty()) continue; - if (FirstTarget == llvm::array_lengthof(Targets)) + if (FirstTarget == llvm::size(Targets)) FirstTarget = I; else TheDriver.Diag(diag::err_drv_conflicting_deployment_targets) Index: clang/lib/Driver/Types.cpp =================================================================== --- clang/lib/Driver/Types.cpp +++ clang/lib/Driver/Types.cpp @@ -42,7 +42,7 @@ #include "clang/Driver/Types.def" #undef TYPE }; -static const unsigned numTypes = llvm::array_lengthof(TypeInfos); +static const unsigned numTypes = llvm::size(TypeInfos); static const TypeInfo &getInfo(unsigned id) { assert(id > 0 && id - 1 < numTypes && "Invalid Type ID."); Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp =================================================================== --- clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -863,7 +863,7 @@ } else if (Tok.isLiteral() && !Tok.needsCleaning() && Tok.getLiteralData()) { OS.write(Tok.getLiteralData(), Tok.getLength()); - } else if (Tok.getLength() < llvm::array_lengthof(Buffer)) { + } else if (Tok.getLength() < llvm::size(Buffer)) { const char *TokPtr = Buffer; unsigned Len = PP.getSpelling(Tok, TokPtr); OS.write(TokPtr, Len); Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -1365,7 +1365,7 @@ ArgsUnion Args[] = {Language.get(), DefinedInExpr.get(), GeneratedDeclaration}; Attrs.addNew(&ExternalSourceSymbol, SourceRange(Loc, T.getCloseLocation()), - ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax); + ScopeName, ScopeLoc, Args, llvm::size(Args), Syntax); } /// Parse the contents of the "objc_bridge_related" attribute. @@ -1493,7 +1493,7 @@ ArgsUnion Args[] = {SwiftType}; Attrs.addNew(&AttrName, SourceRange(AttrNameLoc, T.getCloseLocation()), - ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax); + ScopeName, ScopeLoc, Args, llvm::size(Args), Syntax); } Index: clang/lib/Parse/ParseOpenMP.cpp =================================================================== --- clang/lib/Parse/ParseOpenMP.cpp +++ clang/lib/Parse/ParseOpenMP.cpp @@ -188,7 +188,7 @@ if (DKind == OMPD_unknown) return OMPD_unknown; - for (unsigned I = 0; I < llvm::array_lengthof(F); ++I) { + for (unsigned I = 0; I < llvm::size(F); ++I) { if (DKind != F[I][0]) continue; Index: clang/lib/Sema/DeclSpec.cpp =================================================================== --- clang/lib/Sema/DeclSpec.cpp +++ clang/lib/Sema/DeclSpec.cpp @@ -238,7 +238,7 @@ // is already used (consider a function returning a function pointer) or too // small (function with too many parameters), go to the heap. if (!TheDeclarator.InlineStorageUsed && - NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) { + NumParams <= llvm::size(TheDeclarator.InlineParams)) { I.Fun.Params = TheDeclarator.InlineParams; new (I.Fun.Params) ParamInfo[NumParams]; I.Fun.DeleteParams = false; @@ -307,8 +307,7 @@ // Allocate storage for bindings and stash them away. if (Bindings.size()) { - if (!InlineStorageUsed && - Bindings.size() <= llvm::array_lengthof(InlineBindings)) { + if (!InlineStorageUsed && Bindings.size() <= llvm::size(InlineBindings)) { BindingGroup.Bindings = InlineBindings; BindingGroup.DeleteBindings = false; InlineStorageUsed = true; Index: clang/lib/Sema/ParsedAttr.cpp =================================================================== --- clang/lib/Sema/ParsedAttr.cpp +++ clang/lib/Sema/ParsedAttr.cpp @@ -111,7 +111,7 @@ const ParsedAttrInfo &ParsedAttrInfo::get(const AttributeCommonInfo &A) { // If we have a ParsedAttrInfo for this ParsedAttr then return that. - if ((size_t)A.getParsedKind() < llvm::array_lengthof(AttrInfoMap)) + if ((size_t)A.getParsedKind() < llvm::size(AttrInfoMap)) return *AttrInfoMap[A.getParsedKind()]; // If this is an ignored attribute then return an appropriate ParsedAttrInfo. Index: clang/lib/Sema/SemaLookup.cpp =================================================================== --- clang/lib/Sema/SemaLookup.cpp +++ clang/lib/Sema/SemaLookup.cpp @@ -4726,7 +4726,7 @@ "extern", "inline", "static", "typedef" }; - const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs); + const unsigned NumCTypeSpecs = llvm::size(CTypeSpecs); for (unsigned I = 0; I != NumCTypeSpecs; ++I) Consumer.addKeywordResult(CTypeSpecs[I]); @@ -4780,7 +4780,7 @@ static const char *const CXXExprs[] = { "delete", "new", "operator", "throw", "typeid" }; - const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs); + const unsigned NumCXXExprs = llvm::size(CXXExprs); for (unsigned I = 0; I != NumCXXExprs; ++I) Consumer.addKeywordResult(CXXExprs[I]); @@ -4806,7 +4806,7 @@ // Statements. static const char *const CStmts[] = { "do", "else", "for", "goto", "if", "return", "switch", "while" }; - const unsigned NumCStmts = llvm::array_lengthof(CStmts); + const unsigned NumCStmts = llvm::size(CStmts); for (unsigned I = 0; I != NumCStmts; ++I) Consumer.addKeywordResult(CStmts[I]); Index: clang/lib/Sema/TreeTransform.h =================================================================== --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -14357,7 +14357,7 @@ SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy, SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty }; - const unsigned NumTypes = llvm::array_lengthof(Types); + const unsigned NumTypes = llvm::size(Types); QualType SizeType; for (unsigned I = 0; I != NumTypes; ++I) if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) { Index: clang/unittests/AST/CommentLexer.cpp =================================================================== --- clang/unittests/AST/CommentLexer.cpp +++ clang/unittests/AST/CommentLexer.cpp @@ -91,7 +91,7 @@ const char *Sources[] = { "//", "///", "//!", "///<", "//!<" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -107,7 +107,7 @@ const char *Sources[] = { "/**/", "/***/", "/*!*/", "/**<*/", "/*!<*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -126,7 +126,7 @@ "// Meow\n", "// Meow\r\n", "//! Meow\r", }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -146,7 +146,7 @@ "/* Meow*/", "/** Meow*/", "/*! Meow*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -169,7 +169,7 @@ "// Aaa\\\r" " Bbb\\ \r" " Ccc?" "?/\r" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -248,7 +248,7 @@ // A command marker followed by comment end. TEST_F(CommentLexerTest, DoxygenCommand1) { const char *Sources[] = { "//@", "///@", "//!@" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -265,7 +265,7 @@ // A command marker followed by comment end. TEST_F(CommentLexerTest, DoxygenCommand2) { const char *Sources[] = { "/*@*/", "/**@*/", "/*!@*/"}; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -283,7 +283,7 @@ // A command marker followed by comment end. TEST_F(CommentLexerTest, DoxygenCommand3) { const char *Sources[] = { "/*\\*/", "/**\\*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -311,12 +311,12 @@ "::", "" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); - ASSERT_EQ(array_lengthof(Text), Toks.size()); + ASSERT_EQ(llvm::size(Text), Toks.size()); for (size_t j = 0, e = Toks.size(); j != e; j++) { if(Toks[j].is(tok::text)) { @@ -578,7 +578,7 @@ "/** \\verbatim\\endverbatim*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -645,7 +645,7 @@ "/** Meow \\verbatim aaa \\endverbatim*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -676,7 +676,7 @@ "/** Meow \\verbatim aaa */" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -901,7 +901,7 @@ "/** \\fn*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -926,7 +926,7 @@ "/** \\fn void *foo(const char *zzz = \"\\$\");*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -1052,7 +1052,7 @@ "// Toks; lexString(Sources[i], Toks); @@ -1169,7 +1169,7 @@ "// Toks; lexString(Sources[i], Toks); @@ -1195,7 +1195,7 @@ "// Toks; lexString(Sources[i], Toks); @@ -1284,7 +1284,7 @@ "// Toks; lexString(Sources[i], Toks); @@ -1315,7 +1315,7 @@ "// " }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -1348,7 +1348,7 @@ "// " }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -1373,7 +1373,7 @@ "// Toks; lexString(Sources[i], Toks); @@ -1797,7 +1797,7 @@ "// =" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); Index: clang/unittests/AST/CommentParser.cpp =================================================================== --- clang/unittests/AST/CommentParser.cpp +++ clang/unittests/AST/CommentParser.cpp @@ -664,7 +664,7 @@ "*/"), }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -801,7 +801,7 @@ "// Bbb\n") }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -831,7 +831,7 @@ "// Bbb\n"), }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -861,7 +861,7 @@ "// Bbb\n"), }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -892,7 +892,7 @@ "// Bbb\n" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -947,7 +947,7 @@ "// Bbb\n" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1081,7 +1081,7 @@ "// " }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1103,7 +1103,7 @@ "//
" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1127,7 +1127,7 @@ "//
", }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1149,7 +1149,7 @@ "// ", }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1172,7 +1172,7 @@ "// " }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1285,7 +1285,7 @@ " *\\endverbatim*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1309,7 +1309,7 @@ " * \\endverbatim*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1336,7 +1336,7 @@ " * \\endverbatim*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1364,7 +1364,7 @@ " * Bbb\n" " * \\endverbatim*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1387,7 +1387,7 @@ "// \\fn\n" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1405,7 +1405,7 @@ "/** \\fn void *foo(const char *zzz = \"\\$\");*/" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1424,7 +1424,7 @@ "/// @deprecated\n" }; - for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { + for (size_t i = 0, e = llvm::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); Index: clang/unittests/AST/DeclPrinterTest.cpp =================================================================== --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -731,7 +731,7 @@ "()", "[]" }; - for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) { + for (unsigned i = 0, e = llvm::size(OperatorNames); i != e; ++i) { SmallString<128> Code; Code.append("struct Z { void operator"); Code.append(OperatorNames[i]); @@ -754,7 +754,7 @@ "~", "!", "++", "--", "->" }; - for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) { + for (unsigned i = 0, e = llvm::size(OperatorNames); i != e; ++i) { SmallString<128> Code; Code.append("struct Z { void operator"); Code.append(OperatorNames[i]); Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp =================================================================== --- clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -642,7 +642,7 @@ // Adjust the given command line arguments to ensure that any positional // arguments in them are stripped. const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"}; - int Argc = llvm::array_lengthof(Argv); + int Argc = llvm::size(Argv); std::string ErrorMessage; std::unique_ptr Database = FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage); Index: lld/COFF/Chunks.cpp =================================================================== --- lld/COFF/Chunks.cpp +++ lld/COFF/Chunks.cpp @@ -947,7 +947,7 @@ void MergeChunk::addSection(COFFLinkerContext &ctx, SectionChunk *c) { assert(isPowerOf2_32(c->getAlignment())); uint8_t p2Align = llvm::Log2_32(c->getAlignment()); - assert(p2Align < array_lengthof(ctx.mergeChunkInstances)); + assert(p2Align < llvm::size(ctx.mergeChunkInstances)); auto *&mc = ctx.mergeChunkInstances[p2Align]; if (!mc) mc = make(c->getAlignment()); Index: lldb/source/DataFormatters/FormatManager.cpp =================================================================== --- lldb/source/DataFormatters/FormatManager.cpp +++ lldb/source/DataFormatters/FormatManager.cpp @@ -77,7 +77,7 @@ kNumFormats, "All formats must have a corresponding info entry."); -static uint32_t g_num_format_infos = llvm::array_lengthof(g_format_infos); +static uint32_t g_num_format_infos = llvm::size(g_format_infos); static bool GetFormatFromFormatChar(char format_char, Format &format) { for (uint32_t i = 0; i < g_num_format_infos; ++i) { Index: lldb/source/Host/common/MainLoop.cpp =================================================================== --- lldb/source/Host/common/MainLoop.cpp +++ lldb/source/Host/common/MainLoop.cpp @@ -108,7 +108,7 @@ EV_SET(&in_events[i++], fd.first, EVFILT_READ, EV_ADD, 0, 0, 0); num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(), - out_events, llvm::array_lengthof(out_events), nullptr); + out_events, llvm::size(out_events), nullptr); if (num_events < 0) { if (errno == EINTR) { Index: lldb/source/Host/windows/ConnectionGenericFileWindows.cpp =================================================================== --- lldb/source/Host/windows/ConnectionGenericFileWindows.cpp +++ lldb/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -187,9 +187,8 @@ ? std::chrono::duration_cast(*timeout) .count() : INFINITE; - DWORD wait_result = - ::WaitForMultipleObjects(llvm::array_lengthof(m_event_handles), - m_event_handles, FALSE, milliseconds); + DWORD wait_result = ::WaitForMultipleObjects( + llvm::size(m_event_handles), m_event_handles, FALSE, milliseconds); // All of the events are manual reset events, so make sure we reset them // to non-signalled. switch (wait_result) { Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -549,7 +549,7 @@ "breakpoint set --name '%1'"}}; // clang-format on - size_t num_regexes = llvm::array_lengthof(break_regexes); + size_t num_regexes = llvm::size(break_regexes); std::unique_ptr break_regex_cmd_up( new CommandObjectRegexCommand( Index: lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp =================================================================== --- lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp +++ lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp @@ -1186,8 +1186,7 @@ nullptr, }}; -static const uint32_t k_num_register_infos = - llvm::array_lengthof(g_register_infos); +static const uint32_t k_num_register_infos = llvm::size(g_register_infos); const lldb_private::RegisterInfo * ABIMacOSX_arm::GetRegisterInfoArray(uint32_t &count) { @@ -1235,7 +1234,7 @@ llvm::ArrayRef::iterator ai = args.begin(), ae = args.end(); - for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { + for (size_t i = 0; i < llvm::size(reg_names); ++i) { if (ai == ae) break; Index: lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp =================================================================== --- lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp +++ lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp @@ -1189,8 +1189,7 @@ nullptr, }}; -static const uint32_t k_num_register_infos = - llvm::array_lengthof(g_register_infos); +static const uint32_t k_num_register_infos = llvm::size(g_register_infos); const lldb_private::RegisterInfo * ABISysV_arm::GetRegisterInfoArray(uint32_t &count) { @@ -1240,7 +1239,7 @@ llvm::ArrayRef::iterator ai = args.begin(), ae = args.end(); - for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { + for (size_t i = 0; i < llvm::size(reg_names); ++i) { if (ai == ae) break; Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp =================================================================== --- lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp +++ lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp @@ -502,8 +502,7 @@ }, }; -static const uint32_t k_num_register_infos = - llvm::array_lengthof(g_register_infos); +static const uint32_t k_num_register_infos = llvm::size(g_register_infos); const lldb_private::RegisterInfo * ABISysV_mips::GetRegisterInfoArray(uint32_t &count) { @@ -559,7 +558,7 @@ llvm::ArrayRef::iterator ai = args.begin(), ae = args.end(); // Write arguments to registers - for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { + for (size_t i = 0; i < llvm::size(reg_names); ++i) { if (ai == ae) break; Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp =================================================================== --- lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp +++ lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp @@ -503,7 +503,7 @@ }; static const uint32_t k_num_register_infos = - llvm::array_lengthof(g_register_infos_mips64); + llvm::size(g_register_infos_mips64); const lldb_private::RegisterInfo * ABISysV_mips64::GetRegisterInfoArray(uint32_t &count) { Index: lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp =================================================================== --- lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp +++ lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp @@ -203,8 +203,7 @@ nullptr, }}; -static const uint32_t k_num_register_infos = - llvm::array_lengthof(g_register_infos); +static const uint32_t k_num_register_infos = llvm::size(g_register_infos); const lldb_private::RegisterInfo * ABISysV_ppc::GetRegisterInfoArray(uint32_t &count) { Index: lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp =================================================================== --- lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp +++ lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp @@ -52,10 +52,10 @@ const lldb_private::RegisterInfo * ABISysV_ppc64::GetRegisterInfoArray(uint32_t &count) { if (GetByteOrder() == lldb::eByteOrderLittle) { - count = llvm::array_lengthof(g_register_infos_ppc64le); + count = llvm::size(g_register_infos_ppc64le); return g_register_infos_ppc64le; } else { - count = llvm::array_lengthof(g_register_infos_ppc64); + count = llvm::size(g_register_infos_ppc64); return g_register_infos_ppc64; } } Index: lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp =================================================================== --- lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp +++ lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp @@ -171,8 +171,7 @@ DEFINE_REG(f15, 8, nullptr, LLDB_INVALID_REGNUM), }; -static const uint32_t k_num_register_infos = - llvm::array_lengthof(g_register_infos); +static const uint32_t k_num_register_infos = llvm::size(g_register_infos); const lldb_private::RegisterInfo * ABISysV_s390x::GetRegisterInfoArray(uint32_t &count) { Index: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -405,7 +405,7 @@ const uint32_t magicks[] = { llvm::MachO::MH_MAGIC_64, llvm::MachO::MH_MAGIC, llvm::MachO::MH_CIGAM, llvm::MachO::MH_CIGAM_64}; bool found_matching_pattern = false; - for (size_t i = 0; i < llvm::array_lengthof (magicks); i++) + for (size_t i = 0; i < llvm::size(magicks); i++) if (::memcmp (&header.magic, &magicks[i], sizeof (uint32_t)) == 0) found_matching_pattern = true; Index: lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp =================================================================== --- lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -13198,7 +13198,7 @@ &EmulateInstructionARM::EmulateRFE, "rfe{} {!}"} }; - static const size_t k_num_arm_opcodes = llvm::array_lengthof(g_arm_opcodes); + static const size_t k_num_arm_opcodes = llvm::size(g_arm_opcodes); for (size_t i = 0; i < k_num_arm_opcodes; ++i) { if ((g_arm_opcodes[i].mask & opcode) == g_arm_opcodes[i].value && @@ -13749,7 +13749,7 @@ &EmulateInstructionARM::EmulateUXTH, "uxth.w ,{,}"}, }; - const size_t k_num_thumb_opcodes = llvm::array_lengthof(g_thumb_opcodes); + const size_t k_num_thumb_opcodes = llvm::size(g_thumb_opcodes); for (size_t i = 0; i < k_num_thumb_opcodes; ++i) { if ((g_thumb_opcodes[i].mask & opcode) == g_thumb_opcodes[i].value && (g_thumb_opcodes[i].variants & arm_isa) != 0) Index: lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp =================================================================== --- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -52,7 +52,7 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionARM64, InstructionARM64) static bool LLDBTableGetRegisterInfo(uint32_t reg_num, RegisterInfo ®_info) { - if (reg_num >= llvm::array_lengthof(g_register_infos_arm64_le)) + if (reg_num >= llvm::size(g_register_infos_arm64_le)) return false; reg_info = g_register_infos_arm64_le[reg_num]; return true; @@ -360,7 +360,7 @@ "TBNZ , #,