Skip to content

Commit 621cecb

Browse files
committed
Revert "[Diag] Create frontend flags for localization and write tests (swiftlang#32568)"
This reverts commit 621b3b4. The driver is double faulting on my Linux box (Fedora 32 / x86-64). It crashes due to heap corruption, then hangs trying to introspect and print the stack. There also appears to be an unrelated(?) uninitialized memory error that valgrind detects (as opposed to malloc's own self diagnostics).
1 parent 621b3b4 commit 621cecb

File tree

14 files changed

+3
-360
lines changed

14 files changed

+3
-360
lines changed

include/swift/AST/DiagnosticEngine.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,9 @@ namespace swift {
740740
}
741741

742742
void setLocalization(std::string locale, std::string path) {
743-
assert(!locale.empty());
744-
assert(!path.empty());
745-
localization =
746-
std::make_unique<diag::YAMLLocalizationProducer>(locale, path);
743+
if (!locale.empty() && !path.empty())
744+
localization =
745+
std::make_unique<diag::YAMLLocalizationProducer>(locale, path);
747746
}
748747

749748
void ignoreDiagnostic(DiagID id) {

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ ERROR(error_unknown_arg,none,
7676
"unknown argument: '%0'", (StringRef))
7777
ERROR(error_invalid_arg_value,none,
7878
"invalid value '%1' in '%0'", (StringRef, StringRef))
79-
ERROR(error_invalid_locale_code,none,
80-
"unsupported locale code; supported locale codes are: '%0'", (StringRef))
81-
WARNING(warning_locale_path_not_found,none,
82-
"specified localization directory '%0' does not exist, "
83-
"translation is disabled", (StringRef))
84-
WARNING(warning_cannot_find_locale_file,none,
85-
"cannot find translations for '%0' at '%1': no such file", (StringRef, StringRef))
8679
WARNING(warning_cannot_multithread_batch_mode,none,
8780
"ignoring -num-threads argument; cannot multithread batch mode", ())
8881
ERROR(error_unsupported_option_argument,none,

include/swift/AST/LocalizationLanguages.def

Lines changed: 0 additions & 207 deletions
This file was deleted.

test/diagnostics/Localization/Inputs/fr.yaml renamed to include/swift/AST/diagnostics/fr.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,3 @@
1717
#
1818
#===----------------------------------------------------------------------===#
1919

20-
- id: "lex_unterminated_string"
21-
msg: "chaîne non terminée littérale"
22-
23-
- id: "var_init_self_referential"
24-
msg: "variable utilisée dans sa propre valeur initiale"
25-
26-
- id: "cannot_find_in_scope"
27-
msg: "impossible %select{de trouver|de trouver opérateur}1 %0 portée"
28-
29-
- id: "error_invalid_locale_code"
30-
msg: "code de paramètres régionaux non pris en charge; les codes pris en charge sont '%0'"

include/swift/Basic/DiagnosticOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ class DiagnosticOptions {
6767

6868
std::string DiagnosticDocumentationPath = "";
6969

70-
std::string LocalizationCode = "";
71-
72-
// Diagnostic messages directory path.
73-
std::string LocalizationPath = "";
74-
7570
/// Return a hash code of any components from these options that should
7671
/// contribute to a Swift Bridging PCH hash.
7772
llvm::hash_code getPCHHashComponents() const {

include/swift/Option/Options.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,14 +389,6 @@ def diagnostic_style : Separate<["-"], "diagnostic-style">,
389389
def diagnostic_style_EQ : Joined<["-"], "diagnostic-style=">,
390390
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
391391
MetaVarName<"<style>">, Alias<diagnostic_style>;
392-
def locale : Separate<["-"], "locale">,
393-
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
394-
HelpText<"Choose a language for diagnostic messages">,
395-
MetaVarName<"<locale-code>">;
396-
def localization_path : Separate<["-"], "localization-path">,
397-
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,
398-
HelpText<"Path to localized diagnostic messages directory">,
399-
MetaVarName<"<path>">;
400392

401393
def module_cache_path : Separate<["-"], "module-cache-path">,
402394
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,

lib/Driver/ToolChains.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
242242
inputArgs.AddLastArg(arguments,
243243
options::OPT_emit_fine_grained_dependency_sourcefile_dot_files);
244244
inputArgs.AddLastArg(arguments, options::OPT_package_description_version);
245-
inputArgs.AddLastArg(arguments, options::OPT_locale);
246-
inputArgs.AddLastArg(arguments, options::OPT_localization_path);
247245
inputArgs.AddLastArg(arguments, options::OPT_serialize_diagnostics_path);
248246
inputArgs.AddLastArg(arguments, options::OPT_debug_diagnostic_names);
249247
inputArgs.AddLastArg(arguments, options::OPT_print_educational_notes);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ using namespace llvm::opt;
3434
/// The path for Swift libraries in the OS on Darwin.
3535
#define DARWIN_OS_LIBRARY_PATH "/usr/lib/swift"
3636

37-
static constexpr const char *const localeCodes[] = {
38-
#define SUPPORTED_LOCALE(Code, Language) #Code,
39-
#include "swift/AST/LocalizationLanguages.def"
40-
};
41-
4237
swift::CompilerInvocation::CompilerInvocation() {
4338
setTargetTriple(llvm::sys::getDefaultTargetTriple());
4439
}
@@ -62,14 +57,6 @@ void CompilerInvocation::setMainExecutablePath(StringRef Path) {
6257
llvm::sys::path::append(DiagnosticDocsPath, "share", "doc", "swift",
6358
"diagnostics");
6459
DiagnosticOpts.DiagnosticDocumentationPath = std::string(DiagnosticDocsPath.str());
65-
66-
// Compute the path of the YAML diagnostic messages directory files
67-
// in the toolchain.
68-
llvm::SmallString<128> DiagnosticMessagesDir(Path);
69-
llvm::sys::path::remove_filename(DiagnosticMessagesDir); // Remove /swift
70-
llvm::sys::path::remove_filename(DiagnosticMessagesDir); // Remove /bin
71-
llvm::sys::path::append(DiagnosticMessagesDir, "share", "swift");
72-
DiagnosticOpts.LocalizationPath = std::string(DiagnosticMessagesDir.str());
7360
}
7461

7562
void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary() {
@@ -941,43 +928,6 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
941928
if (Arg *A = Args.getLastArg(OPT_diagnostic_documentation_path)) {
942929
Opts.DiagnosticDocumentationPath = A->getValue();
943930
}
944-
if (Arg *A = Args.getLastArg(OPT_locale)) {
945-
std::string localeCode = A->getValue();
946-
947-
// Check if the locale code is available.
948-
if (llvm::none_of(localeCodes, [&](const char *locale) {
949-
return localeCode == locale;
950-
})) {
951-
std::string availableLocaleCodes = "";
952-
llvm::interleave(
953-
std::begin(localeCodes), std::end(localeCodes),
954-
[&](std::string locale) { availableLocaleCodes += locale; },
955-
[&] { availableLocaleCodes += ", "; });
956-
957-
Diags.diagnose(SourceLoc(), diag::error_invalid_locale_code,
958-
availableLocaleCodes);
959-
return true;
960-
}
961-
Opts.LocalizationCode = localeCode;
962-
}
963-
if (Arg *A = Args.getLastArg(OPT_localization_path)) {
964-
if (!llvm::sys::fs::exists(A->getValue())) {
965-
Diags.diagnose(SourceLoc(), diag::warning_locale_path_not_found,
966-
A->getValue());
967-
} else if (!Opts.LocalizationCode.empty()) {
968-
// Check if the localization path exists but it doesn't have a file
969-
// for the specified locale code.
970-
llvm::SmallString<128> localizationPath(A->getValue());
971-
llvm::sys::path::append(localizationPath, Opts.LocalizationCode);
972-
llvm::sys::path::replace_extension(localizationPath, ".yaml");
973-
if (!llvm::sys::fs::exists(localizationPath)) {
974-
Diags.diagnose(SourceLoc(), diag::warning_cannot_find_locale_file,
975-
Opts.LocalizationCode, localizationPath);
976-
}
977-
978-
Opts.LocalizationPath = A->getValue();
979-
}
980-
}
981931
assert(!(Opts.WarningsAsErrors && Opts.SuppressWarnings) &&
982932
"conflicting arguments; should have been caught by driver");
983933

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,6 @@ void CompilerInstance::setUpDiagnosticOptions() {
383383
}
384384
Diagnostics.setDiagnosticDocumentationPath(
385385
Invocation.getDiagnosticOptions().DiagnosticDocumentationPath);
386-
if (!Invocation.getDiagnosticOptions().LocalizationCode.empty()) {
387-
Diagnostics.setLocalization(
388-
Invocation.getDiagnosticOptions().LocalizationCode,
389-
Invocation.getDiagnosticOptions().LocalizationPath);
390-
}
391386
}
392387

393388
// The ordering of ModuleLoaders is important!

0 commit comments

Comments
 (0)