@@ -54,19 +54,18 @@ class FlattenedSpelling {
5454 const Record &OriginalSpelling;
5555
5656public:
57- FlattenedSpelling (const std::string &Variety, const std::string & Name,
57+ FlattenedSpelling (const std::string &Variety, StringRef Name,
5858 const std::string &Namespace, bool KnownToGCC,
5959 const Record &OriginalSpelling)
60- : V(Variety), N(Name), NS(Namespace), K(KnownToGCC),
60+ : V(Variety), N(Name.str() ), NS(Namespace), K(KnownToGCC),
6161 OriginalSpelling (OriginalSpelling) {}
6262 explicit FlattenedSpelling (const Record &Spelling)
63- : V(std::string(Spelling.getValueAsString(" Variety" ))),
64- N(std::string(Spelling.getValueAsString(" Name" ))),
65- OriginalSpelling(Spelling) {
63+ : V(Spelling.getValueAsString(" Variety" ).str()),
64+ N(Spelling.getValueAsString(" Name" ).str()), OriginalSpelling(Spelling) {
6665 assert (V != " GCC" && V != " Clang" &&
6766 " Given a GCC spelling, which means this hasn't been flattened!" );
6867 if (V == " CXX11" || V == " C23" || V == " Pragma" )
69- NS = std::string ( Spelling.getValueAsString (" Namespace" ));
68+ NS = Spelling.getValueAsString (" Namespace" ). str ( );
7069 }
7170
7271 const std::string &variety () const { return V; }
@@ -105,15 +104,15 @@ GetFlattenedSpellings(const Record &Attr) {
105104 StringRef Variety = Spelling->getValueAsString (" Variety" );
106105 StringRef Name = Spelling->getValueAsString (" Name" );
107106 if (Variety == " GCC" ) {
108- Ret.emplace_back (" GNU" , std::string ( Name) , " " , true , *Spelling);
109- Ret.emplace_back (" CXX11" , std::string ( Name) , " gnu" , true , *Spelling);
107+ Ret.emplace_back (" GNU" , Name, " " , true , *Spelling);
108+ Ret.emplace_back (" CXX11" , Name, " gnu" , true , *Spelling);
110109 if (Spelling->getValueAsBit (" AllowInC" ))
111- Ret.emplace_back (" C23" , std::string ( Name) , " gnu" , true , *Spelling);
110+ Ret.emplace_back (" C23" , Name, " gnu" , true , *Spelling);
112111 } else if (Variety == " Clang" ) {
113- Ret.emplace_back (" GNU" , std::string ( Name) , " " , false , *Spelling);
114- Ret.emplace_back (" CXX11" , std::string ( Name) , " clang" , false , *Spelling);
112+ Ret.emplace_back (" GNU" , Name, " " , false , *Spelling);
113+ Ret.emplace_back (" CXX11" , Name, " clang" , false , *Spelling);
115114 if (Spelling->getValueAsBit (" AllowInC" ))
116- Ret.emplace_back (" C23" , std::string ( Name) , " clang" , false , *Spelling);
115+ Ret.emplace_back (" C23" , Name, " clang" , false , *Spelling);
117116 } else
118117 Ret.push_back (FlattenedSpelling (*Spelling));
119118 }
@@ -123,9 +122,7 @@ GetFlattenedSpellings(const Record &Attr) {
123122
124123static std::string ReadPCHRecord (StringRef type) {
125124 return StringSwitch<std::string>(type)
126- .EndsWith (" Decl *" , " Record.readDeclAs<" +
127- std::string (type.data (), 0 , type.size () - 1 ) +
128- " >()" )
125+ .EndsWith (" Decl *" , " Record.readDeclAs<" + type.drop_back ().str () + " >()" )
129126 .Case (" TypeSourceInfo *" , " Record.readTypeSourceInfo()" )
130127 .Case (" Expr *" , " Record.readExpr()" )
131128 .Case (" IdentifierInfo *" , " Record.readIdentifier()" )
@@ -146,18 +143,16 @@ static StringRef getStorageType(StringRef type) {
146143static std::string WritePCHRecord (StringRef type, StringRef name) {
147144 return " Record." +
148145 StringSwitch<std::string>(type)
149- .EndsWith (" Decl *" , " AddDeclRef(" + std::string ( name) + " );\n " )
146+ .EndsWith (" Decl *" , " AddDeclRef(" + name. str ( ) + " );\n " )
150147 .Case (" TypeSourceInfo *" ,
151- " AddTypeSourceInfo(" + std::string ( name) + " );\n " )
152- .Case (" Expr *" , " AddStmt(" + std::string ( name) + " );\n " )
148+ " AddTypeSourceInfo(" + name. str ( ) + " );\n " )
149+ .Case (" Expr *" , " AddStmt(" + name. str ( ) + " );\n " )
153150 .Case (" IdentifierInfo *" ,
154- " AddIdentifierRef(" + std::string (name) + " );\n " )
155- .Case (" StringRef" , " AddString(" + std::string (name) + " );\n " )
156- .Case (" ParamIdx" ,
157- " push_back(" + std::string (name) + " .serialize());\n " )
158- .Case (" OMPTraitInfo *" ,
159- " writeOMPTraitInfo(" + std::string (name) + " );\n " )
160- .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 " );
161156}
162157
163158// Normalize attribute name by removing leading and trailing
@@ -198,7 +193,7 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
198193 std::string AN;
199194 if (Attr->isSubClassOf (" TargetSpecificAttr" ) &&
200195 !Attr->isValueUnset (" ParseKind" )) {
201- AN = std::string ( Attr->getValueAsString (" ParseKind" ));
196+ AN = Attr->getValueAsString (" ParseKind" ). str ( );
202197
203198 // If this attribute has already been handled, it does not need to be
204199 // handled again.
@@ -226,7 +221,7 @@ namespace {
226221
227222 public:
228223 Argument (StringRef Arg, StringRef Attr)
229- : lowerName(std::string( Arg)), upperName(lowerName), attrName(Attr),
224+ : lowerName(Arg.str( )), upperName(lowerName), attrName(Attr),
230225 isOpt (false ), Fake(false ) {
231226 if (!lowerName.empty ()) {
232227 lowerName[0 ] = std::tolower (lowerName[0 ]);
@@ -332,8 +327,7 @@ namespace {
332327
333328 void writePCHWrite (raw_ostream &OS) const override {
334329 OS << " "
335- << WritePCHRecord (type,
336- " SA->get" + std::string (getUpperName ()) + " ()" );
330+ << WritePCHRecord (type, " SA->get" + getUpperName ().str () + " ()" );
337331 }
338332
339333 std::string getIsOmitted () const override {
@@ -699,12 +693,12 @@ namespace {
699693 VariadicArgument (const Record &Arg, StringRef Attr, std::string T)
700694 : Argument(Arg, Attr), Type(std::move(T)),
701695 ArgName (getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
702- RangeName(std::string( getLowerName())) {}
696+ RangeName(getLowerName().str( )) {}
703697
704698 VariadicArgument (StringRef Arg, StringRef Attr, std::string T)
705699 : Argument(Arg, Attr), Type(std::move(T)),
706700 ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
707- RangeName(std::string( getLowerName())) {}
701+ RangeName(getLowerName().str( )) {}
708702
709703 const std::string &getType () const { return Type; }
710704 const std::string &getArgName () const { return ArgName; }
@@ -793,8 +787,8 @@ namespace {
793787 // If we can't store the values in the current type (if it's something
794788 // like StringRef), store them in a different type and convert the
795789 // container afterwards.
796- std::string StorageType = std::string ( getStorageType (getType ()));
797- std::string StorageName = std::string ( getLowerName ());
790+ std::string StorageType = getStorageType (getType ()). str ( );
791+ std::string StorageName = getLowerName (). str ( );
798792 if (StorageType != getType ()) {
799793 StorageName += " Storage" ;
800794 OS << " SmallVector<" << StorageType << " , 4> "
@@ -1082,8 +1076,7 @@ namespace {
10821076
10831077 public:
10841078 VariadicEnumArgument (const Record &Arg, StringRef Attr)
1085- : VariadicArgument(Arg, Attr,
1086- std::string (Arg.getValueAsString(" Type" ))),
1079+ : VariadicArgument(Arg, Attr, Arg.getValueAsString(" Type" ).str()),
10871080 values (Arg.getValueAsListOfStrings(" Values" )),
10881081 enums(Arg.getValueAsListOfStrings(" Enums" )),
10891082 uniques(uniqueEnumsInOrder(enums)),
@@ -1438,7 +1431,7 @@ namespace {
14381431 void writePCHWrite (raw_ostream &OS) const override {
14391432 OS << " "
14401433 << WritePCHRecord (getType (),
1441- " SA->get" + std::string ( getUpperName ()) + " Loc()" );
1434+ " SA->get" + getUpperName (). str ( ) + " Loc()" );
14421435 }
14431436 };
14441437
@@ -1771,11 +1764,10 @@ static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) {
17711764static bool
17721765SpellingNamesAreCommon (const std::vector<FlattenedSpelling>& Spellings) {
17731766 assert (!Spellings.empty () && " An empty list of spellings was provided" );
1774- std::string FirstName =
1775- std::string ( NormalizeNameForSpellingComparison (Spellings.front ().name () ));
1767+ StringRef FirstName =
1768+ NormalizeNameForSpellingComparison (Spellings.front ().name ());
17761769 for (const auto &Spelling : drop_begin (Spellings)) {
1777- std::string Name =
1778- std::string (NormalizeNameForSpellingComparison (Spelling.name ()));
1770+ StringRef Name = NormalizeNameForSpellingComparison (Spelling.name ());
17791771 if (Name != FirstName)
17801772 return false ;
17811773 }
@@ -1990,7 +1982,7 @@ struct AttributeSubjectMatchRule {
19901982 }
19911983
19921984 std::string getSpelling () const {
1993- std::string Result = std::string ( MetaSubject->getValueAsString (" Name" ));
1985+ std::string Result = MetaSubject->getValueAsString (" Name" ). str ( );
19941986 if (isSubRule ()) {
19951987 Result += ' (' ;
19961988 if (isNegatedSubRule ())
@@ -2750,7 +2742,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
27502742 for (const auto &[R, _] : reverse (Supers)) {
27512743 if (R->getName () != " TargetSpecificAttr" &&
27522744 R->getName () != " DeclOrTypeAttr" && SuperName.empty ())
2753- SuperName = std::string ( R->getName ());
2745+ SuperName = R->getName (). str ( );
27542746 if (R->getName () == " InheritableAttr" )
27552747 Inheritable = true ;
27562748 }
@@ -4086,9 +4078,9 @@ static void emitArgInfo(const Record &R, raw_ostream &OS) {
40864078}
40874079
40884080static std::string GetDiagnosticSpelling (const Record &R) {
4089- std::string Ret = std::string ( R.getValueAsString (" DiagSpelling" ) );
4081+ StringRef Ret = R.getValueAsString (" DiagSpelling" );
40904082 if (!Ret.empty ())
4091- return Ret;
4083+ return Ret. str () ;
40924084
40934085 // If we couldn't find the DiagSpelling in this object, we can check to see
40944086 // if the object is one that has a base, and if it is, loop up to the Base
@@ -4121,7 +4113,7 @@ static std::string CalculateDiagnostic(const Record &S) {
41214113 SmallVector<StringRef, 2 > Frags;
41224114 SplitString (V, Frags, " ," );
41234115 for (auto Str : Frags) {
4124- DiagList.push_back (std::string ( Str.trim ()));
4116+ DiagList.push_back (Str.trim (). str ( ));
41254117 }
41264118 }
41274119 }
@@ -4152,7 +4144,7 @@ static std::string CalculateDiagnostic(const Record &S) {
41524144}
41534145
41544146static std::string GetSubjectWithSuffix (const Record *R) {
4155- const std::string & B = std::string ( R->getName ());
4147+ const std::string B = R->getName (). str ( );
41564148 if (B == " DeclBase" )
41574149 return " Decl" ;
41584150 return B + " Decl" ;
@@ -4861,7 +4853,7 @@ void EmitClangAttrParsedAttrKinds(const RecordKeeper &Records,
48614853 std::string AttrName;
48624854 if (Attr.isSubClassOf (" TargetSpecificAttr" ) &&
48634855 !Attr.isValueUnset (" ParseKind" )) {
4864- AttrName = std::string ( Attr.getValueAsString (" ParseKind" ));
4856+ AttrName = Attr.getValueAsString (" ParseKind" ). str ( );
48654857 if (!Seen.insert (AttrName).second )
48664858 continue ;
48674859 } else
@@ -5134,7 +5126,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
51345126 " documented" );
51355127
51365128 // Determine the heading to be used for this attribute.
5137- std::string Heading = std::string ( Documentation.getValueAsString (" Heading" ));
5129+ std::string Heading = Documentation.getValueAsString (" Heading" ). str ( );
51385130 if (Heading.empty ()) {
51395131 // If there's only one spelling, we can simply use that.
51405132 if (Spellings.size () == 1 )
@@ -5144,7 +5136,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
51445136 for (auto I = Spellings.begin (), E = Spellings.end ();
51455137 I != E; ++I) {
51465138 std::string Spelling =
5147- std::string ( NormalizeNameForSpellingComparison (I->name ()));
5139+ NormalizeNameForSpellingComparison (I->name ()). str ( );
51485140 Uniques.insert (Spelling);
51495141 }
51505142 // If the semantic map has only one spelling, that is sufficient for our
0 commit comments