Skip to content

Commit 09b794d

Browse files
[Localization] Correct namings and improve comment
1 parent 65da71a commit 09b794d

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

include/swift/AST/DiagnosticEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ namespace swift {
10431043

10441044
public:
10451045
llvm::StringRef diagnosticStringFor(const DiagID id,
1046-
bool printDiagnosticName);
1046+
bool printDiagnosticNames);
10471047

10481048
/// If there is no clear .dia file for a diagnostic, put it in the one
10491049
/// corresponding to the SourceLoc given here.

include/swift/Localization/LocalizationFormat.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,17 @@ class SerializedLocalizationWriter {
156156

157157
class LocalizationProducer {
158158
/// This allocator will retain localized diagnostic strings containing the
159-
/// diagnostic's message and identifier for the duration of compiler
160-
/// invocation
159+
/// diagnostic's message and identifier as `message [id]` for the duration of
160+
/// compiler invocation. This will be used when the frontend flag
161+
/// `-debug-diagnostic-names` is used.
161162
llvm::BumpPtrAllocator localizationAllocator;
162163
llvm::StringSaver localizationSaver;
163-
bool printDiagnosticName;
164+
bool printDiagnosticNames;
164165

165166
public:
166-
LocalizationProducer(bool printDiagnosticName = false)
167+
LocalizationProducer(bool printDiagnosticNames = false)
167168
: localizationSaver(localizationAllocator),
168-
printDiagnosticName(printDiagnosticName) {}
169+
printDiagnosticNames(printDiagnosticNames) {}
169170

170171
/// If the message isn't available/localized in current context
171172
/// return the fallback default message.
@@ -186,9 +187,8 @@ class YAMLLocalizationProducer final : public LocalizationProducer {
186187
public:
187188
/// The diagnostics IDs that are no longer available in `.def`
188189
std::vector<std::string> unknownIDs;
189-
explicit YAMLLocalizationProducer(
190-
llvm::StringRef filePath,
191-
bool printDiagnosticName = false);
190+
explicit YAMLLocalizationProducer(llvm::StringRef filePath,
191+
bool printDiagnosticNames = false);
192192

193193
/// Iterate over all of the available (non-empty) translations
194194
/// maintained by this producer, callback gets each translation
@@ -210,7 +210,7 @@ class SerializedLocalizationProducer final : public LocalizationProducer {
210210
public:
211211
explicit SerializedLocalizationProducer(
212212
std::unique_ptr<llvm::MemoryBuffer> buffer,
213-
bool printDiagnosticName = false);
213+
bool printDiagnosticNames = false);
214214

215215
protected:
216216
llvm::StringRef getMessage(swift::DiagID id) const override;

lib/AST/DiagnosticEngine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,8 @@ void DiagnosticEngine::emitDiagnostic(const Diagnostic &diagnostic) {
11131113

11141114
llvm::StringRef
11151115
DiagnosticEngine::diagnosticStringFor(const DiagID id,
1116-
bool printDiagnosticName) {
1117-
auto defaultMessage = printDiagnosticName
1116+
bool printDiagnosticNames) {
1117+
auto defaultMessage = printDiagnosticNames
11181118
? debugDiagnosticStrings[(unsigned)id]
11191119
: diagnosticStrings[(unsigned)id];
11201120
if (localization) {

lib/Localization/LocalizationFormat.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ LocalizationProducer::getMessageOr(swift::DiagID id,
9797
auto localizedMessage = getMessage(id);
9898
if (localizedMessage.empty())
9999
return defaultMessage;
100-
llvm::StringRef diagnosticName(diagnosticNameStrings[(unsigned)id]);
101-
if (printDiagnosticName) {
100+
if (printDiagnosticNames) {
101+
llvm::StringRef diagnosticName(diagnosticNameStrings[(unsigned)id]);
102102
auto localizedDebugDiagnosticMessage =
103103
localizationSaver.save(localizedMessage.str() + diagnosticName.str());
104104
return localizedDebugDiagnosticMessage;
@@ -107,8 +107,8 @@ LocalizationProducer::getMessageOr(swift::DiagID id,
107107
}
108108

109109
SerializedLocalizationProducer::SerializedLocalizationProducer(
110-
std::unique_ptr<llvm::MemoryBuffer> buffer, bool printDiagnosticName)
111-
: LocalizationProducer(printDiagnosticName), Buffer(std::move(buffer)) {
110+
std::unique_ptr<llvm::MemoryBuffer> buffer, bool printDiagnosticNames)
111+
: LocalizationProducer(printDiagnosticNames), Buffer(std::move(buffer)) {
112112
auto base =
113113
reinterpret_cast<const unsigned char *>(Buffer.get()->getBufferStart());
114114
auto tableOffset = endian::read<offset_type>(base, little);
@@ -125,8 +125,8 @@ SerializedLocalizationProducer::getMessage(swift::DiagID id) const {
125125
}
126126

127127
YAMLLocalizationProducer::YAMLLocalizationProducer(llvm::StringRef filePath,
128-
bool printDiagnosticName)
129-
: LocalizationProducer(printDiagnosticName) {
128+
bool printDiagnosticNames)
129+
: LocalizationProducer(printDiagnosticNames) {
130130
auto FileBufOrErr = llvm::MemoryBuffer::getFileOrSTDIN(filePath);
131131
llvm::MemoryBuffer *document = FileBufOrErr->get();
132132
diag::LocalizationInput yin(document->getBuffer());

0 commit comments

Comments
 (0)