@@ -28,10 +28,9 @@ static std::string getPackageFullName(const Record *R, StringRef Sep = ".");
2828
2929static std::string getParentPackageFullName (const Record *R,
3030 StringRef Sep = " ." ) {
31- std::string name;
3231 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 " " ;
3534}
3635
3736static std::string getPackageFullName (const Record *R, StringRef Sep) {
@@ -52,10 +51,10 @@ static std::string getCheckerFullName(const Record *R, StringRef Sep = ".") {
5251 return name;
5352}
5453
55- static std::string getStringValue (const Record &R, StringRef field) {
54+ static StringRef getStringValue (const Record &R, StringRef field) {
5655 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 " " ;
5958}
6059
6160// Calculates the integer value representing the BitsInit object
@@ -93,7 +92,7 @@ static std::string getCheckerDocs(const Record &R) {
9392// / Retrieves the type from a CmdOptionTypeEnum typed Record object. Note that
9493// / the class itself has to be modified for adding a new option type in
9594// / CheckerBase.td.
96- static std::string getCheckerOptionType (const Record &R) {
95+ static StringRef getCheckerOptionType (const Record &R) {
9796 if (const BitsInit *BI = R.getValueAsBitsInit (" Type" )) {
9897 switch (getValueFromBitsInit (BI, R)) {
9998 case 0 :
@@ -110,7 +109,7 @@ static std::string getCheckerOptionType(const Record &R) {
110109 return " " ;
111110}
112111
113- static std::string getDevelopmentStage (const Record &R) {
112+ static StringRef getDevelopmentStage (const Record &R) {
114113 if (const BitsInit *BI = R.getValueAsBitsInit (" DevelopmentStage" )) {
115114 switch (getValueFromBitsInit (BI, R)) {
116115 case 0 :
@@ -179,8 +178,6 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
179178 ArrayRef<const Record *> packages =
180179 Records.getAllDerivedDefinitions (" Package" );
181180
182- using SortedRecords = StringMap<const Record *>;
183-
184181 OS << " // This file is automatically generated. Do not edit this file by "
185182 " hand.\n " ;
186183
@@ -191,16 +188,13 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
191188 OS << " \n "
192189 " #ifdef GET_PACKAGES\n " ;
193190 {
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) {
202196 OS << " PACKAGE(" << " \" " ;
203- OS.write_escaped (getPackageFullName (& R)) << ' \" ' ;
197+ OS.write_escaped (getPackageFullName (R)) << ' \" ' ;
204198 OS << " )\n " ;
205199 }
206200 }
@@ -225,7 +219,6 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
225219 OS << " \n "
226220 " #ifdef GET_PACKAGE_OPTIONS\n " ;
227221 for (const Record *Package : packages) {
228-
229222 if (Package->isValueUnset (" PackageOptions" ))
230223 continue ;
231224
@@ -250,9 +243,9 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
250243 OS << " \n "
251244 " #ifdef GET_CHECKERS\n "
252245 " \n " ;
253- for (const Record *checker : checkers) {
246+ for (const Record *checker : checkers)
254247 printChecker (OS, *checker);
255- }
248+
256249 OS << " \n "
257250 " #endif // GET_CHECKERS\n "
258251 " \n " ;
0 commit comments