From f15014ff549a8686671a599f7b49ce9963769eaf Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 26 Jan 2022 16:55:53 +0100 Subject: [PATCH] Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17" This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2. - It conflicts with the existing llvm::size in STLExtras, which will now never be called. - Calling it without llvm:: breaks C++17 compat --- clang/include/clang/AST/OpenMPClause.h | 12 ++--- clang/lib/AST/ASTContext.cpp | 2 +- clang/lib/AST/AttrDocTable.cpp | 2 +- clang/lib/AST/CommentCommandTraits.cpp | 6 +-- clang/lib/Basic/DiagnosticIDs.cpp | 4 +- clang/lib/Basic/Targets/NVPTX.h | 2 +- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/lib/CodeGen/CGObjC.cpp | 2 +- clang/lib/Driver/Compilation.cpp | 2 +- clang/lib/Driver/ToolChain.cpp | 2 +- clang/lib/Driver/ToolChains/Darwin.cpp | 8 ++-- clang/lib/Driver/Types.cpp | 2 +- .../lib/Frontend/PrintPreprocessedOutput.cpp | 2 +- clang/lib/Parse/ParseDecl.cpp | 4 +- clang/lib/Parse/ParseOpenMP.cpp | 2 +- clang/lib/Sema/DeclSpec.cpp | 4 +- clang/lib/Sema/ParsedAttr.cpp | 2 +- clang/lib/Sema/SemaLookup.cpp | 6 +-- clang/lib/Sema/TreeTransform.h | 2 +- clang/test/Analysis/templates.cpp | 4 +- clang/test/SemaTemplate/instantiate-init.cpp | 10 ++-- clang/unittests/AST/CommentLexer.cpp | 48 +++++++++---------- clang/unittests/AST/CommentParser.cpp | 36 +++++++------- clang/unittests/AST/DeclPrinterTest.cpp | 4 +- .../Tooling/CompilationDatabaseTest.cpp | 2 +- lld/COFF/Chunks.cpp | 2 +- lldb/source/DataFormatters/FormatManager.cpp | 2 +- lldb/source/Host/common/MainLoop.cpp | 2 +- .../windows/ConnectionGenericFileWindows.cpp | 2 +- .../source/Interpreter/CommandInterpreter.cpp | 2 +- lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp | 4 +- lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp | 4 +- lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp | 4 +- .../Plugins/ABI/Mips/ABISysV_mips64.cpp | 2 +- .../Plugins/ABI/PowerPC/ABISysV_ppc.cpp | 2 +- .../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp | 4 +- .../Plugins/ABI/SystemZ/ABISysV_s390x.cpp | 2 +- .../DynamicLoaderDarwinKernel.cpp | 2 +- .../Instruction/ARM/EmulateInstructionARM.cpp | 4 +- .../ARM64/EmulateInstructionARM64.cpp | 4 +- .../MIPS/EmulateInstructionMIPS.cpp | 2 +- .../MIPS64/EmulateInstructionMIPS64.cpp | 2 +- .../PPC64/EmulateInstructionPPC64.cpp | 4 +- .../AppleObjCTrampolineHandler.cpp | 4 +- .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 2 +- .../ObjectFile/PECOFF/PECallFrameInfo.cpp | 4 +- .../Platform/MacOSX/PlatformDarwin.cpp | 4 +- .../Utility/RegisterContextDarwin_arm.cpp | 10 ++-- .../Utility/RegisterContextDarwin_arm64.cpp | 10 ++-- .../Utility/RegisterContextDarwin_i386.cpp | 10 ++-- .../Utility/RegisterContextDarwin_x86_64.cpp | 10 ++-- .../Utility/RegisterContextWindows_i386.cpp | 4 +- .../Utility/RegisterContextWindows_x86_64.cpp | 4 +- .../NativeRegisterContextWindows_WoW64.cpp | 2 +- .../NativeRegisterContextWindows_arm.cpp | 4 +- .../NativeRegisterContextWindows_arm64.cpp | 4 +- .../NativeRegisterContextWindows_i386.cpp | 2 +- .../NativeRegisterContextWindows_x86_64.cpp | 4 +- .../Common/arm/RegisterContextWindows_arm.cpp | 10 ++-- .../arm64/RegisterContextWindows_arm64.cpp | 10 ++-- .../Common/x64/RegisterContextWindows_x64.cpp | 10 ++-- .../Common/x86/RegisterContextWindows_x86.cpp | 8 ++-- .../minidump/RegisterContextMinidump_ARM.cpp | 12 ++--- .../RegisterContextMinidump_ARM64.cpp | 8 ++-- lldb/source/Utility/ArchSpec.cpp | 16 +++---- lldb/unittests/Utility/StatusTest.cpp | 2 +- llvm/include/llvm/ADT/STLExtras.h | 6 +++ llvm/include/llvm/ADT/STLForwardCompat.h | 10 ---- llvm/include/llvm/CodeGen/TargetLowering.h | 24 +++++----- llvm/include/llvm/MC/SubtargetFeature.h | 6 +-- .../CodeGen/GlobalISel/LegalizerHelper.cpp | 8 ++-- .../SelectionDAG/LegalizeVectorTypes.cpp | 8 ++-- llvm/lib/CodeGen/TargetLoweringBase.cpp | 2 +- llvm/lib/DWP/DWP.cpp | 2 +- llvm/lib/IR/DebugInfoMetadata.cpp | 6 +-- llvm/lib/MC/MCAsmBackend.cpp | 2 +- llvm/lib/MC/MCDwarf.cpp | 2 +- llvm/lib/Object/MachOObjectFile.cpp | 2 +- llvm/lib/Support/ARMAttributeParser.cpp | 6 +-- llvm/lib/Support/CrashRecoveryContext.cpp | 2 +- llvm/lib/Support/NativeFormatting.cpp | 2 +- llvm/lib/Support/RISCVAttributeParser.cpp | 2 +- llvm/lib/Support/Triple.cpp | 10 ++-- llvm/lib/Support/Unix/Signals.inc | 10 ++-- llvm/lib/Support/Windows/Path.inc | 2 +- llvm/lib/Support/Windows/Signals.inc | 2 +- llvm/lib/Support/X86TargetParser.cpp | 14 +++--- llvm/lib/Support/raw_ostream.cpp | 4 +- .../Target/AArch64/AArch64ISelLowering.cpp | 4 +- .../MCTargetDesc/AArch64InstPrinter.cpp | 2 +- llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp | 4 +- llvm/lib/Target/AMDGPU/R600RegisterInfo.cpp | 2 +- llvm/lib/Target/ARC/ARCISelLowering.cpp | 8 ++-- llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 4 +- llvm/lib/Target/ARM/ARMFrameLowering.cpp | 2 +- llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 +- llvm/lib/Target/ARM/Thumb2SizeReduction.cpp | 2 +- llvm/lib/Target/AVR/AVRISelLowering.cpp | 4 +- .../Disassembler/HexagonDisassembler.cpp | 8 ++-- .../lib/Target/Hexagon/HexagonFrameLowering.h | 2 +- .../Target/Hexagon/HexagonHardwareLoops.cpp | 4 +- .../Target/Hexagon/HexagonISelDAGToDAG.cpp | 2 +- .../Target/Hexagon/HexagonISelLowering.cpp | 2 +- .../MCTargetDesc/HexagonMCCodeEmitter.cpp | 2 +- .../MSP430/MCTargetDesc/MSP430AsmBackend.cpp | 2 +- llvm/lib/Target/MSP430/MSP430ISelLowering.cpp | 4 +- .../Mips/MCTargetDesc/MipsAsmBackend.cpp | 4 +- llvm/lib/Target/Mips/Mips16ISelLowering.cpp | 2 +- llvm/lib/Target/PowerPC/PPCCallingConv.cpp | 6 +-- llvm/lib/Target/PowerPC/PPCFrameLowering.cpp | 8 ++-- llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 20 ++++---- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | 4 +- .../RISCV/MCTargetDesc/RISCVAsmBackend.cpp | 2 +- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 4 +- .../Sparc/Disassembler/SparcDisassembler.cpp | 2 +- .../Target/SystemZ/SystemZFrameLowering.cpp | 4 +- llvm/lib/Target/VE/VEFrameLowering.h | 2 +- .../lib/Target/X86/AsmParser/X86AsmParser.cpp | 4 +- llvm/lib/Target/X86/X86ISelLowering.cpp | 4 +- llvm/lib/Target/XCore/XCoreISelLowering.cpp | 4 +- .../InstCombine/InstCombineAddSub.cpp | 2 +- .../Transforms/Scalar/LoopStrengthReduce.cpp | 2 +- llvm/lib/Transforms/Utils/MetaRenamer.cpp | 2 +- llvm/tools/llvm-config/llvm-config.cpp | 4 +- llvm/tools/llvm-objdump/COFFDump.cpp | 2 +- llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp | 4 +- llvm/tools/llvm-readobj/ELFDumper.cpp | 2 +- llvm/unittests/ADT/APFloatTest.cpp | 20 ++++---- llvm/unittests/ADT/StringRefTest.cpp | 12 ++--- llvm/unittests/ADT/TinyPtrVectorTest.cpp | 2 +- .../ProfileData/CoverageMappingTest.cpp | 4 +- llvm/unittests/Support/BinaryStreamTest.cpp | 2 +- llvm/unittests/Support/CommandLineTest.cpp | 10 ++-- llvm/unittests/Support/FormatVariadicTest.cpp | 2 +- llvm/unittests/Support/TargetParserTest.cpp | 12 ++--- llvm/utils/KillTheDoctor/KillTheDoctor.cpp | 6 +-- llvm/utils/TableGen/AsmWriterEmitter.cpp | 2 +- llvm/utils/TableGen/CodeGenTarget.cpp | 2 +- llvm/utils/TableGen/RegisterInfoEmitter.cpp | 4 +- llvm/utils/TableGen/X86DisassemblerTables.cpp | 2 +- .../mlir/Dialect/SPIRV/IR/SPIRVBase.td | 4 +- mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp | 6 +-- mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp | 22 ++++----- 143 files changed, 382 insertions(+), 386 deletions(-) diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index e3f975c90643..3ecc1d40fafc 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -5772,11 +5772,11 @@ private: /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo), MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { - assert(llvm::size(MapTypeModifiers) == MapModifiers.size() && + assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && "Unexpected number of map type modifiers."); llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); - assert(llvm::size(MapTypeModifiersLoc) == + assert(llvm::array_lengthof(MapTypeModifiersLoc) == MapModifiersLoc.size() && "Unexpected number of map type modifier locations."); llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); @@ -6694,11 +6694,11 @@ class OMPToClause final : public OMPMappableExprListClause, : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { - assert(llvm::size(MotionModifiers) == TheMotionModifiers.size() && + assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); - assert(llvm::size(MotionModifiersLoc) == + assert(llvm::array_lengthof(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); @@ -6896,11 +6896,11 @@ class OMPFromClause final : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, /*SupportsMapper=*/true, &MapperQualifierLoc, &MapperIdInfo) { - assert(llvm::size(MotionModifiers) == TheMotionModifiers.size() && + assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && "Unexpected number of motion modifiers."); llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); - assert(llvm::size(MotionModifiersLoc) == + assert(llvm::array_lengthof(MotionModifiersLoc) == TheMotionModifiersLoc.size() && "Unexpected number of motion modifier locations."); llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 2111e9380167..9d63724c919a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -6594,7 +6594,7 @@ QualType ASTContext::getPromotedIntegerType(QualType Promotable) const { uint64_t FromSize = getTypeSize(BT); QualType PromoteTypes[] = { IntTy, UnsignedIntTy, LongTy, UnsignedLongTy, LongLongTy, UnsignedLongLongTy }; - for (size_t Idx = 0; Idx < llvm::size(PromoteTypes); ++Idx) { + for (size_t Idx = 0; Idx < llvm::array_lengthof(PromoteTypes); ++Idx) { uint64_t ToSize = getTypeSize(PromoteTypes[Idx]); if (FromSize < ToSize || (FromSize == ToSize && diff --git a/clang/lib/AST/AttrDocTable.cpp b/clang/lib/AST/AttrDocTable.cpp index 8f7e7eaf0452..3bfedac8b8f1 100644 --- a/clang/lib/AST/AttrDocTable.cpp +++ b/clang/lib/AST/AttrDocTable.cpp @@ -21,7 +21,7 @@ static const llvm::StringRef AttrDoc[] = { }; llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) { - if(K < llvm::size(AttrDoc)) + if(K < llvm::array_lengthof(AttrDoc)) return AttrDoc[K]; return ""; } diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp index 68f8006261f1..bdc0dd47fb7d 100644 --- a/clang/lib/AST/CommentCommandTraits.cpp +++ b/clang/lib/AST/CommentCommandTraits.cpp @@ -17,7 +17,7 @@ namespace comments { CommandTraits::CommandTraits(llvm::BumpPtrAllocator &Allocator, const CommentOptions &CommentOptions) : - NextID(llvm::size(Commands)), Allocator(Allocator) { + NextID(llvm::array_lengthof(Commands)), Allocator(Allocator) { registerCommentOptions(CommentOptions); } @@ -115,7 +115,7 @@ const CommandInfo *CommandTraits::registerBlockCommand(StringRef CommandName) { const CommandInfo *CommandTraits::getBuiltinCommandInfo( unsigned CommandID) { - if (CommandID < llvm::size(Commands)) + if (CommandID < llvm::array_lengthof(Commands)) return &Commands[CommandID]; return nullptr; } @@ -131,7 +131,7 @@ const CommandInfo *CommandTraits::getRegisteredCommandInfo( const CommandInfo *CommandTraits::getRegisteredCommandInfo( unsigned CommandID) const { - return RegisteredCommands[CommandID - llvm::size(Commands)]; + return RegisteredCommands[CommandID - llvm::array_lengthof(Commands)]; } } // end namespace comments diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp index 3e6204a07c29..87db131992e4 100644 --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -202,7 +202,7 @@ const StaticDiagInfoRec StaticDiagInfo[] = { } // namespace -static const unsigned StaticDiagInfoSize = llvm::size(StaticDiagInfo); +static const unsigned StaticDiagInfoSize = llvm::array_lengthof(StaticDiagInfo); /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID, /// or null if the ID is invalid. @@ -317,7 +317,7 @@ static const StaticDiagCategoryRec CategoryNameTable[] = { /// getNumberOfCategories - Return the number of categories unsigned DiagnosticIDs::getNumberOfCategories() { - return llvm::size(CategoryNameTable) - 1; + return llvm::array_lengthof(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 index 83f220dcb8b3..589f24f4bb03 100644 --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/clang/lib/Basic/Targets/NVPTX.h @@ -159,7 +159,7 @@ public: /// DWARF. Optional getDWARFAddressSpace(unsigned AddressSpace) const override { - if (AddressSpace >= llvm::size(NVPTXDWARFAddrSpaceMap) || + if (AddressSpace >= llvm::array_lengthof(NVPTXDWARFAddrSpaceMap) || NVPTXDWARFAddrSpaceMap[AddressSpace] < 0) return llvm::None; return NVPTXDWARFAddrSpaceMap[AddressSpace]; diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 888f9e275dd1..0fb7ec26a85e 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3206,7 +3206,7 @@ void CodeGenFunction::EmitCheck( assert(IsSanitizerScope); assert(Checked.size() > 0); assert(CheckHandler >= 0 && - size_t(CheckHandler) < llvm::size(SanitizerHandlers)); + size_t(CheckHandler) < llvm::array_lengthof(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 index a2c8f8ef1066..8cc609186f9e 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -1749,7 +1749,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ &CGM.getContext().Idents.get("count") }; Selector FastEnumSel = - CGM.getContext().Selectors.getSelector(llvm::size(II), &II[0]); + CGM.getContext().Selectors.getSelector(llvm::array_lengthof(II), &II[0]); QualType ItemsTy = getContext().getConstantArrayType(getContext().getObjCIdType(), diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index c479375157c2..67d941c6c2ab 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -278,7 +278,7 @@ void Compilation::initCompilationForDiagnostics() { 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::size(OutputOpts); i != e; ++i) { + for (unsigned i = 0, e = llvm::array_lengthof(OutputOpts); i != e; ++i) { if (TranslatedArgs->hasArg(OutputOpts[i])) TranslatedArgs->eraseArg(OutputOpts[i]); } diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index cc6f7210a8d0..7551ee4aeb79 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -151,7 +151,7 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { {"flang", "--driver-mode=flang"}, }; - for (size_t i = 0; i < llvm::size(DriverSuffixes); ++i) { + for (size_t i = 0; i < llvm::array_lengthof(DriverSuffixes); ++i) { StringRef Suffix(DriverSuffixes[i].Suffix); if (ProgName.endswith(Suffix)) { Pos = ProgName.size() - Suffix.size(); diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 8fed21586959..f7da3f187814 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1694,7 +1694,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver, "TVOS_DEPLOYMENT_TARGET", "WATCHOS_DEPLOYMENT_TARGET", }; - static_assert(llvm::size(EnvVars) == Darwin::LastDarwinPlatform + 1, + static_assert(llvm::array_lengthof(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 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver, Targets[Darwin::TvOS] = ""; } else { // Don't allow conflicts in any other platform. - unsigned FirstTarget = llvm::size(Targets); - for (unsigned I = 0; I != llvm::size(Targets); ++I) { + unsigned FirstTarget = llvm::array_lengthof(Targets); + for (unsigned I = 0; I != llvm::array_lengthof(Targets); ++I) { if (Targets[I].empty()) continue; - if (FirstTarget == llvm::size(Targets)) + if (FirstTarget == llvm::array_lengthof(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 index c5c17e1378fb..1bd187ad2fc0 100644 --- a/clang/lib/Driver/Types.cpp +++ b/clang/lib/Driver/Types.cpp @@ -42,7 +42,7 @@ static constexpr TypeInfo TypeInfos[] = { #include "clang/Driver/Types.def" #undef TYPE }; -static const unsigned numTypes = llvm::size(TypeInfos); +static const unsigned numTypes = llvm::array_lengthof(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 index 23d2bec11dcf..1d0022bda474 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -863,7 +863,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, } else if (Tok.isLiteral() && !Tok.needsCleaning() && Tok.getLiteralData()) { OS.write(Tok.getLiteralData(), Tok.getLength()); - } else if (Tok.getLength() < llvm::size(Buffer)) { + } else if (Tok.getLength() < llvm::array_lengthof(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 index d05169988f2f..f21938c81689 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1365,7 +1365,7 @@ void Parser::ParseExternalSourceSymbolAttribute( ArgsUnion Args[] = {Language.get(), DefinedInExpr.get(), GeneratedDeclaration}; Attrs.addNew(&ExternalSourceSymbol, SourceRange(Loc, T.getCloseLocation()), - ScopeName, ScopeLoc, Args, llvm::size(Args), Syntax); + ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax); } /// Parse the contents of the "objc_bridge_related" attribute. @@ -1493,7 +1493,7 @@ void Parser::ParseSwiftNewTypeAttribute( ArgsUnion Args[] = {SwiftType}; Attrs.addNew(&AttrName, SourceRange(AttrNameLoc, T.getCloseLocation()), - ScopeName, ScopeLoc, Args, llvm::size(Args), Syntax); + ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax); } diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index d13f6e080630..de3d58baf84c 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -188,7 +188,7 @@ static OpenMPDirectiveKindExWrapper parseOpenMPDirectiveKind(Parser &P) { if (DKind == OMPD_unknown) return OMPD_unknown; - for (unsigned I = 0; I < llvm::size(F); ++I) { + for (unsigned I = 0; I < llvm::array_lengthof(F); ++I) { if (DKind != F[I][0]) continue; diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index c595237401e6..d4dc790c008a 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -238,7 +238,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, // 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::size(TheDeclarator.InlineParams)) { + NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) { I.Fun.Params = TheDeclarator.InlineParams; new (I.Fun.Params) ParamInfo[NumParams]; I.Fun.DeleteParams = false; @@ -308,7 +308,7 @@ void Declarator::setDecompositionBindings( // Allocate storage for bindings and stash them away. if (Bindings.size()) { if (!InlineStorageUsed && - Bindings.size() <= llvm::size(InlineBindings)) { + Bindings.size() <= llvm::array_lengthof(InlineBindings)) { BindingGroup.Bindings = InlineBindings; BindingGroup.DeleteBindings = false; InlineStorageUsed = true; diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp index 5c533f11bf32..045847d0ce0f 100644 --- a/clang/lib/Sema/ParsedAttr.cpp +++ b/clang/lib/Sema/ParsedAttr.cpp @@ -111,7 +111,7 @@ namespace { const ParsedAttrInfo &ParsedAttrInfo::get(const AttributeCommonInfo &A) { // If we have a ParsedAttrInfo for this ParsedAttr then return that. - if ((size_t)A.getParsedKind() < llvm::size(AttrInfoMap)) + if ((size_t)A.getParsedKind() < llvm::array_lengthof(AttrInfoMap)) return *AttrInfoMap[A.getParsedKind()]; // If this is an ignored attribute then return an appropriate ParsedAttrInfo. diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 219f2c0f8a31..af6ee24240ce 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -4726,7 +4726,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef, "extern", "inline", "static", "typedef" }; - const unsigned NumCTypeSpecs = llvm::size(CTypeSpecs); + const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs); for (unsigned I = 0; I != NumCTypeSpecs; ++I) Consumer.addKeywordResult(CTypeSpecs[I]); @@ -4780,7 +4780,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef, static const char *const CXXExprs[] = { "delete", "new", "operator", "throw", "typeid" }; - const unsigned NumCXXExprs = llvm::size(CXXExprs); + const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs); for (unsigned I = 0; I != NumCXXExprs; ++I) Consumer.addKeywordResult(CXXExprs[I]); @@ -4806,7 +4806,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef, // Statements. static const char *const CStmts[] = { "do", "else", "for", "goto", "if", "return", "switch", "while" }; - const unsigned NumCStmts = llvm::size(CStmts); + const unsigned NumCStmts = llvm::array_lengthof(CStmts); for (unsigned I = 0; I != NumCStmts; ++I) Consumer.addKeywordResult(CStmts[I]); diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 8a0e26fca91e..e43b3ca968eb 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -14357,7 +14357,7 @@ TreeTransform::RebuildArrayType(QualType ElementType, SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy, SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty }; - const unsigned NumTypes = llvm::size(Types); + const unsigned NumTypes = llvm::array_lengthof(Types); QualType SizeType; for (unsigned I = 0; I != NumTypes; ++I) if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) { diff --git a/clang/test/Analysis/templates.cpp b/clang/test/Analysis/templates.cpp index 2c5b22d24119..e7c30a764f72 100644 --- a/clang/test/Analysis/templates.cpp +++ b/clang/test/Analysis/templates.cpp @@ -34,13 +34,13 @@ int main(){ // template -inline unsigned size(T (&)[N]) { +inline unsigned array_lengthof(T (&)[N]) { return N; } void testNonTypeTemplateInstantiation() { const char *S[] = { "a", "b" }; - clang_analyzer_eval(size(S) == 2); + clang_analyzer_eval(array_lengthof(S) == 2); #ifndef NO_INLINE // expected-warning@-2 {{TRUE}} #else diff --git a/clang/test/SemaTemplate/instantiate-init.cpp b/clang/test/SemaTemplate/instantiate-init.cpp index 52f2b416e64a..6db33a972f86 100644 --- a/clang/test/SemaTemplate/instantiate-init.cpp +++ b/clang/test/SemaTemplate/instantiate-init.cpp @@ -86,7 +86,7 @@ namespace PR7985 { template struct integral_c { }; template - integral_c size(T (&x)[N]) { return integral_c(); } // expected-note 2{{candidate template ignored: could not match 'T[N]' against 'const Data<}} + integral_c array_lengthof(T (&x)[N]) { return integral_c(); } // expected-note 2{{candidate template ignored: could not match 'T[N]' against 'const Data<}} template struct Data { @@ -105,14 +105,14 @@ namespace PR7985 { const Data Description::data[]; void test() { - integral_c<1> ic1 = size(Description::data); - (void)sizeof(size(Description::data)); + integral_c<1> ic1 = array_lengthof(Description::data); + (void)sizeof(array_lengthof(Description::data)); - (void)sizeof(size( // expected-error{{no matching function for call to 'size'}} + (void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}} Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}} )); - size(Description::data); // expected-error{{no matching function for call to 'size'}} + array_lengthof(Description::data); // expected-error{{no matching function for call to 'array_lengthof'}} } } diff --git a/clang/unittests/AST/CommentLexer.cpp b/clang/unittests/AST/CommentLexer.cpp index 9540ebfe32e5..456473e1753b 100644 --- a/clang/unittests/AST/CommentLexer.cpp +++ b/clang/unittests/AST/CommentLexer.cpp @@ -91,7 +91,7 @@ TEST_F(CommentLexerTest, Basic2) { const char *Sources[] = { "//", "///", "//!", "///<", "//!<" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -107,7 +107,7 @@ TEST_F(CommentLexerTest, Basic3) { const char *Sources[] = { "/**/", "/***/", "/*!*/", "/**<*/", "/*!<*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -126,7 +126,7 @@ TEST_F(CommentLexerTest, Basic4) { "// Meow\n", "// Meow\r\n", "//! Meow\r", }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -146,7 +146,7 @@ TEST_F(CommentLexerTest, Basic5) { "/* Meow*/", "/** Meow*/", "/*! Meow*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -169,7 +169,7 @@ TEST_F(CommentLexerTest, Basic6) { "// Aaa\\\r" " Bbb\\ \r" " Ccc?" "?/\r" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -248,7 +248,7 @@ TEST_F(CommentLexerTest, Basic7) { // A command marker followed by comment end. TEST_F(CommentLexerTest, DoxygenCommand1) { const char *Sources[] = { "//@", "///@", "//!@" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -265,7 +265,7 @@ TEST_F(CommentLexerTest, DoxygenCommand1) { // A command marker followed by comment end. TEST_F(CommentLexerTest, DoxygenCommand2) { const char *Sources[] = { "/*@*/", "/**@*/", "/*!@*/"}; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -283,7 +283,7 @@ TEST_F(CommentLexerTest, DoxygenCommand2) { // A command marker followed by comment end. TEST_F(CommentLexerTest, DoxygenCommand3) { const char *Sources[] = { "/*\\*/", "/**\\*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -311,12 +311,12 @@ TEST_F(CommentLexerTest, DoxygenCommand4) { "::", "" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); - ASSERT_EQ(size(Text), Toks.size()); + ASSERT_EQ(array_lengthof(Text), Toks.size()); for (size_t j = 0, e = Toks.size(); j != e; j++) { if(Toks[j].is(tok::text)) { @@ -578,7 +578,7 @@ TEST_F(CommentLexerTest, VerbatimBlock1) { "/** \\verbatim\\endverbatim*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -645,7 +645,7 @@ TEST_F(CommentLexerTest, VerbatimBlock4) { "/** Meow \\verbatim aaa \\endverbatim*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -676,7 +676,7 @@ TEST_F(CommentLexerTest, VerbatimBlock5) { "/** Meow \\verbatim aaa */" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -901,7 +901,7 @@ TEST_F(CommentLexerTest, VerbatimLine1) { "/** \\fn*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -926,7 +926,7 @@ TEST_F(CommentLexerTest, VerbatimLine2) { "/** \\fn void *foo(const char *zzz = \"\\$\");*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -1052,7 +1052,7 @@ TEST_F(CommentLexerTest, HTML4) { "// Toks; lexString(Sources[i], Toks); @@ -1169,7 +1169,7 @@ TEST_F(CommentLexerTest, HTML9) { "// Toks; lexString(Sources[i], Toks); @@ -1195,7 +1195,7 @@ TEST_F(CommentLexerTest, HTML10) { "// Toks; lexString(Sources[i], Toks); @@ -1284,7 +1284,7 @@ TEST_F(CommentLexerTest, HTML13) { "// Toks; lexString(Sources[i], Toks); @@ -1315,7 +1315,7 @@ TEST_F(CommentLexerTest, HTML14) { "// " }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -1348,7 +1348,7 @@ TEST_F(CommentLexerTest, HTML15) { "// " }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { std::vector Toks; lexString(Sources[i], Toks); @@ -1373,7 +1373,7 @@ TEST_F(CommentLexerTest, HTML16) { "// Toks; lexString(Sources[i], Toks); @@ -1797,7 +1797,7 @@ TEST_F(CommentLexerTest, HTMLCharacterReferences16) { "// =" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(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 index 0de20dd32cb0..62c461a00d16 100644 --- a/clang/unittests/AST/CommentParser.cpp +++ b/clang/unittests/AST/CommentParser.cpp @@ -664,7 +664,7 @@ TEST_F(CommentParserTest, ParagraphSplitting1) { "*/"), }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -801,7 +801,7 @@ TEST_F(CommentParserTest, ParamCommand3) { "// Bbb\n") }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -831,7 +831,7 @@ TEST_F(CommentParserTest, ParamCommand4) { "// Bbb\n"), }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -861,7 +861,7 @@ TEST_F(CommentParserTest, ParamCommand5) { "// Bbb\n"), }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -892,7 +892,7 @@ TEST_F(CommentParserTest, ParamCommand6) { "// Bbb\n" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -947,7 +947,7 @@ TEST_F(CommentParserTest, TParamCommand1) { "// Bbb\n" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1081,7 +1081,7 @@ TEST_F(CommentParserTest, HTML1) { "// " }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1103,7 +1103,7 @@ TEST_F(CommentParserTest, HTML2) { "//
" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1127,7 +1127,7 @@ TEST_F(CommentParserTest, HTML3) { "//
", }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1149,7 +1149,7 @@ TEST_F(CommentParserTest, HTML4) { "// ", }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1172,7 +1172,7 @@ TEST_F(CommentParserTest, HTML5) { "// " }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1285,7 +1285,7 @@ TEST_F(CommentParserTest, VerbatimBlock5) { " *\\endverbatim*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 1)); @@ -1309,7 +1309,7 @@ TEST_F(CommentParserTest, VerbatimBlock6) { " * \\endverbatim*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1336,7 +1336,7 @@ TEST_F(CommentParserTest, VerbatimBlock7) { " * \\endverbatim*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1364,7 +1364,7 @@ TEST_F(CommentParserTest, VerbatimBlock8) { " * Bbb\n" " * \\endverbatim*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1387,7 +1387,7 @@ TEST_F(CommentParserTest, VerbatimLine1) { "// \\fn\n" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1405,7 +1405,7 @@ TEST_F(CommentParserTest, VerbatimLine2) { "/** \\fn void *foo(const char *zzz = \"\\$\");*/" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) { FullComment *FC = parseString(Sources[i]); ASSERT_TRUE(HasChildCount(FC, 2)); @@ -1424,7 +1424,7 @@ TEST_F(CommentParserTest, Deprecated) { "/// @deprecated\n" }; - for (size_t i = 0, e = size(Sources); i != e; i++) { + for (size_t i = 0, e = array_lengthof(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 index 628b948c72e4..c2d7d78738f9 100644 --- a/clang/unittests/AST/DeclPrinterTest.cpp +++ b/clang/unittests/AST/DeclPrinterTest.cpp @@ -731,7 +731,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_Operator1) { "()", "[]" }; - for (unsigned i = 0, e = llvm::size(OperatorNames); i != e; ++i) { + for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) { SmallString<128> Code; Code.append("struct Z { void operator"); Code.append(OperatorNames[i]); @@ -754,7 +754,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_Operator2) { "~", "!", "++", "--", "->" }; - for (unsigned i = 0, e = llvm::size(OperatorNames); i != e; ++i) { + for (unsigned i = 0, e = llvm::array_lengthof(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 index 94ccdcafda6d..adb9de0c1cba 100644 --- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -642,7 +642,7 @@ TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) { // 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::size(Argv); + int Argc = llvm::array_lengthof(Argv); std::string ErrorMessage; std::unique_ptr Database = FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage); diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index e26679ceb730..6cabb22d98cf 100644 --- a/lld/COFF/Chunks.cpp +++ b/lld/COFF/Chunks.cpp @@ -947,7 +947,7 @@ MergeChunk::MergeChunk(uint32_t alignment) void MergeChunk::addSection(COFFLinkerContext &ctx, SectionChunk *c) { assert(isPowerOf2_32(c->getAlignment())); uint8_t p2Align = llvm::Log2_32(c->getAlignment()); - assert(p2Align < size(ctx.mergeChunkInstances)); + assert(p2Align < array_lengthof(ctx.mergeChunkInstances)); auto *&mc = ctx.mergeChunkInstances[p2Align]; if (!mc) mc = make(c->getAlignment()); diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index dfc9edefd7c6..f07bb9a7136a 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -77,7 +77,7 @@ static_assert((sizeof(g_format_infos) / sizeof(g_format_infos[0])) == kNumFormats, "All formats must have a corresponding info entry."); -static uint32_t g_num_format_infos = llvm::size(g_format_infos); +static uint32_t g_num_format_infos = llvm::array_lengthof(g_format_infos); static bool GetFormatFromFormatChar(char format_char, Format &format) { for (uint32_t i = 0; i < g_num_format_infos; ++i) { diff --git a/lldb/source/Host/common/MainLoop.cpp b/lldb/source/Host/common/MainLoop.cpp index c7e0abdf7f4e..d36587ce2346 100644 --- a/lldb/source/Host/common/MainLoop.cpp +++ b/lldb/source/Host/common/MainLoop.cpp @@ -108,7 +108,7 @@ Status MainLoop::RunImpl::Poll() { 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::size(out_events), nullptr); + out_events, llvm::array_lengthof(out_events), nullptr); if (num_events < 0) { if (errno == EINTR) { diff --git a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp index bbd471dea076..817663d6212e 100644 --- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -188,7 +188,7 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, .count() : INFINITE; DWORD wait_result = - ::WaitForMultipleObjects(llvm::size(m_event_handles), + ::WaitForMultipleObjects(llvm::array_lengthof(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. diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 9df7c578b669..59c23716bf89 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -549,7 +549,7 @@ void CommandInterpreter::LoadCommandDictionary() { "breakpoint set --name '%1'"}}; // clang-format on - size_t num_regexes = llvm::size(break_regexes); + size_t num_regexes = llvm::array_lengthof(break_regexes); std::unique_ptr break_regex_cmd_up( new CommandObjectRegexCommand( diff --git a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp index b21f5d4341fb..a8d1cbc675e3 100644 --- a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp @@ -1187,7 +1187,7 @@ static const RegisterInfo g_register_infos[] = { }}; static const uint32_t k_num_register_infos = - llvm::size(g_register_infos); + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * ABIMacOSX_arm::GetRegisterInfoArray(uint32_t &count) { @@ -1235,7 +1235,7 @@ bool ABIMacOSX_arm::PrepareTrivialCall(Thread &thread, addr_t sp, llvm::ArrayRef::iterator ai = args.begin(), ae = args.end(); - for (size_t i = 0; i < llvm::size(reg_names); ++i) { + for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { if (ai == ae) break; diff --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp index 87a643f77407..9ed042df4e50 100644 --- a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp +++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp @@ -1190,7 +1190,7 @@ static const RegisterInfo g_register_infos[] = { }}; static const uint32_t k_num_register_infos = - llvm::size(g_register_infos); + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * ABISysV_arm::GetRegisterInfoArray(uint32_t &count) { @@ -1240,7 +1240,7 @@ bool ABISysV_arm::PrepareTrivialCall(Thread &thread, addr_t sp, llvm::ArrayRef::iterator ai = args.begin(), ae = args.end(); - for (size_t i = 0; i < llvm::size(reg_names); ++i) { + for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { if (ai == ae) break; diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp index f06a3258f1e1..662689ca0615 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp @@ -503,7 +503,7 @@ static const RegisterInfo g_register_infos[] = { }; static const uint32_t k_num_register_infos = - llvm::size(g_register_infos); + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * ABISysV_mips::GetRegisterInfoArray(uint32_t &count) { @@ -559,7 +559,7 @@ bool ABISysV_mips::PrepareTrivialCall(Thread &thread, addr_t sp, llvm::ArrayRef::iterator ai = args.begin(), ae = args.end(); // Write arguments to registers - for (size_t i = 0; i < llvm::size(reg_names); ++i) { + for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { if (ai == ae) break; diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp index 7003667bf9dd..7e272265e15d 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp @@ -503,7 +503,7 @@ static const RegisterInfo g_register_infos_mips64[] = { }; static const uint32_t k_num_register_infos = - llvm::size(g_register_infos_mips64); + llvm::array_lengthof(g_register_infos_mips64); const lldb_private::RegisterInfo * ABISysV_mips64::GetRegisterInfoArray(uint32_t &count) { diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp index fc9596562023..70b9c46d353f 100644 --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp @@ -204,7 +204,7 @@ static const RegisterInfo g_register_infos[] = { }}; static const uint32_t k_num_register_infos = - llvm::size(g_register_infos); + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * ABISysV_ppc::GetRegisterInfoArray(uint32_t &count) { diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp index 9270ae57ac4e..f9a2851d3949 100644 --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp @@ -52,10 +52,10 @@ LLDB_PLUGIN_DEFINE(ABISysV_ppc64) const lldb_private::RegisterInfo * ABISysV_ppc64::GetRegisterInfoArray(uint32_t &count) { if (GetByteOrder() == lldb::eByteOrderLittle) { - count = llvm::size(g_register_infos_ppc64le); + count = llvm::array_lengthof(g_register_infos_ppc64le); return g_register_infos_ppc64le; } else { - count = llvm::size(g_register_infos_ppc64); + count = llvm::array_lengthof(g_register_infos_ppc64); return g_register_infos_ppc64; } } diff --git a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp index 986225ecf67a..f8156deb7e30 100644 --- a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp +++ b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp @@ -172,7 +172,7 @@ static const RegisterInfo g_register_infos[] = { }; static const uint32_t k_num_register_infos = - llvm::size(g_register_infos); + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * ABISysV_s390x::GetRegisterInfoArray(uint32_t &count) { diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 633c7e8c604d..a5abce7de3ae 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -405,7 +405,7 @@ DynamicLoaderDarwinKernel::ReadMachHeader(addr_t addr, Process *process, llvm::M 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::size (magicks); i++) + for (size_t i = 0; i < llvm::array_lengthof (magicks); i++) if (::memcmp (&header.magic, &magicks[i], sizeof (uint32_t)) == 0) found_matching_pattern = true; diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index 4b3a45e05dd0..5a238c5d4ac7 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -13198,7 +13198,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode, &EmulateInstructionARM::EmulateRFE, "rfe{} {!}"} }; - static const size_t k_num_arm_opcodes = llvm::size(g_arm_opcodes); + static const size_t k_num_arm_opcodes = llvm::array_lengthof(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::GetThumbOpcodeForInstruction(const uint32_t opcode, &EmulateInstructionARM::EmulateUXTH, "uxth.w ,{,}"}, }; - const size_t k_num_thumb_opcodes = llvm::size(g_thumb_opcodes); + const size_t k_num_thumb_opcodes = llvm::array_lengthof(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) diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp index 3cac8259ae28..f86609f3c5c1 100644 --- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -52,7 +52,7 @@ using namespace lldb_private; LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionARM64, InstructionARM64) static bool LLDBTableGetRegisterInfo(uint32_t reg_num, RegisterInfo ®_info) { - if (reg_num >= llvm::size(g_register_infos_arm64_le)) + if (reg_num >= llvm::array_lengthof(g_register_infos_arm64_le)) return false; reg_info = g_register_infos_arm64_le[reg_num]; return true; @@ -360,7 +360,7 @@ EmulateInstructionARM64::GetOpcodeForInstruction(const uint32_t opcode) { "TBNZ , #,