Skip to content

Commit f464fca

Browse files
committed
Keep the formating gods at bay (or PG&E will not restore my power)
1 parent 28f0ce3 commit f464fca

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

shared/compiler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func attachBitcodePathToObject(bcFile, objFile string) (success bool) {
198198
err = out.Sync()
199199
if err != nil {
200200
LogWarning("Syncing bitcode archive %v failed because %v\n", destFilePath, err)
201-
return
201+
return
202202
}
203203

204204
}

shared/extractor.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ ea.ArchiverName: %v
9292
}
9393

9494
func ParseSwitches(args []string) (ea ExtractionArgs) {
95-
95+
9696
var flagSet *flag.FlagSet = flag.NewFlagSet(args[0], flag.ContinueOnError)
97-
97+
9898
flagSet.BoolVar(&ea.Verbose, "v", false, "verbose mode")
9999
flagSet.BoolVar(&ea.WriteManifest, "m", false, "write the manifest")
100100
flagSet.BoolVar(&ea.SortBitcodeFiles, "s", false, "sort the bitcode files")
@@ -119,19 +119,19 @@ func ParseSwitches(args []string) (ea ExtractionArgs) {
119119
if len(inputFiles) != 1 {
120120
LogError("Can currently only deal with exactly one input file, sorry. You gave me %v input files.\n", len(inputFiles))
121121
ea.Failure = true
122-
return
122+
return
123123
}
124124
ea.InputFile = inputFiles[0]
125125
if _, err := os.Stat(ea.InputFile); os.IsNotExist(err) {
126126
LogError("The input file %s does not exist.", ea.InputFile)
127127
ea.Failure = true
128-
return
128+
return
129129
}
130130
realPath, err := filepath.EvalSymlinks(ea.InputFile)
131131
if err != nil {
132132
LogError("There was an error getting the real path of %s.", ea.InputFile)
133133
ea.Failure = true
134-
return
134+
return
135135
}
136136
ea.InputFile = realPath
137137
ea.InputType = getFileType(realPath)
@@ -143,9 +143,9 @@ func ParseSwitches(args []string) (ea ExtractionArgs) {
143143

144144
//Extract extracts the LLVM bitcode according to the arguments it is passed.
145145
func Extract(args []string) (exitCode int) {
146-
146+
147147
exitCode = 1
148-
148+
149149
ea := ParseSwitches(args)
150150

151151
if ea.Failure {
@@ -229,7 +229,6 @@ func setOutputFile(ea *ExtractionArgs) {
229229
}
230230
}
231231

232-
233232
func resolveTool(defaultPath string, envPath string, usrPath string) (path string) {
234233
if usrPath != defaultPath {
235234
path = usrPath
@@ -255,7 +254,6 @@ func resolveTool(defaultPath string, envPath string, usrPath string) (path strin
255254
return
256255
}
257256

258-
259257
func handleExecutable(ea ExtractionArgs) (success bool) {
260258
// get the list of bitcode paths
261259
artifactPaths := ea.Extractor(ea.InputFile)
@@ -339,7 +337,7 @@ func handleThinArchive(ea ExtractionArgs) (success bool) {
339337
}
340338

341339
if !success {
342-
return
340+
return
343341
}
344342

345343
// Write manifest
@@ -361,7 +359,7 @@ func listArchiveFiles(ea ExtractionArgs, inputFile string) (contents []string) {
361359
if err != nil {
362360
LogWarning("ar command: %v %v", ea.ArchiverName, arArgs)
363361
LogError("Failed to extract contents from archive %s because: %v.\n", inputFile, err)
364-
return
362+
return
365363
}
366364
contents = strings.Split(output, "\n")
367365
return
@@ -497,7 +495,7 @@ func handleArchive(ea ExtractionArgs) (success bool) {
497495

498496
if !success {
499497
//hopefully the failure has alreadu been reported...
500-
return
498+
return
501499
}
502500

503501
// Write manifest

tests/env_and_arg_test.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package test
22

33
import (
44
"fmt"
5-
"os"
65
"github.com/SRI-CSL/gllvm/shared"
6+
"os"
77
"testing"
88
)
99

@@ -13,23 +13,23 @@ const (
1313

1414
func checkExecutables(t *testing.T, ea shared.ExtractionArgs,
1515
llvmLinker string, llvmArchiver string, archiver string,
16-
clang string, clangpp string){
17-
if ea.LlvmLinkerName != llvmLinker {
16+
clang string, clangpp string) {
17+
if ea.LlvmLinkerName != llvmLinker {
1818
t.Errorf("ParseSwitches: LlvmLinkerName incorrect: %v\n", ea.LlvmLinkerName)
1919
}
20-
if ea.LlvmArchiverName != llvmArchiver {
20+
if ea.LlvmArchiverName != llvmArchiver {
2121
t.Errorf("ParseSwitches: LlvmArchiverName incorrect: %v\n", ea.LlvmArchiverName)
2222
}
23-
if ea.ArchiverName != archiver {
23+
if ea.ArchiverName != archiver {
2424
t.Errorf("ParseSwitches: ArchiverName incorrect: %v\n", ea.ArchiverName)
2525
}
2626

2727
eclang := shared.GetCompilerExecName("clang")
28-
if eclang != clang {
28+
if eclang != clang {
2929
t.Errorf("C compiler not correct: %v\n", eclang)
3030
}
3131
eclangpp := shared.GetCompilerExecName("clang++")
32-
if eclangpp != clangpp {
32+
if eclangpp != clangpp {
3333
t.Errorf("C++ compiler not correct: %v\n", eclangpp)
3434
}
3535
if verbose {
@@ -45,14 +45,14 @@ func Test_env_and_args(t *testing.T) {
4545
if !ea.Verbose {
4646
t.Errorf("ParseSwitches: -v flag not working\n")
4747
}
48-
if ea.WriteManifest || ea.SortBitcodeFiles || ea.BuildBitcodeModule || ea.KeepTemp {
48+
if ea.WriteManifest || ea.SortBitcodeFiles || ea.BuildBitcodeModule || ea.KeepTemp {
4949
t.Errorf("ParseSwitches: defaults not correct\n")
5050
}
51-
if ea.InputFile != "../data/hello" {
51+
if ea.InputFile != "../data/hello" {
5252
t.Errorf("ParseSwitches: InputFile incorrect: %v\n", ea.InputFile)
5353
}
54-
55-
checkExecutables(t, ea, "llvm-link", "llvm-ar", "ar", "clang", "clang++")
54+
55+
checkExecutables(t, ea, "llvm-link", "llvm-ar", "ar", "clang", "clang++")
5656

5757
os.Setenv("LLVM_COMPILER_PATH", "/the_future_is_here")
5858
os.Setenv("LLVM_CC_NAME", "clang-666")
@@ -61,27 +61,25 @@ func Test_env_and_args(t *testing.T) {
6161
os.Setenv("LLVM_AR_NAME", "llvm-ar-666")
6262

6363
shared.FetchEnvironment()
64-
64+
6565
ea = shared.ParseSwitches(args)
66-
66+
6767
checkExecutables(t, ea,
6868
"/the_future_is_here/llvm-link-666",
6969
"/the_future_is_here/llvm-ar-666",
7070
"ar",
7171
"/the_future_is_here/clang-666",
7272
"/the_future_is_here/clang++-666")
73-
73+
7474
args = []string{"get-bc", "-a", "llvm-ar-665", "-l", "llvm-link-665", "../data/hello"}
7575

7676
ea = shared.ParseSwitches(args)
77-
77+
7878
checkExecutables(t, ea,
7979
"llvm-link-665",
8080
"llvm-ar-665",
8181
"ar",
8282
"/the_future_is_here/clang-666",
8383
"/the_future_is_here/clang++-666")
84-
85-
8684

8785
}

0 commit comments

Comments
 (0)