Skip to content

Commit e7b2850

Browse files
committed
[SIL][Remarks] Use camelCase for fields, arguments, and variables
1 parent 350d0c3 commit e7b2850

File tree

2 files changed

+162
-159
lines changed

2 files changed

+162
-159
lines changed

include/swift/SIL/OptimizationRemark.h

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ namespace OptRemark {
3434
/// Used in the streaming interface as the general argument type. It
3535
/// internally converts everything into a key-value pair.
3636
struct Argument {
37-
std::string Key;
38-
std::string Val;
37+
std::string key;
38+
std::string val;
3939
/// If set, the debug location corresponding to the value.
40-
SourceLoc Loc;
40+
SourceLoc loc;
4141

42-
explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
43-
Argument(StringRef Key, StringRef Val) : Key(Key), Val(Val) {}
42+
explicit Argument(StringRef Str = "") : key("String"), val(Str) {}
43+
Argument(StringRef key, StringRef val) : key(key), val(val) {}
4444

45-
Argument(StringRef Key, int N);
46-
Argument(StringRef Key, long N);
47-
Argument(StringRef Key, long long N);
48-
Argument(StringRef Key, unsigned N);
49-
Argument(StringRef Key, unsigned long N);
50-
Argument(StringRef Key, unsigned long long N);
45+
Argument(StringRef key, int n);
46+
Argument(StringRef key, long n);
47+
Argument(StringRef key, long long n);
48+
Argument(StringRef key, unsigned n);
49+
Argument(StringRef key, unsigned long n);
50+
Argument(StringRef key, unsigned long long n);
5151

52-
Argument(StringRef Key, SILFunction *F);
53-
Argument(StringRef Key, SILType Ty);
54-
Argument(StringRef Key, CanType Ty);
52+
Argument(StringRef key, SILFunction *f);
53+
Argument(StringRef key, SILType ty);
54+
Argument(StringRef key, CanType ty);
5555
};
5656

5757
/// Shorthand to insert named-value pairs.
@@ -60,132 +60,133 @@ using NV = Argument;
6060
/// Inserting this into a Remark indents the text when printed as a debug
6161
/// message.
6262
struct IndentDebug {
63-
explicit IndentDebug(unsigned Width) : Width(Width) {}
64-
unsigned Width;
63+
explicit IndentDebug(unsigned width) : width(width) {}
64+
unsigned width;
6565
};
6666

6767
/// The base class for remarks. This can be created by optimization passed to
6868
/// report successful and unsuccessful optimizations. CRTP is used to preserve
6969
/// the underlying type encoding the remark kind in the insertion operator.
7070
template <typename DerivedT> class Remark {
7171
/// Arguments collected via the streaming interface.
72-
SmallVector<Argument, 4> Args;
72+
SmallVector<Argument, 4> args;
7373

7474
/// The name of the pass generating the remark.
75-
StringRef PassName;
75+
StringRef passName;
7676

7777
/// Textual identifier for the remark (single-word, camel-case). Can be used
7878
/// by external tools reading the YAML output file for optimization remarks to
7979
/// identify the remark.
80-
StringRef Identifier;
80+
StringRef identifier;
8181

8282
/// Source location for the diagnostics.
83-
SourceLoc Location;
83+
SourceLoc location;
8484

8585
/// The function for the diagnostics.
86-
SILFunction *Function;
86+
SILFunction *function;
8787

8888
/// Indentation used if this remarks is printed as a debug message.
89-
unsigned IndentDebugWidth = 0;
89+
unsigned indentDebugWidth = 0;
9090

9191
protected:
92-
Remark(StringRef Identifier, SILInstruction &I)
93-
: Identifier(Identifier), Location(I.getLoc().getSourceLoc()),
94-
Function(I.getParent()->getParent()) {}
92+
Remark(StringRef identifier, SILInstruction &i)
93+
: identifier(identifier), location(i.getLoc().getSourceLoc()),
94+
function(i.getParent()->getParent()) {}
9595

9696
public:
97-
DerivedT &operator<<(StringRef S) {
98-
Args.emplace_back(S);
97+
DerivedT &operator<<(StringRef s) {
98+
args.emplace_back(s);
9999
return *static_cast<DerivedT *>(this);
100100
}
101101

102-
DerivedT &operator<<(Argument A) {
103-
Args.push_back(std::move(A));
102+
DerivedT &operator<<(Argument a) {
103+
args.push_back(std::move(a));
104104
return *static_cast<DerivedT *>(this);
105105
}
106106

107-
DerivedT &operator<<(IndentDebug ID) {
108-
IndentDebugWidth = ID.Width;
107+
DerivedT &operator<<(IndentDebug indent) {
108+
indentDebugWidth = indent.width;
109109
return *static_cast<DerivedT *>(this);
110110
}
111111

112-
StringRef getPassName() const { return PassName; }
113-
StringRef getIdentifier() const { return Identifier; }
114-
SILFunction *getFunction() const { return Function; }
115-
SourceLoc getLocation() const { return Location; }
112+
StringRef getPassName() const { return passName; }
113+
StringRef getIdentifier() const { return identifier; }
114+
SILFunction *getFunction() const { return function; }
115+
SourceLoc getLocation() const { return location; }
116116
std::string getMsg() const;
117117
std::string getDebugMsg() const;
118118
Remark<DerivedT> &getRemark() { return *this; }
119-
SmallVector<Argument, 4> &getArgs() { return Args; }
119+
SmallVector<Argument, 4> &getArgs() { return args; }
120120

121-
void setPassName(StringRef PN) { PassName = PN; }
121+
void setPassName(StringRef name) { passName = name; }
122122
};
123123

124124
/// Remark to report a successful optimization.
125125
struct RemarkPassed : public Remark<RemarkPassed> {
126-
RemarkPassed(StringRef Id, SILInstruction &I) : Remark(Id, I) {}
126+
RemarkPassed(StringRef id, SILInstruction &i) : Remark(id, i) {}
127127
};
128128
/// Remark to report a unsuccessful optimization.
129129
struct RemarkMissed : public Remark<RemarkMissed> {
130-
RemarkMissed(StringRef Id, SILInstruction &I) : Remark(Id, I) {}
130+
RemarkMissed(StringRef id, SILInstruction &i) : Remark(id, i) {}
131131
};
132132

133133
/// Used to emit the remarks. Passes reporting remarks should create an
134134
/// instance of this.
135135
class Emitter {
136-
SILModule &Module;
137-
std::string PassName;
138-
bool PassedEnabled;
139-
bool MissedEnabled;
136+
SILModule &module;
137+
std::string passName;
138+
bool passedEnabled;
139+
bool missedEnabled;
140140

141141
// Making these non-generic allows out-of-line definition.
142-
void emit(const RemarkPassed &R);
143-
void emit(const RemarkMissed &R);
144-
static void emitDebug(const RemarkPassed &R);
145-
static void emitDebug(const RemarkMissed &R);
142+
void emit(const RemarkPassed &remark);
143+
void emit(const RemarkMissed &remark);
144+
static void emitDebug(const RemarkPassed &remark);
145+
static void emitDebug(const RemarkMissed &remark);
146146

147147
template <typename RemarkT> bool isEnabled();
148148

149149
public:
150-
Emitter(StringRef PassName, SILModule &M);
150+
Emitter(StringRef passName, SILModule &m);
151151

152152
/// Take a lambda that returns a remark which will be emitted. The
153153
/// lambda is not evaluated unless remarks are enabled. Second argument is
154154
/// only used to restrict this to functions.
155155
template <typename T>
156-
void emit(T RemarkBuilder, decltype(RemarkBuilder()) * = nullptr) {
157-
using RemarkT = decltype(RemarkBuilder());
156+
void emit(T remarkBuilder, decltype(remarkBuilder()) * = nullptr) {
157+
using RemarkT = decltype(remarkBuilder());
158158
// Avoid building the remark unless remarks are enabled.
159-
if (isEnabled<RemarkT>() || Module.getOptRecordStream()) {
160-
auto rb = RemarkBuilder();
161-
rb.setPassName(PassName);
159+
if (isEnabled<RemarkT>() || module.getOptRecordStream()) {
160+
auto rb = remarkBuilder();
161+
rb.setPassName(passName);
162162
emit(rb);
163163
}
164164
}
165165

166166
/// Emit an optimization remark or debug message.
167167
template <typename T>
168-
static void emitOrDebug(const char *PassName, Emitter *ORE, T RemarkBuilder,
169-
decltype(RemarkBuilder()) * = nullptr) {
170-
using RemarkT = decltype(RemarkBuilder());
168+
static void emitOrDebug(const char *passName, Emitter *emitter,
169+
T remarkBuilder,
170+
decltype(remarkBuilder()) * = nullptr) {
171+
using RemarkT = decltype(remarkBuilder());
171172
// Avoid building the remark unless remarks are enabled.
172-
bool EmitRemark =
173-
ORE && (ORE->isEnabled<RemarkT>() || ORE->Module.getOptRecordStream());
173+
bool emitRemark = emitter && (emitter->isEnabled<RemarkT>() ||
174+
emitter->module.getOptRecordStream());
174175
// Same for DEBUG.
175-
bool EmitDebug = false;
176+
bool shouldEmitDebug = false;
176177
#ifndef NDEBUG
177-
EmitDebug |= llvm::DebugFlag && llvm::isCurrentDebugType(PassName);
178+
shouldEmitDebug |= llvm::DebugFlag && llvm::isCurrentDebugType(passName);
178179
#endif // NDEBUG
179180

180-
if (EmitRemark || EmitDebug) {
181-
auto R = RemarkBuilder();
182-
if (EmitDebug)
183-
emitDebug(R);
184-
if (EmitRemark) {
185-
// If we have ORE use the PassName that was set up with ORE. DEBUG_TYPE
181+
if (emitRemark || shouldEmitDebug) {
182+
auto r = remarkBuilder();
183+
if (shouldEmitDebug)
184+
emitDebug(r);
185+
if (emitRemark) {
186+
// If we have an Emitter use the PassName that was set up. DEBUG_TYPE
186187
// may be different if a pass is calling other modules.
187-
R.setPassName(ORE->PassName);
188-
ORE->emit(R);
188+
r.setPassName(emitter->passName);
189+
emitter->emit(r);
189190
}
190191
}
191192
}
@@ -195,10 +196,10 @@ class Emitter {
195196
OptRemark::Emitter::emitOrDebug(DEBUG_TYPE, __VA_ARGS__)
196197

197198
template <> inline bool Emitter::isEnabled<RemarkMissed>() {
198-
return MissedEnabled;
199+
return missedEnabled;
199200
}
200201
template <> inline bool Emitter::isEnabled<RemarkPassed>() {
201-
return PassedEnabled;
202+
return passedEnabled;
202203
}
203204
} // namespace OptRemark
204205
} // namespace swift

0 commit comments

Comments
 (0)