@@ -54,19 +54,18 @@ class FlattenedSpelling {
54
54
const Record &OriginalSpelling;
55
55
56
56
public:
57
- FlattenedSpelling (const std::string &Variety, const std::string & Name,
57
+ FlattenedSpelling (const std::string &Variety, StringRef Name,
58
58
const std::string &Namespace, bool KnownToGCC,
59
59
const Record &OriginalSpelling)
60
- : V(Variety), N(Name), NS(Namespace), K(KnownToGCC),
60
+ : V(Variety), N(Name.str() ), NS(Namespace), K(KnownToGCC),
61
61
OriginalSpelling (OriginalSpelling) {}
62
62
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) {
66
65
assert (V != " GCC" && V != " Clang" &&
67
66
" Given a GCC spelling, which means this hasn't been flattened!" );
68
67
if (V == " CXX11" || V == " C23" || V == " Pragma" )
69
- NS = std::string ( Spelling.getValueAsString (" Namespace" ));
68
+ NS = Spelling.getValueAsString (" Namespace" ). str ( );
70
69
}
71
70
72
71
const std::string &variety () const { return V; }
@@ -105,15 +104,15 @@ GetFlattenedSpellings(const Record &Attr) {
105
104
StringRef Variety = Spelling->getValueAsString (" Variety" );
106
105
StringRef Name = Spelling->getValueAsString (" Name" );
107
106
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);
110
109
if (Spelling->getValueAsBit (" AllowInC" ))
111
- Ret.emplace_back (" C23" , std::string ( Name) , " gnu" , true , *Spelling);
110
+ Ret.emplace_back (" C23" , Name, " gnu" , true , *Spelling);
112
111
} 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);
115
114
if (Spelling->getValueAsBit (" AllowInC" ))
116
- Ret.emplace_back (" C23" , std::string ( Name) , " clang" , false , *Spelling);
115
+ Ret.emplace_back (" C23" , Name, " clang" , false , *Spelling);
117
116
} else
118
117
Ret.push_back (FlattenedSpelling (*Spelling));
119
118
}
@@ -123,9 +122,7 @@ GetFlattenedSpellings(const Record &Attr) {
123
122
124
123
static std::string ReadPCHRecord (StringRef type) {
125
124
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 () + " >()" )
129
126
.Case (" TypeSourceInfo *" , " Record.readTypeSourceInfo()" )
130
127
.Case (" Expr *" , " Record.readExpr()" )
131
128
.Case (" IdentifierInfo *" , " Record.readIdentifier()" )
@@ -146,18 +143,16 @@ static StringRef getStorageType(StringRef type) {
146
143
static std::string WritePCHRecord (StringRef type, StringRef name) {
147
144
return " Record." +
148
145
StringSwitch<std::string>(type)
149
- .EndsWith (" Decl *" , " AddDeclRef(" + std::string ( name) + " );\n " )
146
+ .EndsWith (" Decl *" , " AddDeclRef(" + name. str ( ) + " );\n " )
150
147
.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 " )
153
150
.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 " );
161
156
}
162
157
163
158
// Normalize attribute name by removing leading and trailing
@@ -198,7 +193,7 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
198
193
std::string AN;
199
194
if (Attr->isSubClassOf (" TargetSpecificAttr" ) &&
200
195
!Attr->isValueUnset (" ParseKind" )) {
201
- AN = std::string ( Attr->getValueAsString (" ParseKind" ));
196
+ AN = Attr->getValueAsString (" ParseKind" ). str ( );
202
197
203
198
// If this attribute has already been handled, it does not need to be
204
199
// handled again.
@@ -226,7 +221,7 @@ namespace {
226
221
227
222
public:
228
223
Argument (StringRef Arg, StringRef Attr)
229
- : lowerName(std::string( Arg)), upperName(lowerName), attrName(Attr),
224
+ : lowerName(Arg.str( )), upperName(lowerName), attrName(Attr),
230
225
isOpt (false ), Fake(false ) {
231
226
if (!lowerName.empty ()) {
232
227
lowerName[0 ] = std::tolower (lowerName[0 ]);
@@ -332,8 +327,7 @@ namespace {
332
327
333
328
void writePCHWrite (raw_ostream &OS) const override {
334
329
OS << " "
335
- << WritePCHRecord (type,
336
- " SA->get" + std::string (getUpperName ()) + " ()" );
330
+ << WritePCHRecord (type, " SA->get" + getUpperName ().str () + " ()" );
337
331
}
338
332
339
333
std::string getIsOmitted () const override {
@@ -699,12 +693,12 @@ namespace {
699
693
VariadicArgument (const Record &Arg, StringRef Attr, std::string T)
700
694
: Argument(Arg, Attr), Type(std::move(T)),
701
695
ArgName (getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
702
- RangeName(std::string( getLowerName())) {}
696
+ RangeName(getLowerName().str( )) {}
703
697
704
698
VariadicArgument (StringRef Arg, StringRef Attr, std::string T)
705
699
: Argument(Arg, Attr), Type(std::move(T)),
706
700
ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
707
- RangeName(std::string( getLowerName())) {}
701
+ RangeName(getLowerName().str( )) {}
708
702
709
703
const std::string &getType () const { return Type; }
710
704
const std::string &getArgName () const { return ArgName; }
@@ -793,8 +787,8 @@ namespace {
793
787
// If we can't store the values in the current type (if it's something
794
788
// like StringRef), store them in a different type and convert the
795
789
// 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 ( );
798
792
if (StorageType != getType ()) {
799
793
StorageName += " Storage" ;
800
794
OS << " SmallVector<" << StorageType << " , 4> "
@@ -1082,8 +1076,7 @@ namespace {
1082
1076
1083
1077
public:
1084
1078
VariadicEnumArgument (const Record &Arg, StringRef Attr)
1085
- : VariadicArgument(Arg, Attr,
1086
- std::string (Arg.getValueAsString(" Type" ))),
1079
+ : VariadicArgument(Arg, Attr, Arg.getValueAsString(" Type" ).str()),
1087
1080
values (Arg.getValueAsListOfStrings(" Values" )),
1088
1081
enums(Arg.getValueAsListOfStrings(" Enums" )),
1089
1082
uniques(uniqueEnumsInOrder(enums)),
@@ -1438,7 +1431,7 @@ namespace {
1438
1431
void writePCHWrite (raw_ostream &OS) const override {
1439
1432
OS << " "
1440
1433
<< WritePCHRecord (getType (),
1441
- " SA->get" + std::string ( getUpperName ()) + " Loc()" );
1434
+ " SA->get" + getUpperName (). str ( ) + " Loc()" );
1442
1435
}
1443
1436
};
1444
1437
@@ -1771,11 +1764,10 @@ static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) {
1771
1764
static bool
1772
1765
SpellingNamesAreCommon (const std::vector<FlattenedSpelling>& Spellings) {
1773
1766
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 ());
1776
1769
for (const auto &Spelling : drop_begin (Spellings)) {
1777
- std::string Name =
1778
- std::string (NormalizeNameForSpellingComparison (Spelling.name ()));
1770
+ StringRef Name = NormalizeNameForSpellingComparison (Spelling.name ());
1779
1771
if (Name != FirstName)
1780
1772
return false ;
1781
1773
}
@@ -1990,7 +1982,7 @@ struct AttributeSubjectMatchRule {
1990
1982
}
1991
1983
1992
1984
std::string getSpelling () const {
1993
- std::string Result = std::string ( MetaSubject->getValueAsString (" Name" ));
1985
+ std::string Result = MetaSubject->getValueAsString (" Name" ). str ( );
1994
1986
if (isSubRule ()) {
1995
1987
Result += ' (' ;
1996
1988
if (isNegatedSubRule ())
@@ -2750,7 +2742,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
2750
2742
for (const auto &[R, _] : reverse (Supers)) {
2751
2743
if (R->getName () != " TargetSpecificAttr" &&
2752
2744
R->getName () != " DeclOrTypeAttr" && SuperName.empty ())
2753
- SuperName = std::string ( R->getName ());
2745
+ SuperName = R->getName (). str ( );
2754
2746
if (R->getName () == " InheritableAttr" )
2755
2747
Inheritable = true ;
2756
2748
}
@@ -4086,9 +4078,9 @@ static void emitArgInfo(const Record &R, raw_ostream &OS) {
4086
4078
}
4087
4079
4088
4080
static std::string GetDiagnosticSpelling (const Record &R) {
4089
- std::string Ret = std::string ( R.getValueAsString (" DiagSpelling" ) );
4081
+ StringRef Ret = R.getValueAsString (" DiagSpelling" );
4090
4082
if (!Ret.empty ())
4091
- return Ret;
4083
+ return Ret. str () ;
4092
4084
4093
4085
// If we couldn't find the DiagSpelling in this object, we can check to see
4094
4086
// 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) {
4121
4113
SmallVector<StringRef, 2 > Frags;
4122
4114
SplitString (V, Frags, " ," );
4123
4115
for (auto Str : Frags) {
4124
- DiagList.push_back (std::string ( Str.trim ()));
4116
+ DiagList.push_back (Str.trim (). str ( ));
4125
4117
}
4126
4118
}
4127
4119
}
@@ -4152,7 +4144,7 @@ static std::string CalculateDiagnostic(const Record &S) {
4152
4144
}
4153
4145
4154
4146
static std::string GetSubjectWithSuffix (const Record *R) {
4155
- const std::string & B = std::string ( R->getName ());
4147
+ const std::string B = R->getName (). str ( );
4156
4148
if (B == " DeclBase" )
4157
4149
return " Decl" ;
4158
4150
return B + " Decl" ;
@@ -4861,7 +4853,7 @@ void EmitClangAttrParsedAttrKinds(const RecordKeeper &Records,
4861
4853
std::string AttrName;
4862
4854
if (Attr.isSubClassOf (" TargetSpecificAttr" ) &&
4863
4855
!Attr.isValueUnset (" ParseKind" )) {
4864
- AttrName = std::string ( Attr.getValueAsString (" ParseKind" ));
4856
+ AttrName = Attr.getValueAsString (" ParseKind" ). str ( );
4865
4857
if (!Seen.insert (AttrName).second )
4866
4858
continue ;
4867
4859
} else
@@ -5134,7 +5126,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
5134
5126
" documented" );
5135
5127
5136
5128
// 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 ( );
5138
5130
if (Heading.empty ()) {
5139
5131
// If there's only one spelling, we can simply use that.
5140
5132
if (Spellings.size () == 1 )
@@ -5144,7 +5136,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
5144
5136
for (auto I = Spellings.begin (), E = Spellings.end ();
5145
5137
I != E; ++I) {
5146
5138
std::string Spelling =
5147
- std::string ( NormalizeNameForSpellingComparison (I->name ()));
5139
+ NormalizeNameForSpellingComparison (I->name ()). str ( );
5148
5140
Uniques.insert (Spelling);
5149
5141
}
5150
5142
// If the semantic map has only one spelling, that is sufficient for our
0 commit comments