From 4a6b4fd13965fe8428c9177bdd824a48dff553c0 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 24 Nov 2020 15:52:13 -0800 Subject: [PATCH] [dev.regabi] add FatalfAt and fix Fatalf docs I've wanted a FatalfAt function for a while, but under the old "-l" suffix naming convention it would have been called "Fatalfl", which is just atrocious. Change-Id: If87f692ecdff478769426d4b054ac396e5c1e42e Reviewed-on: https://go-review.googlesource.com/c/go/+/273013 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/cmd/compile/internal/gc/print.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/gc/print.go b/src/cmd/compile/internal/gc/print.go index 1dbd58df42..52585814f6 100644 --- a/src/cmd/compile/internal/gc/print.go +++ b/src/cmd/compile/internal/gc/print.go @@ -177,23 +177,39 @@ func Warnl(pos src.XPos, format string, args ...interface{}) { } } -// Fatal reports a fatal error - an internal problem - at the current line and exits. -// If other errors have already been printed, then Fatal just quietly exits. +// Fatalf reports a fatal error - an internal problem - at the current line and exits. +// If other errors have already been printed, then Fatalf just quietly exits. // (The internal problem may have been caused by incomplete information // after the already-reported errors, so best to let users fix those and // try again without being bothered about a spurious internal error.) // // But if no errors have been printed, or if -d panic has been specified, -// Fatal prints the error as an "internal compiler error". In a released build, +// Fatalf prints the error as an "internal compiler error". In a released build, // it prints an error asking to file a bug report. In development builds, it // prints a stack trace. // -// If -h has been specified, Fatal panics to force the usual runtime info dump. +// If -h has been specified, Fatalf panics to force the usual runtime info dump. func Fatalf(format string, args ...interface{}) { + FatalfAt(lineno, format, args...) +} + +// FatalfAt reports a fatal error - an internal problem - at pos and exits. +// If other errors have already been printed, then FatalfAt just quietly exits. +// (The internal problem may have been caused by incomplete information +// after the already-reported errors, so best to let users fix those and +// try again without being bothered about a spurious internal error.) +// +// But if no errors have been printed, or if -d panic has been specified, +// FatalfAt prints the error as an "internal compiler error". In a released build, +// it prints an error asking to file a bug report. In development builds, it +// prints a stack trace. +// +// If -h has been specified, FatalfAt panics to force the usual runtime info dump. +func FatalfAt(pos src.XPos, format string, args ...interface{}) { flusherrors() if Debug_panic != 0 || numErrors == 0 { - fmt.Printf("%v: internal compiler error: ", linestr(lineno)) + fmt.Printf("%v: internal compiler error: ", linestr(pos)) fmt.Printf(format, args...) fmt.Printf("\n")