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.
This commit is contained in:
Ayke van Laethem
2020-03-23 14:40:38 +01:00
committed by Ron Evans
parent 25fcf3e18e
commit 26aba72729
3 changed files with 31 additions and 18 deletions
+8 -2
View File
@@ -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)
}