Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "swift/AST/Type.h"
#include "swift/AST/Types.h"
#include "swift/ASTSectionImporter/ASTSectionImporter.h"
#include "swift/Basic/DiagnosticOptions.h"
#include "swift/Basic/Dwarf.h"
#include "swift/Basic/LangOptions.h"
#include "swift/Basic/Located.h"
Expand Down Expand Up @@ -1531,6 +1532,20 @@ void SwiftASTContext::ApplyWorkingDir(
clang_argument.append(joined_path.begin(), joined_path.end());
}

void SwiftASTContext::ApplyDiagnosticOptions() {
const auto &opts = GetCompilerInvocation().getDiagnosticOptions();
if (opts.PrintDiagnosticNames)
GetDiagnosticEngine().setPrintDiagnosticNames(true);

if (!opts.DiagnosticDocumentationPath.empty())
GetDiagnosticEngine().setDiagnosticDocumentationPath(
opts.DiagnosticDocumentationPath);

if (!opts.LocalizationCode.empty() && !opts.LocalizationPath.empty())
GetDiagnosticEngine().setLocalization(opts.LocalizationCode,
opts.LocalizationPath);
}

void SwiftASTContext::RemapClangImporterOptions(
const PathMappingList &path_map) {
auto &options = GetClangImporterOptions();
Expand Down Expand Up @@ -2301,6 +2316,8 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
swift_ast_sp->GetDiagnosticEngine());
}

swift_ast_sp->ApplyDiagnosticOptions();

// Apply source path remappings found in the target settings.
swift_ast_sp->RemapClangImporterOptions(target.GetSourcePathMap());

Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ class SwiftASTContext : public TypeSystemSwift {

friend class CompilerType;

void ApplyDiagnosticOptions();

/// Apply a PathMappingList dictionary on all search paths in the
/// ClangImporterOptions.
void RemapClangImporterOptions(const PathMappingList &path_map);
Expand Down
20 changes: 20 additions & 0 deletions lldb/test/Shell/SwiftREPL/DiagnosticOptions.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Test diagnostic options in REPL
// REQUIRES: swift

// RUN: %lldb --repl="-debug-diagnostic-names" < %s 2>&1 \
// RUN: | FileCheck %s --check-prefix=DIAGNOSTIC

// RUN: split-file %s %t.dir
// RUN: %lldb --repl="-localization-path %t.dir -locale fr" < %s 2>&1 \
// RUN: | FileCheck %s --check-prefix=LOCALIZED


_ = "An unterminated string
// DIAGNOSTIC: error: unterminated string literal [lex_unterminated_string]{{$}}
// LOCALIZED: error: chaîne non terminée littérale{{$}}
:quit


//--- fr.yaml
- id: "lex_unterminated_string"
msg: "chaîne non terminée littérale"