[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / bindings / go / llvm / support.go
blob8a663fee502a5893efbcc1605afd84785a61ed86
1 //===- support.go - Bindings for support ----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines bindings for the support component.
11 //===----------------------------------------------------------------------===//
13 package llvm
16 #include "llvm-c/Support.h"
17 #include "SupportBindings.h"
18 #include <stdlib.h>
20 import "C"
22 import (
23 "errors"
24 "unsafe"
27 // Loads a dynamic library such that it may be used as an LLVM plugin.
28 // See llvm::sys::DynamicLibrary::LoadLibraryPermanently.
29 func LoadLibraryPermanently(lib string) error {
30 var errstr *C.char
31 libstr := C.CString(lib)
32 defer C.free(unsafe.Pointer(libstr))
33 C.LLVMLoadLibraryPermanently2(libstr, &errstr)
34 if errstr != nil {
35 err := errors.New(C.GoString(errstr))
36 C.free(unsafe.Pointer(errstr))
37 return err
39 return nil
42 // Parse the given arguments using the LLVM command line parser.
43 // See llvm::cl::ParseCommandLineOptions.
44 func ParseCommandLineOptions(args []string, overview string) {
45 argstrs := make([]*C.char, len(args))
46 for i, arg := range args {
47 argstrs[i] = C.CString(arg)
48 defer C.free(unsafe.Pointer(argstrs[i]))
50 overviewstr := C.CString(overview)
51 defer C.free(unsafe.Pointer(overviewstr))
52 C.LLVMParseCommandLineOptions(C.int(len(args)), &argstrs[0], overviewstr)