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
19
19
#include <stdlib.h>
20
20
*/
21
21
import "C"
22
- import "unsafe"
23
- import "errors"
22
+ import (
23
+ "errors"
24
+ "unsafe"
25
+ )
24
26
25
27
type (
26
28
// We use these weird structs here because *Ref types are pointers and
@@ -910,6 +912,18 @@ func ConstVector(scalarConstVals []Value, packed bool) (v Value) {
910
912
return
911
913
}
912
914
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
+
913
927
// Constant expressions
914
928
func (v Value ) Opcode () Opcode { return Opcode (C .LLVMGetConstOpcode (v .C )) }
915
929
func (v Value ) InstructionOpcode () Opcode { return Opcode (C .LLVMGetInstructionOpcode (v .C )) }
You can’t perform that action at this time.
0 commit comments