Skip to content

Commit 70f9a81

Browse files
authored
[utils][TableGen] Clean up code in DirectiveEmitter (#140772)
Remove most redundant function calls. Unify enum identifier name generation (via getIdentifierName), and namespace qualification (via getQualifier).
1 parent 32f8132 commit 70f9a81

File tree

2 files changed

+235
-229
lines changed

2 files changed

+235
-229
lines changed

llvm/include/llvm/TableGen/DirectiveEmitter.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,23 @@ class BaseRecord {
113113

114114
// Returns the name of the directive formatted for output. Whitespace are
115115
// replaced with underscores.
116-
static std::string getFormattedName(const Record *R) {
117-
StringRef Name = R->getValueAsString("name");
116+
static std::string formatName(StringRef Name) {
118117
std::string N = Name.str();
119118
llvm::replace(N, ' ', '_');
120119
return N;
121120
}
122121

123-
std::string getFormattedName() const { return getFormattedName(Def); }
122+
std::string getFormattedName() const {
123+
return formatName(Def->getValueAsString("name"));
124+
}
124125

125126
bool isDefault() const { return Def->getValueAsBit("isDefault"); }
126127

127128
// Returns the record name.
128129
StringRef getRecordName() const { return Def->getName(); }
129130

131+
const Record *getRecord() const { return Def; }
132+
130133
protected:
131134
const Record *Def;
132135
};

0 commit comments

Comments
 (0)