mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Diagnostics] Introduce "Educational Notes" for diagnostics
Educational notes are small pieces of documentation which explain a concept relevant to some diagnostic message. If -enable-descriptive-diagnostics is passed, they will be printed after a diagnostic message if available. Educational notes can be found at /usr/share/doc/diagnostics in a toolchain, and are associated with specific compiler diagnostics in EducationalNotes.def.
This commit is contained in:
@@ -44,6 +44,13 @@ void CompilerInvocation::setMainExecutablePath(StringRef Path) {
|
||||
llvm::sys::path::remove_filename(LibPath); // Remove /bin
|
||||
llvm::sys::path::append(LibPath, "lib", "swift");
|
||||
setRuntimeResourcePath(LibPath.str());
|
||||
|
||||
llvm::SmallString<128> DiagnosticDocsPath(Path);
|
||||
llvm::sys::path::remove_filename(DiagnosticDocsPath); // Remove /swift
|
||||
llvm::sys::path::remove_filename(DiagnosticDocsPath); // Remove /bin
|
||||
llvm::sys::path::append(DiagnosticDocsPath, "share", "doc", "swift",
|
||||
"diagnostics");
|
||||
DiagnosticOpts.DiagnosticDocumentationPath = DiagnosticDocsPath.str();
|
||||
}
|
||||
|
||||
/// If we haven't explicitly passed -prebuilt-module-cache-path, set it to
|
||||
@@ -682,7 +689,9 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
|
||||
Opts.PrintDiagnosticNames |= Args.hasArg(OPT_debug_diagnostic_names);
|
||||
Opts.EnableDescriptiveDiagnostics |=
|
||||
Args.hasArg(OPT_enable_descriptive_diagnostics);
|
||||
|
||||
if (Arg *A = Args.getLastArg(OPT_diagnostic_documentation_path)) {
|
||||
Opts.DiagnosticDocumentationPath = A->getValue();
|
||||
}
|
||||
assert(!(Opts.WarningsAsErrors && Opts.SuppressWarnings) &&
|
||||
"conflicting arguments; should have been caught by driver");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user