mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Update LocalizationFormat to use diagnosticIDStringFor
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/Localization/LocalizationFormat.h"
|
||||
#include "swift/AST/DiagnosticEngine.h"
|
||||
#include "swift/Basic/Range.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
@@ -39,12 +40,6 @@ enum LocalDiagID : uint32_t {
|
||||
NumDiags
|
||||
};
|
||||
|
||||
static constexpr const char *const diagnosticNameStrings[] = {
|
||||
#define DIAG(KIND, ID, Options, Text, Signature) " [" #ID "]",
|
||||
#include "swift/AST/DiagnosticsAll.def"
|
||||
"<not a diagnostic>",
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace llvm {
|
||||
@@ -100,9 +95,9 @@ LocalizationProducer::getMessageOr(swift::DiagID id,
|
||||
if (localizedMessage.empty())
|
||||
return defaultMessage;
|
||||
if (printDiagnosticNames) {
|
||||
llvm::StringRef diagnosticName(diagnosticNameStrings[(unsigned)id]);
|
||||
llvm::StringRef diagnosticID(DiagnosticEngine::diagnosticIDStringFor(id));
|
||||
auto localizedDebugDiagnosticMessage =
|
||||
localizationSaver.save(localizedMessage.str() + diagnosticName.str());
|
||||
localizationSaver.save(localizedMessage.str() + " [" + diagnosticID.str() + "]");
|
||||
return localizedDebugDiagnosticMessage;
|
||||
}
|
||||
return localizedMessage;
|
||||
|
||||
Reference in New Issue
Block a user