File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
lib/ASTGen/Sources/ASTGen Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ fileprivate func emitDiagnosticParts(
88
88
func emitDiagnostic(
89
89
diagEnginePtr: UnsafeMutablePointer < UInt8 > ,
90
90
sourceFileBuffer: UnsafeMutableBufferPointer < UInt8 > ,
91
- diagnostic: Diagnostic
91
+ diagnostic: Diagnostic ,
92
+ messageSuffix: String ? = nil
92
93
) {
93
94
// Collect all of the Fix-It changes based on their Fix-It ID.
94
95
var fixItChangesByID : [ MessageID : [ FixIt . Change ] ] = [ : ]
@@ -101,7 +102,7 @@ func emitDiagnostic(
101
102
emitDiagnosticParts (
102
103
diagEnginePtr: diagEnginePtr,
103
104
sourceFileBuffer: sourceFileBuffer,
104
- message: diagnostic. diagMessage. message,
105
+ message: diagnostic. diagMessage. message + ( messageSuffix ?? " " ) ,
105
106
severity: diagnostic. diagMessage. severity,
106
107
position: diagnostic. position,
107
108
highlights: diagnostic. highlights,
Original file line number Diff line number Diff line change @@ -176,13 +176,13 @@ func evaluateMacro(
176
176
}
177
177
178
178
// Emit diagnostics accumulated in the context.
179
+ let macroName = parentExpansion. macro. withoutTrivia ( ) . description
179
180
for diag in context. diagnostics {
180
- // FIXME: Consider tacking on a note that says that this diagnostic
181
- // came from a macro expansion.
182
181
emitDiagnostic (
183
182
diagEnginePtr: diagEnginePtr,
184
183
sourceFileBuffer: . init( mutating: sourceFile. pointee. buffer) ,
185
- diagnostic: diag
184
+ diagnostic: diag,
185
+ messageSuffix: " (from macro ' \( macroName) ') "
186
186
)
187
187
}
188
188
Original file line number Diff line number Diff line change @@ -53,6 +53,6 @@ macro addBlocker<T>(_ value: T) -> T = MacroDefinition.AddBlocker
53
53
func testAddBlocker( a: Int , b: Int , c: Int ) {
54
54
_ = #addBlocker( a * b * c)
55
55
#if TEST_DIAGNOSTICS
56
- _ = #addBlocker( a + b * c) // expected-error{{blocked an add; did you mean to subtract?}}{{21-22=-}}
56
+ _ = #addBlocker( a + b * c) // expected-error{{blocked an add; did you mean to subtract? (from macro 'addBlocker') }}{{21-22=-}}
57
57
#endif
58
58
}
You can’t perform that action at this time.
0 commit comments