@@ -122,9 +122,7 @@ GetFlattenedSpellings(const Record &Attr) {
122122
123123static std::string ReadPCHRecord (StringRef type) {
124124 return StringSwitch<std::string>(type)
125- .EndsWith (" Decl *" , " Record.readDeclAs<" +
126- std::string (type.data (), 0 , type.size () - 1 ) +
127- " >()" )
125+ .EndsWith (" Decl *" , " Record.readDeclAs<" + type.drop_back ().str () + " >()" )
128126 .Case (" TypeSourceInfo *" , " Record.readTypeSourceInfo()" )
129127 .Case (" Expr *" , " Record.readExpr()" )
130128 .Case (" IdentifierInfo *" , " Record.readIdentifier()" )
@@ -145,18 +143,16 @@ static StringRef getStorageType(StringRef type) {
145143static std::string WritePCHRecord (StringRef type, StringRef name) {
146144 return " Record." +
147145 StringSwitch<std::string>(type)
148- .EndsWith (" Decl *" , " AddDeclRef(" + std::string ( name) + " );\n " )
146+ .EndsWith (" Decl *" , " AddDeclRef(" + name. str ( ) + " );\n " )
149147 .Case (" TypeSourceInfo *" ,
150- " AddTypeSourceInfo(" + std::string ( name) + " );\n " )
151- .Case (" Expr *" , " AddStmt(" + std::string ( name) + " );\n " )
148+ " AddTypeSourceInfo(" + name. str ( ) + " );\n " )
149+ .Case (" Expr *" , " AddStmt(" + name. str ( ) + " );\n " )
152150 .Case (" IdentifierInfo *" ,
153- " AddIdentifierRef(" + std::string (name) + " );\n " )
154- .Case (" StringRef" , " AddString(" + std::string (name) + " );\n " )
155- .Case (" ParamIdx" ,
156- " push_back(" + std::string (name) + " .serialize());\n " )
157- .Case (" OMPTraitInfo *" ,
158- " writeOMPTraitInfo(" + std::string (name) + " );\n " )
159- .Default (" push_back(" + std::string (name) + " );\n " );
151+ " AddIdentifierRef(" + name.str () + " );\n " )
152+ .Case (" StringRef" , " AddString(" + name.str () + " );\n " )
153+ .Case (" ParamIdx" , " push_back(" + name.str () + " .serialize());\n " )
154+ .Case (" OMPTraitInfo *" , " writeOMPTraitInfo(" + name.str () + " );\n " )
155+ .Default (" push_back(" + name.str () + " );\n " );
160156}
161157
162158// Normalize attribute name by removing leading and trailing
@@ -197,7 +193,7 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
197193 std::string AN;
198194 if (Attr->isSubClassOf (" TargetSpecificAttr" ) &&
199195 !Attr->isValueUnset (" ParseKind" )) {
200- AN = std::string ( Attr->getValueAsString (" ParseKind" ));
196+ AN = Attr->getValueAsString (" ParseKind" ). str ( );
201197
202198 // If this attribute has already been handled, it does not need to be
203199 // handled again.
@@ -225,7 +221,7 @@ namespace {
225221
226222 public:
227223 Argument (StringRef Arg, StringRef Attr)
228- : lowerName(std::string( Arg)), upperName(lowerName), attrName(Attr),
224+ : lowerName(Arg.str( )), upperName(lowerName), attrName(Attr),
229225 isOpt (false ), Fake(false ) {
230226 if (!lowerName.empty ()) {
231227 lowerName[0 ] = std::tolower (lowerName[0 ]);
@@ -331,8 +327,7 @@ namespace {
331327
332328 void writePCHWrite (raw_ostream &OS) const override {
333329 OS << " "
334- << WritePCHRecord (type,
335- " SA->get" + std::string (getUpperName ()) + " ()" );
330+ << WritePCHRecord (type, " SA->get" + getUpperName ().str () + " ()" );
336331 }
337332
338333 std::string getIsOmitted () const override {
@@ -698,12 +693,12 @@ namespace {
698693 VariadicArgument (const Record &Arg, StringRef Attr, std::string T)
699694 : Argument(Arg, Attr), Type(std::move(T)),
700695 ArgName (getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
701- RangeName(std::string( getLowerName())) {}
696+ RangeName(getLowerName().str( )) {}
702697
703698 VariadicArgument (StringRef Arg, StringRef Attr, std::string T)
704699 : Argument(Arg, Attr), Type(std::move(T)),
705700 ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
706- RangeName(std::string( getLowerName())) {}
701+ RangeName(getLowerName().str( )) {}
707702
708703 const std::string &getType () const { return Type; }
709704 const std::string &getArgName () const { return ArgName; }
@@ -792,8 +787,8 @@ namespace {
792787 // If we can't store the values in the current type (if it's something
793788 // like StringRef), store them in a different type and convert the
794789 // container afterwards.
795- std::string StorageType = std::string ( getStorageType (getType ()));
796- std::string StorageName = std::string ( getLowerName ());
790+ std::string StorageType = getStorageType (getType ()). str ( );
791+ std::string StorageName = getLowerName (). str ( );
797792 if (StorageType != getType ()) {
798793 StorageName += " Storage" ;
799794 OS << " SmallVector<" << StorageType << " , 4> "
@@ -1081,8 +1076,7 @@ namespace {
10811076
10821077 public:
10831078 VariadicEnumArgument (const Record &Arg, StringRef Attr)
1084- : VariadicArgument(Arg, Attr,
1085- std::string (Arg.getValueAsString(" Type" ))),
1079+ : VariadicArgument(Arg, Attr, Arg.getValueAsString(" Type" ).str()),
10861080 values (Arg.getValueAsListOfStrings(" Values" )),
10871081 enums(Arg.getValueAsListOfStrings(" Enums" )),
10881082 uniques(uniqueEnumsInOrder(enums)),
@@ -1437,7 +1431,7 @@ namespace {
14371431 void writePCHWrite (raw_ostream &OS) const override {
14381432 OS << " "
14391433 << WritePCHRecord (getType (),
1440- " SA->get" + std::string ( getUpperName ()) + " Loc()" );
1434+ " SA->get" + getUpperName (). str ( ) + " Loc()" );
14411435 }
14421436 };
14431437
@@ -1766,11 +1760,10 @@ static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) {
17661760static bool
17671761SpellingNamesAreCommon (const std::vector<FlattenedSpelling>& Spellings) {
17681762 assert (!Spellings.empty () && " An empty list of spellings was provided" );
1769- std::string FirstName =
1770- std::string ( NormalizeNameForSpellingComparison (Spellings.front ().name () ));
1763+ StringRef FirstName =
1764+ NormalizeNameForSpellingComparison (Spellings.front ().name ());
17711765 for (const auto &Spelling : drop_begin (Spellings)) {
1772- std::string Name =
1773- std::string (NormalizeNameForSpellingComparison (Spelling.name ()));
1766+ StringRef Name = NormalizeNameForSpellingComparison (Spelling.name ());
17741767 if (Name != FirstName)
17751768 return false ;
17761769 }
@@ -1985,7 +1978,7 @@ struct AttributeSubjectMatchRule {
19851978 }
19861979
19871980 std::string getSpelling () const {
1988- std::string Result = std::string ( MetaSubject->getValueAsString (" Name" ));
1981+ std::string Result = MetaSubject->getValueAsString (" Name" ). str ( );
19891982 if (isSubRule ()) {
19901983 Result += ' (' ;
19911984 if (isNegatedSubRule ())
@@ -2728,7 +2721,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
27282721 for (const auto &[R, _] : reverse (Supers)) {
27292722 if (R->getName () != " TargetSpecificAttr" &&
27302723 R->getName () != " DeclOrTypeAttr" && SuperName.empty ())
2731- SuperName = std::string ( R->getName ());
2724+ SuperName = R->getName (). str ( );
27322725 if (R->getName () == " InheritableAttr" )
27332726 Inheritable = true ;
27342727 }
@@ -4054,9 +4047,9 @@ static void emitArgInfo(const Record &R, raw_ostream &OS) {
40544047}
40554048
40564049static std::string GetDiagnosticSpelling (const Record &R) {
4057- std::string Ret = std::string ( R.getValueAsString (" DiagSpelling" ) );
4050+ StringRef Ret = R.getValueAsString (" DiagSpelling" );
40584051 if (!Ret.empty ())
4059- return Ret;
4052+ return Ret. str () ;
40604053
40614054 // If we couldn't find the DiagSpelling in this object, we can check to see
40624055 // if the object is one that has a base, and if it is, loop up to the Base
@@ -4089,7 +4082,7 @@ static std::string CalculateDiagnostic(const Record &S) {
40894082 SmallVector<StringRef, 2 > Frags;
40904083 SplitString (V, Frags, " ," );
40914084 for (auto Str : Frags) {
4092- DiagList.push_back (std::string ( Str.trim ()));
4085+ DiagList.push_back (Str.trim (). str ( ));
40934086 }
40944087 }
40954088 }
@@ -4120,7 +4113,7 @@ static std::string CalculateDiagnostic(const Record &S) {
41204113}
41214114
41224115static std::string GetSubjectWithSuffix (const Record *R) {
4123- const std::string & B = std::string ( R->getName ());
4116+ const std::string B = R->getName (). str ( );
41244117 if (B == " DeclBase" )
41254118 return " Decl" ;
41264119 return B + " Decl" ;
@@ -5107,7 +5100,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
51075100 " documented" );
51085101
51095102 // Determine the heading to be used for this attribute.
5110- std::string Heading = std::string ( Documentation.getValueAsString (" Heading" ));
5103+ std::string Heading = Documentation.getValueAsString (" Heading" ). str ( );
51115104 if (Heading.empty ()) {
51125105 // If there's only one spelling, we can simply use that.
51135106 if (Spellings.size () == 1 )
@@ -5117,7 +5110,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
51175110 for (auto I = Spellings.begin (), E = Spellings.end ();
51185111 I != E; ++I) {
51195112 std::string Spelling =
5120- std::string ( NormalizeNameForSpellingComparison (I->name ()));
5113+ NormalizeNameForSpellingComparison (I->name ()). str ( );
51215114 Uniques.insert (Spelling);
51225115 }
51235116 // If the semantic map has only one spelling, that is sufficient for our
0 commit comments