[PATCH] [llgo] llgoi: Fix importing source packages together with dependent binary packages.

Peter Collingbourne peter at pcc.me.uk
Tue Mar 17 23:07:22 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8403

Files:
  llgo/trunk/cmd/llgoi/llgoi.go
  llgo/trunk/test/llgoi/Inputs/src/bar/answer.go
  llgo/trunk/test/llgoi/import-source.test
  llgo/trunk/test/llgoi/import-source2.test

Index: llgo/trunk/cmd/llgoi/llgoi.go
===================================================================
--- llgo/trunk/cmd/llgoi/llgoi.go
+++ llgo/trunk/cmd/llgoi/llgoi.go
@@ -102,6 +102,9 @@
 		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
Index: llgo/trunk/test/llgoi/Inputs/src/bar/answer.go
===================================================================
--- llgo/trunk/test/llgoi/Inputs/src/bar/answer.go
+++ llgo/trunk/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
 }
Index: llgo/trunk/test/llgoi/import-source.test
===================================================================
--- llgo/trunk/test/llgoi/import-source.test
+++ llgo/trunk/test/llgoi/import-source.test
@@ -7,8 +7,14 @@
 // 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
Index: llgo/trunk/test/llgoi/import-source2.test
===================================================================
--- llgo/trunk/test/llgoi/import-source2.test
+++ llgo/trunk/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

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8403.22157.patch
Type: text/x-patch
Size: 1741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150318/fc8eb0cf/attachment.bin>


More information about the llvm-commits mailing list