diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-03-18 06:04:22 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-03-18 06:04:22 +0000 |
commit | 6092d2c06540c83b3e261835d045822af1ea9e2f (patch) | |
tree | e553ffcd888b31ac191a73721496342fd7aa235d /llgo | |
parent | 28aae9c29b6dd740c4d8da4b7019f2b83bc446b2 (diff) | |
download | bcm5719-llvm-6092d2c06540c83b3e261835d045822af1ea9e2f.tar.gz bcm5719-llvm-6092d2c06540c83b3e261835d045822af1ea9e2f.zip |
llgoi: Fix importing source packages together with dependent binary packages.
Note that this means that llgoi does not support the case
where a package's pkgpath is different from its import path,
but I don't think this should actually happen with llgoi.
Differential Revision: http://reviews.llvm.org/D8403
llvm-svn: 232612
Diffstat (limited to 'llgo')
-rw-r--r-- | llgo/cmd/llgoi/llgoi.go | 3 | ||||
-rw-r--r-- | llgo/test/llgoi/Inputs/src/bar/answer.go | 5 | ||||
-rw-r--r-- | llgo/test/llgoi/import-source.test | 6 | ||||
-rw-r--r-- | llgo/test/llgoi/import-source2.test | 14 |
4 files changed, 27 insertions, 1 deletions
diff --git a/llgo/cmd/llgoi/llgoi.go b/llgo/cmd/llgoi/llgoi.go index e8968f8b7f8..e331c316759 100644 --- a/llgo/cmd/llgoi/llgoi.go +++ b/llgo/cmd/llgoi/llgoi.go @@ -102,6 +102,9 @@ func (in *interp) makeCompilerOptions() error { if pkg, ok := in.inputPkgmap[pkgpath]; ok { return pkg, nil } + if pkg, ok := pkgmap[pkgpath]; ok && pkg.Complete() { + return pkg, nil + } return origImporter(pkgmap, pkgpath) } return nil diff --git a/llgo/test/llgoi/Inputs/src/bar/answer.go b/llgo/test/llgoi/Inputs/src/bar/answer.go index 7f1bd022ac5..202b5096525 100644 --- a/llgo/test/llgoi/Inputs/src/bar/answer.go +++ b/llgo/test/llgoi/Inputs/src/bar/answer.go @@ -1,5 +1,8 @@ package bar +import "strconv" + func Answer() int { - return 42 + n, _ := strconv.Atoi("42") + return n } diff --git a/llgo/test/llgoi/import-source.test b/llgo/test/llgoi/import-source.test index 22cf57487e3..c5a3eabf38d 100644 --- a/llgo/test/llgoi/import-source.test +++ b/llgo/test/llgoi/import-source.test @@ -7,8 +7,14 @@ import "foo" // CHECK: # bar // CHECK: # foo +// Test that importing binary after source works. +import "strconv" + foo.Answer() // CHECK: #0 int = 42 +strconv.FormatBool(true) +// CHECK: #0 string = true + import "foo_cgo" // CHECK: foo_cgo: cannot load cgo package diff --git a/llgo/test/llgoi/import-source2.test b/llgo/test/llgoi/import-source2.test new file mode 100644 index 00000000000..fcf3b475bd6 --- /dev/null +++ b/llgo/test/llgoi/import-source2.test @@ -0,0 +1,14 @@ +// RUN: env GOPATH=%S/Inputs llgoi < %s | FileCheck %s + +// Test that importing binary before source works. +import "strconv" + +import "foo" +// CHECK: # bar +// CHECK: # foo + +foo.Answer() +// CHECK: #0 int = 42 + +strconv.FormatBool(true) +// CHECK: #0 string = true |