]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] add FatalfAt and fix Fatalf docs
authorMatthew Dempsky <mdempsky@google.com>
Tue, 24 Nov 2020 23:52:13 +0000 (15:52 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 25 Nov 2020 03:22:35 +0000 (03:22 +0000)
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 <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/print.go

index 1dbd58df42ada5c22d0ca86549ee1019449b99d7..52585814f6d6857323a7f09f32e04786ce8b5934 100644 (file)
@@ -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")