@@ -28,10 +28,9 @@ static std::string getPackageFullName(const Record *R, StringRef Sep = ".");
28
28
29
29
static std::string getParentPackageFullName (const Record *R,
30
30
StringRef Sep = " ." ) {
31
- std::string name;
32
31
if (const DefInit *DI = dyn_cast<DefInit>(R->getValueInit (" ParentPackage" )))
33
- name = getPackageFullName (DI->getDef (), Sep);
34
- return name ;
32
+ return getPackageFullName (DI->getDef (), Sep);
33
+ return " " ;
35
34
}
36
35
37
36
static std::string getPackageFullName (const Record *R, StringRef Sep) {
@@ -52,10 +51,10 @@ static std::string getCheckerFullName(const Record *R, StringRef Sep = ".") {
52
51
return name;
53
52
}
54
53
55
- static std::string getStringValue (const Record &R, StringRef field) {
54
+ static StringRef getStringValue (const Record &R, StringRef field) {
56
55
if (const StringInit *SI = dyn_cast<StringInit>(R.getValueInit (field)))
57
- return std::string ( SI->getValue () );
58
- return std::string () ;
56
+ return SI->getValue ();
57
+ return " " ;
59
58
}
60
59
61
60
// Calculates the integer value representing the BitsInit object
@@ -93,7 +92,7 @@ static std::string getCheckerDocs(const Record &R) {
93
92
// / Retrieves the type from a CmdOptionTypeEnum typed Record object. Note that
94
93
// / the class itself has to be modified for adding a new option type in
95
94
// / CheckerBase.td.
96
- static std::string getCheckerOptionType (const Record &R) {
95
+ static StringRef getCheckerOptionType (const Record &R) {
97
96
if (const BitsInit *BI = R.getValueAsBitsInit (" Type" )) {
98
97
switch (getValueFromBitsInit (BI, R)) {
99
98
case 0 :
@@ -110,7 +109,7 @@ static std::string getCheckerOptionType(const Record &R) {
110
109
return " " ;
111
110
}
112
111
113
- static std::string getDevelopmentStage (const Record &R) {
112
+ static StringRef getDevelopmentStage (const Record &R) {
114
113
if (const BitsInit *BI = R.getValueAsBitsInit (" DevelopmentStage" )) {
115
114
switch (getValueFromBitsInit (BI, R)) {
116
115
case 0 :
@@ -179,8 +178,6 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
179
178
ArrayRef<const Record *> packages =
180
179
Records.getAllDerivedDefinitions (" Package" );
181
180
182
- using SortedRecords = StringMap<const Record *>;
183
-
184
181
OS << " // This file is automatically generated. Do not edit this file by "
185
182
" hand.\n " ;
186
183
@@ -191,16 +188,13 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
191
188
OS << " \n "
192
189
" #ifdef GET_PACKAGES\n " ;
193
190
{
194
- SortedRecords sortedPackages;
195
- for (unsigned i = 0 , e = packages.size (); i != e; ++i)
196
- sortedPackages[getPackageFullName (packages[i])] = packages[i];
197
-
198
- for (SortedRecords::iterator
199
- I = sortedPackages.begin (), E = sortedPackages.end (); I != E; ++I) {
200
- const Record &R = *I->second ;
201
-
191
+ StringMap<const Record *> sortedPackages;
192
+ for (const Record *Package : packages)
193
+ sortedPackages[getPackageFullName (Package)] = Package;
194
+
195
+ for (const auto &[_, R] : sortedPackages) {
202
196
OS << " PACKAGE(" << " \" " ;
203
- OS.write_escaped (getPackageFullName (& R)) << ' \" ' ;
197
+ OS.write_escaped (getPackageFullName (R)) << ' \" ' ;
204
198
OS << " )\n " ;
205
199
}
206
200
}
@@ -225,7 +219,6 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
225
219
OS << " \n "
226
220
" #ifdef GET_PACKAGE_OPTIONS\n " ;
227
221
for (const Record *Package : packages) {
228
-
229
222
if (Package->isValueUnset (" PackageOptions" ))
230
223
continue ;
231
224
@@ -250,9 +243,9 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
250
243
OS << " \n "
251
244
" #ifdef GET_CHECKERS\n "
252
245
" \n " ;
253
- for (const Record *checker : checkers) {
246
+ for (const Record *checker : checkers)
254
247
printChecker (OS, *checker);
255
- }
248
+
256
249
OS << " \n "
257
250
" #endif // GET_CHECKERS\n "
258
251
" \n " ;
0 commit comments