diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -5785,12 +5785,11 @@ /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo), MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { - assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && + assert(std::size(MapTypeModifiers) == MapModifiers.size() && "Unexpected number of map type modifiers."); llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); - assert(llvm::array_lengthof(MapTypeModifiersLoc) == - MapModifiersLoc.size() && + assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() && "Unexpected number of map type modifier locations."); llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); } @@ -6707,12 +6706,11 @@ : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { - assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && + assert(std::size(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); - assert(llvm::array_lengthof(MotionModifiersLoc) == - TheMotionModifiersLoc.size() && + assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); } @@ -6909,12 +6907,11 @@ : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { - assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && + assert(std::size(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); - assert(llvm::array_lengthof(MotionModifiersLoc) == - TheMotionModifiersLoc.size() && + assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); } diff --git a/clang/lib/AST/AttrDocTable.cpp b/clang/lib/AST/AttrDocTable.cpp --- a/clang/lib/AST/AttrDocTable.cpp +++ b/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 < std::size(AttrDoc)) return AttrDoc[K]; return ""; } diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp --- a/clang/lib/AST/CommentCommandTraits.cpp +++ b/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(std::size(Commands)), Allocator(Allocator) { registerCommentOptions(CommentOptions); } @@ -115,7 +115,7 @@ const CommandInfo *CommandTraits::getBuiltinCommandInfo( unsigned CommandID) { - if (CommandID < llvm::array_lengthof(Commands)) + if (CommandID < std::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 - std::size(Commands)]; } } // end namespace comments diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -202,7 +202,7 @@ } // namespace -static const unsigned StaticDiagInfoSize = llvm::array_lengthof(StaticDiagInfo); +static const unsigned StaticDiagInfoSize = std::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 std::size(CategoryNameTable) - 1; } /// getCategoryNameFromID - Given a category ID, return the name of the diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/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 >= std::size(NVPTXDWARFAddrSpaceMap) || NVPTXDWARFAddrSpaceMap[AddressSpace] < 0) return llvm::None; return NVPTXDWARFAddrSpaceMap[AddressSpace]; diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3297,7 +3297,7 @@ assert(IsSanitizerScope); assert(Checked.size() > 0); assert(CheckHandler >= 0 && - size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers)); + size_t(CheckHandler) < std::size(SanitizerHandlers)); const StringRef CheckName = SanitizerHandlers[CheckHandler].Name; llvm::Value *FatalCond = nullptr; diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/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(std::size(II), &II[0]); QualType ItemsTy = getContext().getConstantArrayType(getContext().getObjCIdType(), diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1809,7 +1809,7 @@ "WATCHOS_DEPLOYMENT_TARGET", "DRIVERKIT_DEPLOYMENT_TARGET", }; - static_assert(llvm::array_lengthof(EnvVars) == Darwin::LastDarwinPlatform + 1, + static_assert(std::size(EnvVars) == Darwin::LastDarwinPlatform + 1, "Missing platform"); for (const auto &I : llvm::enumerate(llvm::makeArrayRef(EnvVars))) { if (char *Env = ::getenv(I.value())) @@ -1830,11 +1830,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 = std::size(Targets); + for (unsigned I = 0; I != std::size(Targets); ++I) { if (Targets[I].empty()) continue; - if (FirstTarget == llvm::array_lengthof(Targets)) + if (FirstTarget == std::size(Targets)) FirstTarget = I; else TheDriver.Diag(diag::err_drv_conflicting_deployment_targets) diff --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp --- a/clang/lib/Driver/Types.cpp +++ b/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 = std::size(TypeInfos); static const TypeInfo &getInfo(unsigned id) { assert(id > 0 && id - 1 < numTypes && "Invalid Type ID."); diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -877,7 +877,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() < std::size(Buffer)) { const char *TokPtr = Buffer; unsigned Len = PP.getSpelling(Tok, TokPtr); OS.write(TokPtr, Len); diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1417,7 +1417,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, std::size(Args), Syntax); } /// Parse the contents of the "objc_bridge_related" attribute. @@ -1538,7 +1538,7 @@ ArgsUnion Args[] = {SwiftType}; Attrs.addNew(&AttrName, SourceRange(AttrNameLoc, T.getCloseLocation()), - ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax); + ScopeName, ScopeLoc, Args, std::size(Args), Syntax); } void Parser::ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName, diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -239,7 +239,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 <= std::size(TheDeclarator.InlineParams)) { I.Fun.Params = TheDeclarator.InlineParams; new (I.Fun.Params) ParamInfo[NumParams]; I.Fun.DeleteParams = false; @@ -308,8 +308,7 @@ // Allocate storage for bindings and stash them away. if (Bindings.size()) { - if (!InlineStorageUsed && - Bindings.size() <= llvm::array_lengthof(InlineBindings)) { + if (!InlineStorageUsed && Bindings.size() <= std::size(InlineBindings)) { BindingGroup.Bindings = InlineBindings; BindingGroup.DeleteBindings = false; InlineStorageUsed = true; diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp --- a/clang/lib/Sema/ParsedAttr.cpp +++ b/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() < std::size(AttrInfoMap)) return *AttrInfoMap[A.getParsedKind()]; // If this is an ignored attribute then return an appropriate ParsedAttrInfo. diff --git a/clang/unittests/AST/CommentLexer.cpp b/clang/unittests/AST/CommentLexer.cpp --- a/clang/unittests/AST/CommentLexer.cpp +++ b/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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); - ASSERT_EQ(array_lengthof(Text), Toks.size()); + ASSERT_EQ(std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::size(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); diff --git a/clang/unittests/AST/CommentParser.cpp b/clang/unittests/AST/CommentParser.cpp --- a/clang/unittests/AST/CommentParser.cpp +++ b/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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::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 = std::size(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp --- a/clang/unittests/AST/DeclPrinterTest.cpp +++ b/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 = std::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 = std::size(OperatorNames); i != e; ++i) { SmallString<128> Code; Code.append("struct Z { void operator"); Code.append(OperatorNames[i]); diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp --- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/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 = std::size(Argv); std::string ErrorMessage; std::unique_ptr Database = FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);