15
15
#ifndef LLVM_UTILS_TABLEGEN_BASIC_SEQUENCETOOFFSETTABLE_H
16
16
#define LLVM_UTILS_TABLEGEN_BASIC_SEQUENCETOOFFSETTABLE_H
17
17
18
+ #include " llvm/ADT/StringExtras.h"
18
19
#include " llvm/Support/CommandLine.h"
19
20
#include " llvm/Support/raw_ostream.h"
20
21
#include < algorithm>
21
22
#include < cassert>
22
- #include < cctype>
23
23
#include < functional>
24
24
#include < map>
25
25
26
26
namespace llvm {
27
- extern llvm:: cl::opt<bool > EmitLongStrLiterals;
27
+ extern cl::opt<bool > EmitLongStrLiterals;
28
28
29
- static inline void printChar (raw_ostream &OS, char C) {
29
+ inline void printChar (raw_ostream &OS, char C) {
30
30
unsigned char UC (C);
31
- if (isalnum (UC) || ispunct (UC)) {
31
+ if (isAlnum (UC) || isPunct (UC)) {
32
32
OS << ' \' ' ;
33
33
if (C == ' \\ ' || C == ' \' ' )
34
34
OS << ' \\ ' ;
@@ -126,7 +126,7 @@ class SequenceToOffsetTable {
126
126
// / initializer, where each element is a C string literal terminated by
127
127
// / `\0`. Falls back to emitting a comma-separated integer list if
128
128
// / `EmitLongStrLiterals` is false
129
- void emitStringLiteralDef (raw_ostream &OS, const llvm:: Twine &Decl) const {
129
+ void emitStringLiteralDef (raw_ostream &OS, const Twine &Decl) const {
130
130
assert (Entries && " Call layout() before emitStringLiteralDef()" );
131
131
if (!EmitLongStrLiterals) {
132
132
OS << Decl << " = {\n " ;
@@ -140,9 +140,9 @@ class SequenceToOffsetTable {
140
140
<< " #pragma GCC diagnostic ignored \" -Woverlength-strings\"\n "
141
141
<< " #endif\n "
142
142
<< Decl << " = {\n " ;
143
- for (auto I : Seqs) {
144
- OS << " /* " << I. second << " */ \" " ;
145
- OS.write_escaped (I. first );
143
+ for (const auto &[Seq, Offset] : Seqs) {
144
+ OS << " /* " << Offset << " */ \" " ;
145
+ OS.write_escaped (Seq );
146
146
OS << " \\ 0\"\n " ;
147
147
}
148
148
OS << " };\n "
@@ -156,13 +156,10 @@ class SequenceToOffsetTable {
156
156
void emit (raw_ostream &OS, void (*Print)(raw_ostream &, ElemT),
157
157
const char *Term = "0") const {
158
158
assert ((empty () || Entries) && " Call layout() before emit()" );
159
- for (typename SeqMap::const_iterator I = Seqs.begin (), E = Seqs.end ();
160
- I != E; ++I) {
161
- OS << " /* " << I->second << " */ " ;
162
- for (typename SeqT::const_iterator SI = I->first .begin (),
163
- SE = I->first .end ();
164
- SI != SE; ++SI) {
165
- Print (OS, *SI);
159
+ for (const auto &[Seq, Offset] : Seqs) {
160
+ OS << " /* " << Offset << " */ " ;
161
+ for (const ElemT &Element : Seq) {
162
+ Print (OS, Element);
166
163
OS << " , " ;
167
164
}
168
165
OS << Term << " ,\n " ;
0 commit comments