Skip to content

Commit 19fef5b

Browse files
committed
Do not serialize the input Twine more than once
1 parent 90eff5f commit 19fef5b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

llvm/include/llvm/TableGen/CodeGenHelpers.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace llvm {
2222
// Simple RAII helper for emitting ifdef-undef-endif scope.
2323
class IfDefEmitter {
2424
public:
25-
IfDefEmitter(raw_ostream &OS, const Twine &Name) : Name(Name.str()), OS(OS) {
25+
IfDefEmitter(raw_ostream &OS, const Twine &NameTwine)
26+
: Name(NameTwine.str()), OS(OS) {
2627
OS << "#ifdef " << Name << "\n"
2728
<< "#undef " << Name << "\n\n";
2829
}
@@ -36,8 +37,8 @@ class IfDefEmitter {
3637
// Simple RAII helper for emitting header include guard (ifndef-define-endif).
3738
class IncludeGuardEmitter {
3839
public:
39-
IncludeGuardEmitter(raw_ostream &OS, const Twine &Name)
40-
: Name(Name.str()), OS(OS) {
40+
IncludeGuardEmitter(raw_ostream &OS, const Twine &NameTwine)
41+
: Name(NameTwine.str()), OS(OS) {
4142
OS << "#ifndef " << Name << "\n"
4243
<< "#define " << Name << "\n\n";
4344
}
@@ -53,8 +54,8 @@ class IncludeGuardEmitter {
5354
// namespace scope.
5455
class NamespaceEmitter {
5556
public:
56-
NamespaceEmitter(raw_ostream &OS, const Twine &NameUntrimmed)
57-
: Name(trim(NameUntrimmed)), OS(OS) {
57+
NamespaceEmitter(raw_ostream &OS, const Twine &NameTwine)
58+
: Name(trim(NameTwine)), OS(OS) {
5859
if (!Name.empty())
5960
OS << "namespace " << Name << " {\n";
6061
}
@@ -76,8 +77,8 @@ class NamespaceEmitter {
7677
// }
7778
//
7879
// and cannot use "namespace ::mlir::toy".
79-
static std::string trim(const Twine &NameUntrimmed) {
80-
std::string Name = NameUntrimmed.str();
80+
static std::string trim(const Twine &NameTwine) {
81+
std::string Name = NameTwine.str();
8182
StringRef StrRef = Name;
8283
StrRef.consume_front("::");
8384
return StrRef.str();

0 commit comments

Comments
 (0)