Keep the formating gods at bay (or PG&E will not restore my power)

This commit is contained in:
Ian A. Mason 2019-10-28 20:47:17 +00:00
parent 28f0ce31f2
commit f464fcac22
3 changed files with 26 additions and 30 deletions

View File

@ -198,7 +198,7 @@ func attachBitcodePathToObject(bcFile, objFile string) (success bool) {
err = out.Sync()
if err != nil {
LogWarning("Syncing bitcode archive %v failed because %v\n", destFilePath, err)
return
return
}
}

View File

@ -92,9 +92,9 @@ ea.ArchiverName: %v
}
func ParseSwitches(args []string) (ea ExtractionArgs) {
var flagSet *flag.FlagSet = flag.NewFlagSet(args[0], flag.ContinueOnError)
flagSet.BoolVar(&ea.Verbose, "v", false, "verbose mode")
flagSet.BoolVar(&ea.WriteManifest, "m", false, "write the manifest")
flagSet.BoolVar(&ea.SortBitcodeFiles, "s", false, "sort the bitcode files")
@ -119,19 +119,19 @@ func ParseSwitches(args []string) (ea ExtractionArgs) {
if len(inputFiles) != 1 {
LogError("Can currently only deal with exactly one input file, sorry. You gave me %v input files.\n", len(inputFiles))
ea.Failure = true
return
return
}
ea.InputFile = inputFiles[0]
if _, err := os.Stat(ea.InputFile); os.IsNotExist(err) {
LogError("The input file %s does not exist.", ea.InputFile)
ea.Failure = true
return
return
}
realPath, err := filepath.EvalSymlinks(ea.InputFile)
if err != nil {
LogError("There was an error getting the real path of %s.", ea.InputFile)
ea.Failure = true
return
return
}
ea.InputFile = realPath
ea.InputType = getFileType(realPath)
@ -143,9 +143,9 @@ func ParseSwitches(args []string) (ea ExtractionArgs) {
//Extract extracts the LLVM bitcode according to the arguments it is passed.
func Extract(args []string) (exitCode int) {
exitCode = 1
ea := ParseSwitches(args)
if ea.Failure {
@ -229,7 +229,6 @@ func setOutputFile(ea *ExtractionArgs) {
}
}
func resolveTool(defaultPath string, envPath string, usrPath string) (path string) {
if usrPath != defaultPath {
path = usrPath
@ -255,7 +254,6 @@ func resolveTool(defaultPath string, envPath string, usrPath string) (path strin
return
}
func handleExecutable(ea ExtractionArgs) (success bool) {
// get the list of bitcode paths
artifactPaths := ea.Extractor(ea.InputFile)
@ -339,7 +337,7 @@ func handleThinArchive(ea ExtractionArgs) (success bool) {
}
if !success {
return
return
}
// Write manifest
@ -361,7 +359,7 @@ func listArchiveFiles(ea ExtractionArgs, inputFile string) (contents []string) {
if err != nil {
LogWarning("ar command: %v %v", ea.ArchiverName, arArgs)
LogError("Failed to extract contents from archive %s because: %v.\n", inputFile, err)
return
return
}
contents = strings.Split(output, "\n")
return
@ -497,7 +495,7 @@ func handleArchive(ea ExtractionArgs) (success bool) {
if !success {
//hopefully the failure has alreadu been reported...
return
return
}
// Write manifest

View File

@ -2,8 +2,8 @@ package test
import (
"fmt"
"os"
"github.com/SRI-CSL/gllvm/shared"
"os"
"testing"
)
@ -13,23 +13,23 @@ const (
func checkExecutables(t *testing.T, ea shared.ExtractionArgs,
llvmLinker string, llvmArchiver string, archiver string,
clang string, clangpp string){
if ea.LlvmLinkerName != llvmLinker {
clang string, clangpp string) {
if ea.LlvmLinkerName != llvmLinker {
t.Errorf("ParseSwitches: LlvmLinkerName incorrect: %v\n", ea.LlvmLinkerName)
}
if ea.LlvmArchiverName != llvmArchiver {
if ea.LlvmArchiverName != llvmArchiver {
t.Errorf("ParseSwitches: LlvmArchiverName incorrect: %v\n", ea.LlvmArchiverName)
}
if ea.ArchiverName != archiver {
if ea.ArchiverName != archiver {
t.Errorf("ParseSwitches: ArchiverName incorrect: %v\n", ea.ArchiverName)
}
eclang := shared.GetCompilerExecName("clang")
if eclang != clang {
if eclang != clang {
t.Errorf("C compiler not correct: %v\n", eclang)
}
eclangpp := shared.GetCompilerExecName("clang++")
if eclangpp != clangpp {
if eclangpp != clangpp {
t.Errorf("C++ compiler not correct: %v\n", eclangpp)
}
if verbose {
@ -45,14 +45,14 @@ func Test_env_and_args(t *testing.T) {
if !ea.Verbose {
t.Errorf("ParseSwitches: -v flag not working\n")
}
if ea.WriteManifest || ea.SortBitcodeFiles || ea.BuildBitcodeModule || ea.KeepTemp {
if ea.WriteManifest || ea.SortBitcodeFiles || ea.BuildBitcodeModule || ea.KeepTemp {
t.Errorf("ParseSwitches: defaults not correct\n")
}
if ea.InputFile != "../data/hello" {
if ea.InputFile != "../data/hello" {
t.Errorf("ParseSwitches: InputFile incorrect: %v\n", ea.InputFile)
}
checkExecutables(t, ea, "llvm-link", "llvm-ar", "ar", "clang", "clang++")
checkExecutables(t, ea, "llvm-link", "llvm-ar", "ar", "clang", "clang++")
os.Setenv("LLVM_COMPILER_PATH", "/the_future_is_here")
os.Setenv("LLVM_CC_NAME", "clang-666")
@ -61,27 +61,25 @@ func Test_env_and_args(t *testing.T) {
os.Setenv("LLVM_AR_NAME", "llvm-ar-666")
shared.FetchEnvironment()
ea = shared.ParseSwitches(args)
checkExecutables(t, ea,
"/the_future_is_here/llvm-link-666",
"/the_future_is_here/llvm-ar-666",
"ar",
"/the_future_is_here/clang-666",
"/the_future_is_here/clang++-666")
args = []string{"get-bc", "-a", "llvm-ar-665", "-l", "llvm-link-665", "../data/hello"}
ea = shared.ParseSwitches(args)
checkExecutables(t, ea,
"llvm-link-665",
"llvm-ar-665",
"ar",
"/the_future_is_here/clang-666",
"/the_future_is_here/clang++-666")
}