From 26aba727296c7302cf369d2b6e32b4fe010e1434 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 23 Mar 2020 14:40:38 +0100 Subject: transform: replace panics with source locations Panics are bad for usability: whenever something breaks, the user is shown a (not very informative) backtrace. Replace it with real error messages instead, that even try to display the Go source location. --- transform/optimizer.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'transform/optimizer.go') diff --git a/transform/optimizer.go b/transform/optimizer.go index 71bf4d617..2677e6902 100644 --- a/transform/optimizer.go +++ b/transform/optimizer.go @@ -75,7 +75,10 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i OptimizeMaps(mod) OptimizeStringToBytes(mod) OptimizeAllocs(mod) - LowerInterfaces(mod) + err := LowerInterfaces(mod) + if err != nil { + return []error{err} + } errs := LowerInterrupts(mod) if len(errs) > 0 { @@ -115,7 +118,10 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i } else { // Must be run at any optimization level. - LowerInterfaces(mod) + err := LowerInterfaces(mod) + if err != nil { + return []error{err} + } if config.FuncImplementation() == compileopts.FuncValueSwitch { LowerFuncValues(mod) } -- cgit v1.2.3