Skip to content

Commit 1e18747

Browse files
[ObjectYAML] Remove redundant .str().c_str() (NFC) (#167154)
We can drop .str().c_str() here because all of the following are of type StringRef: - E.Name - the second parameter of llvm::yaml::IO::enumCase - the second parameter of llvm::yaml::IO::bitSetCase Identified with readability-redundant-string-cstr.
1 parent ae1622a commit 1e18747

File tree

2 files changed

+29
-39
lines changed

2 files changed

+29
-39
lines changed

llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,72 +80,65 @@ void ScalarEnumerationTraits<SymbolKind>::enumeration(IO &io,
8080
SymbolKind &Value) {
8181
auto SymbolNames = getSymbolTypeNames();
8282
for (const auto &E : SymbolNames)
83-
io.enumCase(Value, E.Name.str().c_str(), E.Value);
83+
io.enumCase(Value, E.Name, E.Value);
8484
}
8585

8686
void ScalarBitSetTraits<CompileSym2Flags>::bitset(IO &io,
8787
CompileSym2Flags &Flags) {
8888
auto FlagNames = getCompileSym2FlagNames();
8989
for (const auto &E : FlagNames) {
90-
io.bitSetCase(Flags, E.Name.str().c_str(),
91-
static_cast<CompileSym2Flags>(E.Value));
90+
io.bitSetCase(Flags, E.Name, static_cast<CompileSym2Flags>(E.Value));
9291
}
9392
}
9493

9594
void ScalarBitSetTraits<CompileSym3Flags>::bitset(IO &io,
9695
CompileSym3Flags &Flags) {
9796
auto FlagNames = getCompileSym3FlagNames();
9897
for (const auto &E : FlagNames) {
99-
io.bitSetCase(Flags, E.Name.str().c_str(),
100-
static_cast<CompileSym3Flags>(E.Value));
98+
io.bitSetCase(Flags, E.Name, static_cast<CompileSym3Flags>(E.Value));
10199
}
102100
}
103101

104102
void ScalarBitSetTraits<ExportFlags>::bitset(IO &io, ExportFlags &Flags) {
105103
auto FlagNames = getExportSymFlagNames();
106104
for (const auto &E : FlagNames) {
107-
io.bitSetCase(Flags, E.Name.str().c_str(),
108-
static_cast<ExportFlags>(E.Value));
105+
io.bitSetCase(Flags, E.Name, static_cast<ExportFlags>(E.Value));
109106
}
110107
}
111108

112109
void ScalarBitSetTraits<PublicSymFlags>::bitset(IO &io, PublicSymFlags &Flags) {
113110
auto FlagNames = getPublicSymFlagNames();
114111
for (const auto &E : FlagNames) {
115-
io.bitSetCase(Flags, E.Name.str().c_str(),
116-
static_cast<PublicSymFlags>(E.Value));
112+
io.bitSetCase(Flags, E.Name, static_cast<PublicSymFlags>(E.Value));
117113
}
118114
}
119115

120116
void ScalarBitSetTraits<LocalSymFlags>::bitset(IO &io, LocalSymFlags &Flags) {
121117
auto FlagNames = getLocalFlagNames();
122118
for (const auto &E : FlagNames) {
123-
io.bitSetCase(Flags, E.Name.str().c_str(),
124-
static_cast<LocalSymFlags>(E.Value));
119+
io.bitSetCase(Flags, E.Name, static_cast<LocalSymFlags>(E.Value));
125120
}
126121
}
127122

128123
void ScalarBitSetTraits<ProcSymFlags>::bitset(IO &io, ProcSymFlags &Flags) {
129124
auto FlagNames = getProcSymFlagNames();
130125
for (const auto &E : FlagNames) {
131-
io.bitSetCase(Flags, E.Name.str().c_str(),
132-
static_cast<ProcSymFlags>(E.Value));
126+
io.bitSetCase(Flags, E.Name, static_cast<ProcSymFlags>(E.Value));
133127
}
134128
}
135129

136130
void ScalarBitSetTraits<FrameProcedureOptions>::bitset(
137131
IO &io, FrameProcedureOptions &Flags) {
138132
auto FlagNames = getFrameProcSymFlagNames();
139133
for (const auto &E : FlagNames) {
140-
io.bitSetCase(Flags, E.Name.str().c_str(),
141-
static_cast<FrameProcedureOptions>(E.Value));
134+
io.bitSetCase(Flags, E.Name, static_cast<FrameProcedureOptions>(E.Value));
142135
}
143136
}
144137

145138
void ScalarEnumerationTraits<CPUType>::enumeration(IO &io, CPUType &Cpu) {
146139
auto CpuNames = getCPUTypeNames();
147140
for (const auto &E : CpuNames) {
148-
io.enumCase(Cpu, E.Name.str().c_str(), static_cast<CPUType>(E.Value));
141+
io.enumCase(Cpu, E.Name, static_cast<CPUType>(E.Value));
149142
}
150143
}
151144

@@ -177,7 +170,7 @@ void ScalarEnumerationTraits<RegisterId>::enumeration(IO &io, RegisterId &Reg) {
177170
RegNames = getRegisterNames(*CpuType);
178171

179172
for (const auto &E : RegNames) {
180-
io.enumCase(Reg, E.Name.str().c_str(), static_cast<RegisterId>(E.Value));
173+
io.enumCase(Reg, E.Name, static_cast<RegisterId>(E.Value));
181174
}
182175
io.enumFallback<Hex16>(Reg);
183176
}
@@ -186,34 +179,31 @@ void ScalarEnumerationTraits<TrampolineType>::enumeration(
186179
IO &io, TrampolineType &Tramp) {
187180
auto TrampNames = getTrampolineNames();
188181
for (const auto &E : TrampNames) {
189-
io.enumCase(Tramp, E.Name.str().c_str(),
190-
static_cast<TrampolineType>(E.Value));
182+
io.enumCase(Tramp, E.Name, static_cast<TrampolineType>(E.Value));
191183
}
192184
}
193185

194186
void ScalarEnumerationTraits<ThunkOrdinal>::enumeration(IO &io,
195187
ThunkOrdinal &Ord) {
196188
auto ThunkNames = getThunkOrdinalNames();
197189
for (const auto &E : ThunkNames) {
198-
io.enumCase(Ord, E.Name.str().c_str(), static_cast<ThunkOrdinal>(E.Value));
190+
io.enumCase(Ord, E.Name, static_cast<ThunkOrdinal>(E.Value));
199191
}
200192
}
201193

202194
void ScalarEnumerationTraits<FrameCookieKind>::enumeration(
203195
IO &io, FrameCookieKind &FC) {
204196
auto ThunkNames = getFrameCookieKindNames();
205197
for (const auto &E : ThunkNames) {
206-
io.enumCase(FC, E.Name.str().c_str(),
207-
static_cast<FrameCookieKind>(E.Value));
198+
io.enumCase(FC, E.Name, static_cast<FrameCookieKind>(E.Value));
208199
}
209200
}
210201

211202
void ScalarEnumerationTraits<JumpTableEntrySize>::enumeration(
212203
IO &io, JumpTableEntrySize &FC) {
213204
auto ThunkNames = getJumpTableEntrySizeNames();
214205
for (const auto &E : ThunkNames) {
215-
io.enumCase(FC, E.Name.str().c_str(),
216-
static_cast<JumpTableEntrySize>(E.Value));
206+
io.enumCase(FC, E.Name, static_cast<JumpTableEntrySize>(E.Value));
217207
}
218208
}
219209

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -589,55 +589,55 @@ void MappingTraits<DXContainerYAML::SignatureElement>::mapping(
589589
void ScalarEnumerationTraits<dxbc::PSV::SemanticKind>::enumeration(
590590
IO &IO, dxbc::PSV::SemanticKind &Value) {
591591
for (const auto &E : dxbc::PSV::getSemanticKinds())
592-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
592+
IO.enumCase(Value, E.Name, E.Value);
593593
}
594594

595595
void ScalarEnumerationTraits<dxbc::PSV::ComponentType>::enumeration(
596596
IO &IO, dxbc::PSV::ComponentType &Value) {
597597
for (const auto &E : dxbc::PSV::getComponentTypes())
598-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
598+
IO.enumCase(Value, E.Name, E.Value);
599599
}
600600

601601
void ScalarEnumerationTraits<dxbc::PSV::InterpolationMode>::enumeration(
602602
IO &IO, dxbc::PSV::InterpolationMode &Value) {
603603
for (const auto &E : dxbc::PSV::getInterpolationModes())
604-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
604+
IO.enumCase(Value, E.Name, E.Value);
605605
}
606606

607607
void ScalarEnumerationTraits<dxbc::PSV::ResourceType>::enumeration(
608608
IO &IO, dxbc::PSV::ResourceType &Value) {
609609
for (const auto &E : dxbc::PSV::getResourceTypes())
610-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
610+
IO.enumCase(Value, E.Name, E.Value);
611611
}
612612

613613
void ScalarEnumerationTraits<dxbc::PSV::ResourceKind>::enumeration(
614614
IO &IO, dxbc::PSV::ResourceKind &Value) {
615615
for (const auto &E : dxbc::PSV::getResourceKinds())
616-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
616+
IO.enumCase(Value, E.Name, E.Value);
617617
}
618618

619619
void ScalarEnumerationTraits<dxbc::D3DSystemValue>::enumeration(
620620
IO &IO, dxbc::D3DSystemValue &Value) {
621621
for (const auto &E : dxbc::getD3DSystemValues())
622-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
622+
IO.enumCase(Value, E.Name, E.Value);
623623
}
624624

625625
void ScalarEnumerationTraits<dxbc::SigMinPrecision>::enumeration(
626626
IO &IO, dxbc::SigMinPrecision &Value) {
627627
for (const auto &E : dxbc::getSigMinPrecisions())
628-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
628+
IO.enumCase(Value, E.Name, E.Value);
629629
}
630630

631631
void ScalarEnumerationTraits<dxbc::SigComponentType>::enumeration(
632632
IO &IO, dxbc::SigComponentType &Value) {
633633
for (const auto &E : dxbc::getSigComponentTypes())
634-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
634+
IO.enumCase(Value, E.Name, E.Value);
635635
}
636636

637637
void ScalarEnumerationTraits<dxbc::RootParameterType>::enumeration(
638638
IO &IO, dxbc::RootParameterType &Value) {
639639
for (const auto &E : dxbc::getRootParameterTypes())
640-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
640+
IO.enumCase(Value, E.Name, E.Value);
641641
}
642642

643643
void ScalarEnumerationTraits<dxil::ResourceClass>::enumeration(
@@ -650,37 +650,37 @@ void ScalarEnumerationTraits<dxil::ResourceClass>::enumeration(
650650
};
651651

652652
for (const auto &E : ResourceClasses)
653-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
653+
IO.enumCase(Value, E.Name, E.Value);
654654
}
655655

656656
void ScalarEnumerationTraits<dxbc::SamplerFilter>::enumeration(
657657
IO &IO, dxbc::SamplerFilter &Value) {
658658
for (const auto &E : dxbc::getSamplerFilters())
659-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
659+
IO.enumCase(Value, E.Name, E.Value);
660660
}
661661

662662
void ScalarEnumerationTraits<dxbc::StaticBorderColor>::enumeration(
663663
IO &IO, dxbc::StaticBorderColor &Value) {
664664
for (const auto &E : dxbc::getStaticBorderColors())
665-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
665+
IO.enumCase(Value, E.Name, E.Value);
666666
}
667667

668668
void ScalarEnumerationTraits<dxbc::TextureAddressMode>::enumeration(
669669
IO &IO, dxbc::TextureAddressMode &Value) {
670670
for (const auto &E : dxbc::getTextureAddressModes())
671-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
671+
IO.enumCase(Value, E.Name, E.Value);
672672
}
673673

674674
void ScalarEnumerationTraits<dxbc::ShaderVisibility>::enumeration(
675675
IO &IO, dxbc::ShaderVisibility &Value) {
676676
for (const auto &E : dxbc::getShaderVisibility())
677-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
677+
IO.enumCase(Value, E.Name, E.Value);
678678
}
679679

680680
void ScalarEnumerationTraits<dxbc::ComparisonFunc>::enumeration(
681681
IO &IO, dxbc::ComparisonFunc &Value) {
682682
for (const auto &E : dxbc::getComparisonFuncs())
683-
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
683+
IO.enumCase(Value, E.Name, E.Value);
684684
}
685685

686686
} // namespace yaml

0 commit comments

Comments
 (0)