diff --git a/llvm/include/llvm/ADT/STLArrayExtras.h b/llvm/include/llvm/ADT/STLArrayExtras.h new file mode 100644 --- /dev/null +++ b/llvm/include/llvm/ADT/STLArrayExtras.h @@ -0,0 +1,35 @@ +//===- llvm/ADT/STLArrayExtras.h - additions to ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains some templates that are useful if you are working with the +// STL at all. +// +// No library is required when using these functions. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_STLARRAYEXTRAS_H +#define LLVM_ADT_STLARRAYEXTRAS_H + +#include + +namespace llvm { + +//===----------------------------------------------------------------------===// +// Extra additions for arrays +//===----------------------------------------------------------------------===// + +/// Find the length of an array. +template +constexpr inline size_t array_lengthof(T (&)[N]) { + return N; +} + +} // end namespace llvm + +#endif // LLVM_ADT_STLARRAYEXTRAS_H diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -18,6 +18,7 @@ #include "llvm/ADT/identity.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/STLArrayExtras.h" #include "llvm/ADT/STLForwardCompat.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/iterator.h" @@ -1410,7 +1411,7 @@ } //===----------------------------------------------------------------------===// -// Extra additions for arrays +// Extra additions to //===----------------------------------------------------------------------===// // We have a copy here so that LLVM behaves the same when using different @@ -1430,12 +1431,6 @@ } } -/// Find the length of an array. -template -constexpr inline size_t array_lengthof(T (&)[N]) { - return N; -} - /// Adapt std::less for array_pod_sort. template inline int array_pod_sort_comparator(const void *P1, const void *P2) { @@ -1563,10 +1558,6 @@ llvm::sort(adl_begin(C), adl_end(C), Comp); } -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - /// Get the size of a range. This is a wrapper function around std::distance /// which is only enabled when the operation is O(1). template diff --git a/llvm/lib/Support/ARMAttributeParser.cpp b/llvm/lib/Support/ARMAttributeParser.cpp --- a/llvm/lib/Support/ARMAttributeParser.cpp +++ b/llvm/lib/Support/ARMAttributeParser.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ARMAttributeParser.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLArrayExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/ScopedPrinter.h" diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp --- a/llvm/lib/Support/Signals.cpp +++ b/llvm/lib/Support/Signals.cpp @@ -15,7 +15,7 @@ #include "DebugOptions.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLArrayExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/CommandLine.h" diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/Triple.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLArrayExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/raw_ostream.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLArrayExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" #include "llvm/Support/Compiler.h"