diff options
author | serge-sans-paille <sguelton@redhat.com> | 2022-01-26 10:11:12 -0500 |
---|---|---|
committer | serge-sans-paille <sguelton@redhat.com> | 2022-01-26 16:17:45 +0100 |
commit | ef8206320769ad31422a803a0d6de6077fd231d2 (patch) | |
tree | 06ca6445f38939d6a543e0a64c2ede55497a06cd /clang/lib | |
parent | 99ae5c13f64e138d6b17c00bd01c87c3ce58cb6b (diff) | |
download | llvm-ef8206320769ad31422a803a0d6de6077fd231d2.zip llvm-ef8206320769ad31422a803a0d6de6077fd231d2.tar.gz llvm-ef8206320769ad31422a803a0d6de6077fd231d2.tar.bz2 |
Rename llvm::array_lengthof into llvm::size to match std::size from C++17
As a conquence move llvm::array_lengthof from STLExtras.h to
STLForwardCompat.h (which is included by STLExtras.h so no build
breakage expected).
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/AttrDocTable.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/CommentCommandTraits.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Basic/DiagnosticIDs.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Basic/Targets/NVPTX.h | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGObjC.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Driver/Compilation.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Driver/Types.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/ParsedAttr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 2 |
18 files changed, 28 insertions, 28 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 9d63724..2111e93 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::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 && diff --git a/clang/lib/AST/AttrDocTable.cpp b/clang/lib/AST/AttrDocTable.cpp index 3bfedac..8f7e7ea 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::array_lengthof(AttrDoc)) + if(K < llvm::size(AttrDoc)) return AttrDoc[K]; return ""; } diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp index bdc0dd4..68f8006 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::array_lengthof(Commands)), Allocator(Allocator) { + NextID(llvm::size(Commands)), Allocator(Allocator) { registerCommentOptions(CommentOptions); } @@ -115,7 +115,7 @@ const CommandInfo *CommandTraits::registerBlockCommand(StringRef CommandName) { 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( const CommandInfo *CommandTraits::getRegisteredCommandInfo( unsigned CommandID) const { - return RegisteredCommands[CommandID - llvm::array_lengthof(Commands)]; + return RegisteredCommands[CommandID - llvm::size(Commands)]; } } // end namespace comments diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp index 87db131..3e6204a 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::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 @@ static const StaticDiagCategoryRec CategoryNameTable[] = { /// 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 diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h index 589f24f..83f220d 100644 --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/clang/lib/Basic/Targets/NVPTX.h @@ -159,7 +159,7 @@ public: /// DWARF. Optional<unsigned> 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]; diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 0fb7ec2..888f9e2 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::array_lengthof(SanitizerHandlers)); + size_t(CheckHandler) < llvm::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 index 8cc6091..a2c8f8e 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::array_lengthof(II), &II[0]); + CGM.getContext().Selectors.getSelector(llvm::size(II), &II[0]); QualType ItemsTy = getContext().getConstantArrayType(getContext().getObjCIdType(), diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index 67d941c..c479375 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::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]); } diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 7551ee4..cc6f721 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::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(); diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index f7da3f1..8fed215 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::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 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver, 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) diff --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp index 1bd187a..c5c17e1 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::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."); diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 1d0022b..23d2bec 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::array_lengthof(Buffer)) { + } else if (Tok.getLength() < llvm::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 index f21938c..d051699 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::array_lengthof(Args), Syntax); + ScopeName, ScopeLoc, Args, llvm::size(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::array_lengthof(Args), Syntax); + ScopeName, ScopeLoc, Args, llvm::size(Args), Syntax); } diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index de3d58b..d13f6e0 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::array_lengthof(F); ++I) { + for (unsigned I = 0; I < llvm::size(F); ++I) { if (DKind != F[I][0]) continue; diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index d4dc790..c595237 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::array_lengthof(TheDeclarator.InlineParams)) { + NumParams <= llvm::size(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::array_lengthof(InlineBindings)) { + Bindings.size() <= llvm::size(InlineBindings)) { BindingGroup.Bindings = InlineBindings; BindingGroup.DeleteBindings = false; InlineStorageUsed = true; diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp index 045847d..5c533f1 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::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. diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index af6ee24..219f2c0 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::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 void AddKeywordsToConsumer(Sema &SemaRef, 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 @@ static void AddKeywordsToConsumer(Sema &SemaRef, // 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]); diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index e43b3ca..8a0e26f 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -14357,7 +14357,7 @@ TreeTransform<Derived>::RebuildArrayType(QualType ElementType, 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])) { |