File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,10 @@ package llvm
1919#include <stdlib.h>
2020*/
2121import "C"
22- import "unsafe"
23- import "errors"
22+ import (
23+ "errors"
24+ "unsafe"
25+ )
2426
2527type (
2628 // We use these weird structs here because *Ref types are pointers and
@@ -910,6 +912,18 @@ func ConstVector(scalarConstVals []Value, packed bool) (v Value) {
910912 return
911913}
912914
915+ // IsConstantString checks if the constant is an array of i8.
916+ func (v Value ) IsConstantString () bool {
917+ return C .LLVMIsConstantString (v .C ) != 0
918+ }
919+
920+ // ConstGetAsString will return the string contained in a constant.
921+ func (v Value ) ConstGetAsString () string {
922+ length := C .ulong (0 )
923+ cstr := C .LLVMGetAsString (v .C , & length )
924+ return C .GoStringN (cstr , C .int (length ))
925+ }
926+
913927// Constant expressions
914928func (v Value ) Opcode () Opcode { return Opcode (C .LLVMGetConstOpcode (v .C )) }
915929func (v Value ) InstructionOpcode () Opcode { return Opcode (C .LLVMGetInstructionOpcode (v .C )) }
You can’t perform that action at this time.
0 commit comments