/*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));
}
: 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));
}
: 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));
}
};
llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) {
- if(K < llvm::array_lengthof(AttrDoc))
+ if (K < std::size(AttrDoc))
return AttrDoc[K];
return "";
}
#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);
}
const CommandInfo *CommandTraits::getBuiltinCommandInfo(
unsigned CommandID) {
- if (CommandID < llvm::array_lengthof(Commands))
+ if (CommandID < std::size(Commands))
return &Commands[CommandID];
return nullptr;
}
const CommandInfo *CommandTraits::getRegisteredCommandInfo(
unsigned CommandID) const {
- return RegisteredCommands[CommandID - llvm::array_lengthof(Commands)];
+ return RegisteredCommands[CommandID - std::size(Commands)];
}
} // end namespace comments
} // 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.
/// 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
/// DWARF.
Optional<unsigned>
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];
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;
&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(),
"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()))
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)
#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.");
} 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);
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.
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,
// 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;
// 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;
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.
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<Token> Toks;
lexString(Sources[i], Toks);
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<Token> Toks;
lexString(Sources[i], Toks);
"// 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<Token> Toks;
lexString(Sources[i], Toks);
"/* 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<Token> Toks;
lexString(Sources[i], Toks);
"// 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<Token> Toks;
lexString(Sources[i], Toks);
// 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<Token> Toks;
lexString(Sources[i], Toks);
// 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<Token> Toks;
lexString(Sources[i], Toks);
// 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<Token> Toks;
lexString(Sources[i], Toks);
"::", ""
};
- 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<Token> 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)) {
"/** \\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<Token> Toks;
lexString(Sources[i], Toks);
"/** 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<Token> Toks;
lexString(Sources[i], Toks);
"/** 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<Token> Toks;
lexString(Sources[i], Toks);
"/** \\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<Token> Toks;
lexString(Sources[i], Toks);
"/** \\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<Token> Toks;
lexString(Sources[i], Toks);
"// <img "
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img src "
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img src ="
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img src = \'"
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img src=\'val\\\"\\'val\'"
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img src=\'val\\\"\\'val\'>"
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img />"
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"// <img / 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<Token> Toks;
lexString(Sources[i], Toks);
"// ="
};
- 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<Token> Toks;
lexString(Sources[i], Toks);
"*/"),
};
- 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));
"// 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));
"// 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));
"// 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));
"// 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));
"// 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));
"// <a >"
};
- 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));
"// <br />"
};
- 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));
"// <a href >",
};
- 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));
"// <a href=\"bbb\">",
};
- 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));
"// </a >"
};
- 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));
" *\\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));
" * \\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));
" * \\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));
" * 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));
"// \\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));
"/** \\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));
"/// @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));
"()", "[]"
};
- 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]);
"~", "!", "++", "--", "->"
};
- 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]);
// 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<CompilationDatabase> Database =
FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);