@@ -60,7 +60,7 @@ class ClangOpcodesEmitter {
60
60
void Enumerate (const Record *R, StringRef N,
61
61
std::function<void (ArrayRef<const Record *>, Twine)> &&F) {
62
62
llvm::SmallVector<const Record *, 2 > TypePath;
63
- auto *Types = R->getValueAsListInit (" Types" );
63
+ const auto *Types = R->getValueAsListInit (" Types" );
64
64
65
65
std::function<void (size_t , const Twine &)> Rec;
66
66
Rec = [&TypePath, Types, &Rec, &F](size_t I, const Twine &ID) {
@@ -69,8 +69,9 @@ void Enumerate(const Record *R, StringRef N,
69
69
return ;
70
70
}
71
71
72
- if (auto *TypeClass = dyn_cast<DefInit>(Types->getElement (I))) {
73
- for (auto *Type : TypeClass->getDef ()->getValueAsListOfDefs (" Types" )) {
72
+ if (const auto *TypeClass = dyn_cast<DefInit>(Types->getElement (I))) {
73
+ for (const auto *Type :
74
+ TypeClass->getDef ()->getValueAsListOfDefs (" Types" )) {
74
75
TypePath.push_back (Type);
75
76
Rec (I + 1 , ID + Type->getName ());
76
77
TypePath.pop_back ();
@@ -85,7 +86,7 @@ void Enumerate(const Record *R, StringRef N,
85
86
} // namespace
86
87
87
88
void ClangOpcodesEmitter::run (raw_ostream &OS) {
88
- for (auto *Opcode : Records.getAllDerivedDefinitions (Root.getName ())) {
89
+ for (const auto *Opcode : Records.getAllDerivedDefinitions (Root.getName ())) {
89
90
// The name is the record name, unless overriden.
90
91
StringRef N = Opcode->getValueAsString (" Name" );
91
92
if (N.empty ())
@@ -118,7 +119,7 @@ void ClangOpcodesEmitter::EmitInterp(raw_ostream &OS, StringRef N,
118
119
[this , R, &OS, &N](ArrayRef<const Record *> TS, const Twine &ID) {
119
120
bool CanReturn = R->getValueAsBit (" CanReturn" );
120
121
bool ChangesPC = R->getValueAsBit (" ChangesPC" );
121
- auto Args = R->getValueAsListOfDefs (" Args" );
122
+ const auto & Args = R->getValueAsListOfDefs (" Args" );
122
123
123
124
OS << " case OP_" << ID << " : {\n " ;
124
125
@@ -171,7 +172,7 @@ void ClangOpcodesEmitter::EmitDisasm(raw_ostream &OS, StringRef N,
171
172
OS << " PrintName(\" " << ID << " \" );\n " ;
172
173
OS << " OS << \"\\ t\" " ;
173
174
174
- for (auto *Arg : R->getValueAsListOfDefs (" Args" )) {
175
+ for (const auto *Arg : R->getValueAsListOfDefs (" Args" )) {
175
176
OS << " << ReadArg<" << Arg->getValueAsString (" Name" ) << " >(P, PC)" ;
176
177
OS << " << \" \" " ;
177
178
}
@@ -189,7 +190,7 @@ void ClangOpcodesEmitter::EmitEmitter(raw_ostream &OS, StringRef N,
189
190
190
191
OS << " #ifdef GET_LINK_IMPL\n " ;
191
192
Enumerate (R, N, [R, &OS](ArrayRef<const Record *>, const Twine &ID) {
192
- auto Args = R->getValueAsListOfDefs (" Args" );
193
+ const auto & Args = R->getValueAsListOfDefs (" Args" );
193
194
194
195
// Emit the list of arguments.
195
196
OS << " bool ByteCodeEmitter::emit" << ID << " (" ;
@@ -236,7 +237,7 @@ void ClangOpcodesEmitter::EmitProto(raw_ostream &OS, StringRef N,
236
237
}
237
238
OS << " >\n " ;
238
239
OS << " bool emit" << N << " (" ;
239
- for (auto *Arg : Args)
240
+ for (const auto *Arg : Args)
240
241
OS << Arg->getValueAsString (" Name" ) << " , " ;
241
242
OS << " const SourceInfo &);\n " ;
242
243
OS << " #endif\n " ;
@@ -250,8 +251,8 @@ void ClangOpcodesEmitter::EmitGroup(raw_ostream &OS, StringRef N,
250
251
if (!R->getValueAsBit (" HasGroup" ))
251
252
return ;
252
253
253
- auto *Types = R->getValueAsListInit (" Types" );
254
- auto Args = R->getValueAsListOfDefs (" Args" );
254
+ const auto *Types = R->getValueAsListInit (" Types" );
255
+ const auto & Args = R->getValueAsListOfDefs (" Args" );
255
256
256
257
Twine EmitFuncName = " emit" + N;
257
258
0 commit comments