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(
8888func emitDiagnostic(
8989 diagEnginePtr: UnsafeMutablePointer < UInt8 > ,
9090 sourceFileBuffer: UnsafeMutableBufferPointer < UInt8 > ,
91- diagnostic: Diagnostic
91+ diagnostic: Diagnostic ,
92+ messageSuffix: String ? = nil
9293) {
9394 // Collect all of the Fix-It changes based on their Fix-It ID.
9495 var fixItChangesByID : [ MessageID : [ FixIt . Change ] ] = [ : ]
@@ -101,7 +102,7 @@ func emitDiagnostic(
101102 emitDiagnosticParts (
102103 diagEnginePtr: diagEnginePtr,
103104 sourceFileBuffer: sourceFileBuffer,
104- message: diagnostic. diagMessage. message,
105+ message: diagnostic. diagMessage. message + ( messageSuffix ?? " " ) ,
105106 severity: diagnostic. diagMessage. severity,
106107 position: diagnostic. position,
107108 highlights: diagnostic. highlights,
Original file line number Diff line number Diff line change @@ -176,13 +176,13 @@ func evaluateMacro(
176176 }
177177
178178 // Emit diagnostics accumulated in the context.
179+ let macroName = parentExpansion. macro. withoutTrivia ( ) . description
179180 for diag in context. diagnostics {
180- // FIXME: Consider tacking on a note that says that this diagnostic
181- // came from a macro expansion.
182181 emitDiagnostic (
183182 diagEnginePtr: diagEnginePtr,
184183 sourceFileBuffer: . init( mutating: sourceFile. pointee. buffer) ,
185- diagnostic: diag
184+ diagnostic: diag,
185+ messageSuffix: " (from macro ' \( macroName) ') "
186186 )
187187 }
188188
Original file line number Diff line number Diff line change @@ -53,6 +53,6 @@ macro addBlocker<T>(_ value: T) -> T = MacroDefinition.AddBlocker
5353func testAddBlocker( a: Int , b: Int , c: Int ) {
5454 _ = #addBlocker( a * b * c)
5555#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=-}}
5757#endif
5858}
You can’t perform that action at this time.
0 commit comments