[ADT] Skip initial empty string in StringTable iterator (#211808)
StringTable requires the first string to be empty, but this is never useful for users that iterate over all strings in the table. Skip it by default before drop_begin() on StringTable iteration scatters further throughout the code base.
This commit is contained in:
parent
ca78391cea
commit
03d3c7b049
4 changed files with 6 additions and 6 deletions
|
|
@ -140,7 +140,8 @@ public:
|
|||
Offset offset() const { return O; }
|
||||
};
|
||||
|
||||
constexpr Iterator begin() const { return Iterator(*this, 0); }
|
||||
// Skip empty string at the start.
|
||||
constexpr Iterator begin() const { return Iterator(*this, 1); }
|
||||
constexpr Iterator end() const { return Iterator(*this, size() - 1); }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -965,7 +965,7 @@ static StringRef sanitizeFunctionName(StringRef funcName) {
|
|||
static DenseMap<StringRef, LibFunc>
|
||||
buildIndexMap(const llvm::StringTable &StandardNames) {
|
||||
DenseMap<StringRef, LibFunc> Indices;
|
||||
unsigned Idx = 0;
|
||||
unsigned Idx = 1; // 0 is NotLibFunc.
|
||||
Indices.reserve(LibFunc::NumLibFuncs);
|
||||
for (const auto &Func : StandardNames)
|
||||
Indices[Func] = static_cast<LibFunc>(Idx++);
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ static void Help(StringTable CPUNames, ArrayRef<SubtargetFeatureKV> FeatTable) {
|
|||
|
||||
// Print the CPU table.
|
||||
errs() << "Available CPUs for this target:\n\n";
|
||||
for (auto &CPUName : drop_begin(CPUNames)) {
|
||||
for (auto &CPUName : CPUNames) {
|
||||
// Skip apple-latest, as that's only meant to be used in
|
||||
// disassemblers/debuggers, and we don't want normal code to be built with
|
||||
// it as an -mcpu=
|
||||
|
|
@ -159,7 +159,7 @@ static void cpuHelp(StringTable CPUNames) {
|
|||
|
||||
// Print the CPU table.
|
||||
errs() << "Available CPUs for this target:\n\n";
|
||||
for (auto &CPU : llvm::drop_begin(CPUNames)) {
|
||||
for (auto &CPU : CPUNames) {
|
||||
// Skip apple-latest, as that's only meant to be used in
|
||||
// disassemblers/debuggers, and we don't want normal code to be built with
|
||||
// it as an -mcpu=
|
||||
|
|
|
|||
|
|
@ -2864,7 +2864,7 @@ PassBuilder::parseRegAllocFilter(StringRef FilterName) {
|
|||
|
||||
LLVM_ATTRIBUTE_NOINLINE static void printPassNameList(StringTable PassNames,
|
||||
raw_ostream &OS) {
|
||||
for (StringRef PassName : drop_begin(PassNames))
|
||||
for (StringRef PassName : PassNames)
|
||||
OS << " " << PassName << '\n';
|
||||
}
|
||||
|
||||
|
|
@ -2872,7 +2872,6 @@ LLVM_ATTRIBUTE_NOINLINE static void
|
|||
printPassNameListWithParams(StringTable PassNames, raw_ostream &OS) {
|
||||
auto I = PassNames.begin();
|
||||
auto End = PassNames.end();
|
||||
++I;
|
||||
while (I != End) {
|
||||
StringRef Name = *I;
|
||||
++I;
|
||||
|
|
|
|||
Loading…
Reference in a new issue