[PATCH] D33901: [Go] GetSubtypes function

Andrew Wilkins via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 17:21:52 PDT 2017


axw requested changes to this revision.
axw added a comment.
This revision now requires changes to proceed.

Code looks fine, and thanks for adding a test. I just think this one should be a method rather than a free function.



================
Comment at: bindings/go/llvm/ir.go:614
 // Operations on array, pointer, and vector types (sequence types)
+func GetSubtypes(Tp Type) (ret []Type) {
+	ret = make([]Type, C.LLVMGetNumContainedTypes(Tp.C))
----------------
I think this should be a method, similar to Type.ParamTypes. I suggest `func (t Type) Subtypes() []Type`.


================
Comment at: bindings/go/llvm/ir_test.go:143
+	int_pointer := PointerType(cont.Int32Type(), 0)
+	int_inner := GetSubtypes(int_pointer);
+	if len(int_inner) != 1 {
----------------
Drop the semicolon, they're unnecessary in Go.


https://reviews.llvm.org/D33901





More information about the llvm-commits mailing list