File: Diagnostics.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (181 lines) | stat: -rw-r--r-- 7,207 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//===--------------- Diagnostics.swift - Swift Driver Diagnostics ---------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SwiftOptions

import struct TSCBasic.Diagnostic

extension Diagnostic.Message {
  static var error_static_emit_executable_disallowed: Diagnostic.Message {
    .error("-static may not be used with -emit-executable")
  }

  static func error_update_code_not_supported(in mode: CompilerMode) -> Diagnostic.Message {
    .error("using '-update-code' in \(mode) mode is not supported")
  }

  static func error_option_missing_required_argument(option: Option, requiredArg: String) -> Diagnostic.Message {
    .error("option '\(option.spelling)' is missing a required argument (\(requiredArg))")
  }

  static func error_opt_invalid_mapping(option: Option, value: String) -> Diagnostic.Message {
    .error("values for '\(option.spelling)' must be in the format 'original=remapped', but '\(value)' was provided")
  }

  static func error_unsupported_argument(argument: String, option: Option) -> Diagnostic.Message {
    .error("unsupported argument '\(argument)' to option '\(option.spelling)'")
  }

  static func error_option_requires_sanitizer(option: Option) -> Diagnostic.Message {
    .error("option '\(option.spelling)' requires a sanitizer to be enabled. Use -sanitize= to enable a sanitizer")
  }

  static func error_invalid_arg_value(arg: Option, value: String) -> Diagnostic.Message {
    .error("invalid value '\(value)' in '\(arg.spelling)'")
  }

  static func error_invalid_arg_value_with_allowed(arg: Option, value: String, options: [String]) -> Diagnostic.Message {
    .error("invalid value '\(value)' in '\(arg.spelling)', valid options are: \(options.joined(separator: ", "))")
  }

  static func warning_inferring_simulator_target(originalTriple: Triple, inferredTriple: Triple) -> Diagnostic.Message {
    .warning("inferring simulator environment for target '\(originalTriple.triple)'; use '-target \(inferredTriple.triple)' instead")
  }

  static func remark_inprocess_target_info_query_failed(_ error: String) -> Diagnostic.Message {
    .remark("In-process target-info query failed (\(error)). Using fallback mechanism.")
  }

  static func remark_inprocess_supported_features_query_failed(_ error: String) -> Diagnostic.Message {
    .remark("In-process supported-compiler-features query failed (\(error)). Using fallback mechanism.")
  }

  static func error_argument_not_allowed_with(arg: String, other: String) -> Diagnostic.Message {
    .error("argument '\(arg)' is not allowed with '\(other)'")
  }

  static func error_unsupported_opt_for_target(arg: String, target: Triple) -> Diagnostic.Message {
    .error("unsupported option '\(arg)' for target '\(target.triple)'")
  }

  static func error_sanitizer_unavailable_on_target(sanitizer: String, target: Triple) -> Diagnostic.Message {
    .error("\(sanitizer) sanitizer is unavailable on target '\(target.triple)'")
  }

  static var error_mode_cannot_emit_module: Diagnostic.Message {
    .error("this mode does not support emitting modules")
  }

  static func error_cannot_read_swiftdeps(file: VirtualPath, reason: String) -> Diagnostic.Message {
    .error("cannot read swiftdeps: \(reason), file: \(file)")
  }

  static func error_bad_module_name(
    moduleName: String,
    explicitModuleName: Bool
  ) -> Diagnostic.Message {
    let suffix: String
    if explicitModuleName {
      suffix = ""
    } else {
      suffix = "; use -module-name flag to specify an alternate name"
    }

    return .error("module name \"\(moduleName)\" is not a valid identifier\(suffix)")
  }

  static func error_stdlib_module_name(
    moduleName: String,
    explicitModuleName: Bool
  ) -> Diagnostic.Message {
    let suffix: String
    if explicitModuleName {
      suffix = ""
    } else {
      suffix = "; use -module-name flag to specify an alternate name"
    }

    return .error("module name \"\(moduleName)\" is reserved for the standard library\(suffix)")
  }

  static func error_bad_module_alias(_ arg: String,
                                     moduleName: String,
                                     formatted: Bool = true,
                                     isDuplicate: Bool = false) -> Diagnostic.Message {
    if !formatted {
      return .error("invalid format \"\(arg)\"; use the format '-module-alias alias_name=underlying_name'")
    }
    if arg == moduleName {
      return .error("module alias \"\(arg)\" should be different from the module name \"\(moduleName)\"")
    }
    if isDuplicate {
      return .error("the name \"\(arg)\" is already used for a module alias or an underlying name")
    }
    return .error("bad module alias \"\(arg)\"")
  }

  static var error_empty_package_name: Diagnostic.Message {
    return .error("package-name is empty")
  }

  static var error_hermetic_seal_cannot_have_library_evolution: Diagnostic.Message {
    .error("Cannot use -experimental-hermetic-seal-at-link with -enable-library-evolution")
  }

  static var error_hermetic_seal_requires_lto: Diagnostic.Message {
    .error("-experimental-hermetic-seal-at-link requires -lto=llvm-full or -lto=llvm-thin")
  }

  static func warning_no_such_sdk(_ path: String) -> Diagnostic.Message {
    .warning("no such SDK: \(path)")
  }

  static func warning_no_sdksettings_json(_ path: String) -> Diagnostic.Message {
      .warning("Could not read SDKSettings.json for SDK at: \(path)")
  }

  static func warning_fail_parse_sdk_ver(_ version: String, _ path: String) -> Diagnostic.Message {
      .warning("Could not parse SDK version '\(version)' at: \(path)")
  }

  static func error_sdk_too_old(_ path: String) -> Diagnostic.Message {
      .error("Swift does not support the SDK \(path)")
  }

  static func error_unknown_target(_ target: String) -> Diagnostic.Message {
    .error("unknown target '\(target)'")
  }

  static func warning_option_overrides_another(overridingOption: Option, overridenOption: Option) -> Diagnostic.Message {
    .warning("ignoring '\(overridenOption.spelling)' because '\(overridingOption.spelling)' was also specified")
  }

  static func error_expected_one_frontend_job() -> Diagnostic.Message {
    .error("unable to handle compilation, expected exactly one frontend job")
  }

  static func error_expected_frontend_command() -> Diagnostic.Message {
    .error("expected a swift frontend command")
  }

  static var error_no_library_evolution_embedded: Diagnostic.Message {
    .error("Library evolution cannot be enabled with embedded Swift.")
  }

  static var error_need_wmo_embedded: Diagnostic.Message {
    .error("Whole module optimization (wmo) must be enabled with embedded Swift.")
  }

  static var error_no_objc_interop_embedded: Diagnostic.Message {
    .error("Objective-C interop cannot be enabled with embedded Swift.")
  }
}