@@ -75,10 +75,11 @@ static AttributeMap collectAttributeMacros(const SpecMap &Spec,
75
75
const FuncList &Funcs) {
76
76
llvm::DenseMap<llvm::StringRef, llvm::Record *> MacroAttr;
77
77
for (const auto &Name : Funcs) {
78
- if (!Spec.count (Name))
78
+ auto Iter = Spec.find (Name);
79
+ if (Iter == Spec.end ())
79
80
continue ;
80
81
81
- llvm::Record *FunctionSpec = Spec. at (Name) ;
82
+ llvm::Record *FunctionSpec = Iter-> second ;
82
83
std::vector<llvm::Record *> Attributes =
83
84
FunctionSpec->getValueAsListOfDefs (" Attributes" );
84
85
for (llvm::Record *Attr : Attributes)
@@ -180,7 +181,7 @@ static void writeAPIFromIndex(APIIndexer &G,
180
181
llvm::raw_ostream &OS) {
181
182
for (auto &Pair : G.MacroDefsMap ) {
182
183
const std::string &Name = Pair.first ;
183
- if (G.MacroSpecMap .find (Name) == G. MacroSpecMap . end ( ))
184
+ if (! G.MacroSpecMap .count (Name))
184
185
llvm::PrintFatalError (Name + " not found in any standard spec.\n " );
185
186
186
187
llvm::Record *MacroDef = Pair.second ;
@@ -190,7 +191,7 @@ static void writeAPIFromIndex(APIIndexer &G,
190
191
}
191
192
192
193
for (auto &TypeName : G.RequiredTypes ) {
193
- if (G.TypeSpecMap .find (TypeName) == G. TypeSpecMap . end ( ))
194
+ if (! G.TypeSpecMap .count (TypeName))
194
195
llvm::PrintFatalError (TypeName + " not found in any standard spec.\n " );
195
196
OS << " #include <llvm-libc-types/" << getTypeHdrName (TypeName) << " .h>\n " ;
196
197
}
@@ -222,16 +223,18 @@ static void writeAPIFromIndex(APIIndexer &G,
222
223
223
224
OS << " __BEGIN_C_DECLS\n\n " ;
224
225
for (auto &Name : EntrypointNameList) {
225
- if (G.FunctionSpecMap .find (Name) == G.FunctionSpecMap .end ()) {
226
- continue ; // Functions that aren't in this header file are skipped as
227
- // opposed to erroring out because the list of functions being
228
- // iterated over is the complete list of functions with
229
- // entrypoints. Thus this is filtering out the functions that
230
- // don't go to this header file, whereas the other, similar
231
- // conditionals above are more of a sanity check.
232
- }
226
+ auto Iter = G.FunctionSpecMap .find (Name);
227
+
228
+ // Functions that aren't in this header file are skipped as
229
+ // opposed to erroring out because the list of functions being
230
+ // iterated over is the complete list of functions with
231
+ // entrypoints. Thus this is filtering out the functions that
232
+ // don't go to this header file, whereas the other, similar
233
+ // conditionals above are more of a sanity check.
234
+ if (Iter == G.FunctionSpecMap .end ())
235
+ continue ;
233
236
234
- llvm::Record *FunctionSpec = G. FunctionSpecMap [Name] ;
237
+ llvm::Record *FunctionSpec = Iter-> second ;
235
238
llvm::Record *RetValSpec = FunctionSpec->getValueAsDef (" Return" );
236
239
llvm::Record *ReturnType = RetValSpec->getValueAsDef (" ReturnType" );
237
240
@@ -252,9 +255,10 @@ static void writeAPIFromIndex(APIIndexer &G,
252
255
253
256
// Make another pass over entrypoints to emit object declarations.
254
257
for (const auto &Name : EntrypointNameList) {
255
- if (G.ObjectSpecMap .find (Name) == G.ObjectSpecMap .end ())
258
+ auto Iter = G.ObjectSpecMap .find (Name);
259
+ if (Iter == G.ObjectSpecMap .end ())
256
260
continue ;
257
- llvm::Record *ObjectSpec = G. ObjectSpecMap [Name] ;
261
+ llvm::Record *ObjectSpec = Iter-> second ;
258
262
auto Type = ObjectSpec->getValueAsString (" Type" );
259
263
OS << " extern " << Type << " " << Name << " ;\n " ;
260
264
}
@@ -272,9 +276,8 @@ void PublicAPICommand::run(llvm::raw_ostream &OS, const ArgVector &Args,
272
276
llvm::StringRef StdHeader,
273
277
llvm::RecordKeeper &Records,
274
278
const Command::ErrorReporter &Reporter) const {
275
- if (Args.size () != 0 ) {
279
+ if (Args.size () != 0 )
276
280
Reporter.printFatalError (" public_api command does not take any arguments." );
277
- }
278
281
279
282
APIIndexer G (StdHeader, Records);
280
283
writeAPIFromIndex (G, EntrypointNameList, OS);
0 commit comments