@@ -122,9 +122,7 @@ GetFlattenedSpellings(const Record &Attr) {
122
122
123
123
static std::string ReadPCHRecord (StringRef type) {
124
124
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 () + " >()" )
128
126
.Case (" TypeSourceInfo *" , " Record.readTypeSourceInfo()" )
129
127
.Case (" Expr *" , " Record.readExpr()" )
130
128
.Case (" IdentifierInfo *" , " Record.readIdentifier()" )
@@ -145,18 +143,16 @@ static StringRef getStorageType(StringRef type) {
145
143
static std::string WritePCHRecord (StringRef type, StringRef name) {
146
144
return " Record." +
147
145
StringSwitch<std::string>(type)
148
- .EndsWith (" Decl *" , " AddDeclRef(" + std::string ( name) + " );\n " )
146
+ .EndsWith (" Decl *" , " AddDeclRef(" + name. str ( ) + " );\n " )
149
147
.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 " )
152
150
.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 " );
160
156
}
161
157
162
158
// Normalize attribute name by removing leading and trailing
@@ -197,7 +193,7 @@ static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
197
193
std::string AN;
198
194
if (Attr->isSubClassOf (" TargetSpecificAttr" ) &&
199
195
!Attr->isValueUnset (" ParseKind" )) {
200
- AN = std::string ( Attr->getValueAsString (" ParseKind" ));
196
+ AN = Attr->getValueAsString (" ParseKind" ). str ( );
201
197
202
198
// If this attribute has already been handled, it does not need to be
203
199
// handled again.
@@ -225,7 +221,7 @@ namespace {
225
221
226
222
public:
227
223
Argument (StringRef Arg, StringRef Attr)
228
- : lowerName(std::string( Arg)), upperName(lowerName), attrName(Attr),
224
+ : lowerName(Arg.str( )), upperName(lowerName), attrName(Attr),
229
225
isOpt (false ), Fake(false ) {
230
226
if (!lowerName.empty ()) {
231
227
lowerName[0 ] = std::tolower (lowerName[0 ]);
@@ -331,8 +327,7 @@ namespace {
331
327
332
328
void writePCHWrite (raw_ostream &OS) const override {
333
329
OS << " "
334
- << WritePCHRecord (type,
335
- " SA->get" + std::string (getUpperName ()) + " ()" );
330
+ << WritePCHRecord (type, " SA->get" + getUpperName ().str () + " ()" );
336
331
}
337
332
338
333
std::string getIsOmitted () const override {
@@ -698,12 +693,12 @@ namespace {
698
693
VariadicArgument (const Record &Arg, StringRef Attr, std::string T)
699
694
: Argument(Arg, Attr), Type(std::move(T)),
700
695
ArgName (getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
701
- RangeName(std::string( getLowerName())) {}
696
+ RangeName(getLowerName().str( )) {}
702
697
703
698
VariadicArgument (StringRef Arg, StringRef Attr, std::string T)
704
699
: Argument(Arg, Attr), Type(std::move(T)),
705
700
ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + " Size" ),
706
- RangeName(std::string( getLowerName())) {}
701
+ RangeName(getLowerName().str( )) {}
707
702
708
703
const std::string &getType () const { return Type; }
709
704
const std::string &getArgName () const { return ArgName; }
@@ -792,8 +787,8 @@ namespace {
792
787
// If we can't store the values in the current type (if it's something
793
788
// like StringRef), store them in a different type and convert the
794
789
// 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 ( );
797
792
if (StorageType != getType ()) {
798
793
StorageName += " Storage" ;
799
794
OS << " SmallVector<" << StorageType << " , 4> "
@@ -1081,8 +1076,7 @@ namespace {
1081
1076
1082
1077
public:
1083
1078
VariadicEnumArgument (const Record &Arg, StringRef Attr)
1084
- : VariadicArgument(Arg, Attr,
1085
- std::string (Arg.getValueAsString(" Type" ))),
1079
+ : VariadicArgument(Arg, Attr, Arg.getValueAsString(" Type" ).str()),
1086
1080
values (Arg.getValueAsListOfStrings(" Values" )),
1087
1081
enums(Arg.getValueAsListOfStrings(" Enums" )),
1088
1082
uniques(uniqueEnumsInOrder(enums)),
@@ -1437,7 +1431,7 @@ namespace {
1437
1431
void writePCHWrite (raw_ostream &OS) const override {
1438
1432
OS << " "
1439
1433
<< WritePCHRecord (getType (),
1440
- " SA->get" + std::string ( getUpperName ()) + " Loc()" );
1434
+ " SA->get" + getUpperName (). str ( ) + " Loc()" );
1441
1435
}
1442
1436
};
1443
1437
@@ -1766,11 +1760,10 @@ static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) {
1766
1760
static bool
1767
1761
SpellingNamesAreCommon (const std::vector<FlattenedSpelling>& Spellings) {
1768
1762
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 ());
1771
1765
for (const auto &Spelling : drop_begin (Spellings)) {
1772
- std::string Name =
1773
- std::string (NormalizeNameForSpellingComparison (Spelling.name ()));
1766
+ StringRef Name = NormalizeNameForSpellingComparison (Spelling.name ());
1774
1767
if (Name != FirstName)
1775
1768
return false ;
1776
1769
}
@@ -1985,7 +1978,7 @@ struct AttributeSubjectMatchRule {
1985
1978
}
1986
1979
1987
1980
std::string getSpelling () const {
1988
- std::string Result = std::string ( MetaSubject->getValueAsString (" Name" ));
1981
+ std::string Result = MetaSubject->getValueAsString (" Name" ). str ( );
1989
1982
if (isSubRule ()) {
1990
1983
Result += ' (' ;
1991
1984
if (isNegatedSubRule ())
@@ -2728,7 +2721,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
2728
2721
for (const auto &[R, _] : reverse (Supers)) {
2729
2722
if (R->getName () != " TargetSpecificAttr" &&
2730
2723
R->getName () != " DeclOrTypeAttr" && SuperName.empty ())
2731
- SuperName = std::string ( R->getName ());
2724
+ SuperName = R->getName (). str ( );
2732
2725
if (R->getName () == " InheritableAttr" )
2733
2726
Inheritable = true ;
2734
2727
}
@@ -4054,9 +4047,9 @@ static void emitArgInfo(const Record &R, raw_ostream &OS) {
4054
4047
}
4055
4048
4056
4049
static std::string GetDiagnosticSpelling (const Record &R) {
4057
- std::string Ret = std::string ( R.getValueAsString (" DiagSpelling" ) );
4050
+ StringRef Ret = R.getValueAsString (" DiagSpelling" );
4058
4051
if (!Ret.empty ())
4059
- return Ret;
4052
+ return Ret. str () ;
4060
4053
4061
4054
// If we couldn't find the DiagSpelling in this object, we can check to see
4062
4055
// 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) {
4089
4082
SmallVector<StringRef, 2 > Frags;
4090
4083
SplitString (V, Frags, " ," );
4091
4084
for (auto Str : Frags) {
4092
- DiagList.push_back (std::string ( Str.trim ()));
4085
+ DiagList.push_back (Str.trim (). str ( ));
4093
4086
}
4094
4087
}
4095
4088
}
@@ -4120,7 +4113,7 @@ static std::string CalculateDiagnostic(const Record &S) {
4120
4113
}
4121
4114
4122
4115
static std::string GetSubjectWithSuffix (const Record *R) {
4123
- const std::string & B = std::string ( R->getName ());
4116
+ const std::string B = R->getName (). str ( );
4124
4117
if (B == " DeclBase" )
4125
4118
return " Decl" ;
4126
4119
return B + " Decl" ;
@@ -5107,7 +5100,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
5107
5100
" documented" );
5108
5101
5109
5102
// 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 ( );
5111
5104
if (Heading.empty ()) {
5112
5105
// If there's only one spelling, we can simply use that.
5113
5106
if (Spellings.size () == 1 )
@@ -5117,7 +5110,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
5117
5110
for (auto I = Spellings.begin (), E = Spellings.end ();
5118
5111
I != E; ++I) {
5119
5112
std::string Spelling =
5120
- std::string ( NormalizeNameForSpellingComparison (I->name ()));
5113
+ NormalizeNameForSpellingComparison (I->name ()). str ( );
5121
5114
Uniques.insert (Spelling);
5122
5115
}
5123
5116
// If the semantic map has only one spelling, that is sufficient for our
0 commit comments