[OCaml] Expose Llvm.parse_command_line_options.
authorPeter Zotov <whitequark@whitequark.org>
Wed, 29 Oct 2014 08:16:18 +0000 (08:16 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Wed, 29 Oct 2014 08:16:18 +0000 (08:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220847 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/ocaml/llvm/llvm.ml
bindings/ocaml/llvm/llvm.mli
bindings/ocaml/llvm/llvm_ocaml.c

index ef3c5b5b57cb80b1d28313edb5b06fe0973b202f..567fa2fc9d906669ec0ecff277d07b8a9fc0834d 100644 (file)
@@ -286,6 +286,8 @@ external reset_fatal_error_handler : unit -> unit
                                    = "llvm_reset_fatal_error_handler"
 external enable_pretty_stacktrace : unit -> unit
                                   = "llvm_enable_pretty_stacktrace"
                                    = "llvm_reset_fatal_error_handler"
 external enable_pretty_stacktrace : unit -> unit
                                   = "llvm_enable_pretty_stacktrace"
+external parse_command_line_options : ?overview:string -> string array -> unit
+                                    = "llvm_parse_command_line_options"
 
 type ('a, 'b) llpos =
 | At_end of 'a
 
 type ('a, 'b) llpos =
 | At_end of 'a
index fb41a8134dfaf3d65bd51bbd61255f41d409120e..1d93fa332d24f57f94e18edab099a87bf15e7a00 100644 (file)
@@ -381,6 +381,14 @@ val install_fatal_error_handler : (string -> unit) -> unit
 (** [reset_fatal_error_handler ()] resets LLVM's fatal error handler. *)
 val reset_fatal_error_handler : unit -> unit
 
 (** [reset_fatal_error_handler ()] resets LLVM's fatal error handler. *)
 val reset_fatal_error_handler : unit -> unit
 
+(** [parse_command_line_options ?overview args] parses [args] using
+    the LLVM command line parser. Note that the only stable thing about this
+    function is its signature; you cannot rely on any particular set of command
+    line arguments being interpreted the same way across LLVM versions.
+
+    See the function [llvm::cl::ParseCommandLineOptions()]. *)
+val parse_command_line_options : ?overview:string -> string array -> unit
+
 (** {6 Contexts} *)
 
 (** [create_context ()] creates a context for storing the "global" state in
 (** {6 Contexts} *)
 
 (** [create_context ()] creates a context for storing the "global" state in
index 7f762e0ce03d0c7e32465f7e3ae68e2d2a290a5b..4b146332c943170f165b3429b027e4973a3ec740 100644 (file)
@@ -60,6 +60,17 @@ CAMLprim value llvm_enable_pretty_stacktrace(value Unit) {
   return Val_unit;
 }
 
   return Val_unit;
 }
 
+CAMLprim value llvm_parse_command_line_options(value Overview, value Args) {
+  char *COverview;
+  if (Overview == Val_int(0)) {
+    COverview = NULL;
+  } else {
+    COverview = String_val(Field(Overview, 0));
+  }
+  LLVMParseCommandLineOptions(Wosize_val(Args), (const char* const*) Op_val(Args), COverview);
+  return Val_unit;
+}
+
 static value alloc_variant(int tag, void *Value) {
   value Iter = alloc_small(1, tag);
   Field(Iter, 0) = Val_op(Value);
 static value alloc_variant(int tag, void *Value) {
   value Iter = alloc_small(1, tag);
   Field(Iter, 0) = Val_op(Value);