[PATCH] Revert "llvm-c/lto.h: Avoid use of bool."

Reid Kleckner rnk at google.com
Thu Oct 24 13:59:54 PDT 2013


    - Switch to lto_bool_t.

Hi rafael.espindola, nlewycky, chapuni,

http://llvm-reviews.chandlerc.com/D2019

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2019?vs=5136&id=5138#toc

Files:
  include/llvm-c/lto.h
  tools/lto/lto.cpp

Index: include/llvm-c/lto.h
===================================================================
--- include/llvm-c/lto.h
+++ include/llvm-c/lto.h
@@ -19,6 +19,20 @@
 #include <stddef.h>
 #include <sys/types.h>
 
+#ifndef __cplusplus
+#if !defined(_MSC_VER)
+#include <stdbool.h>
+typedef bool lto_bool_t;
+#else
+// MSVC in particular does not have anything like _Bool or bool in C, but we can
+// at least make sure the type is the same size.  The implementation side will
+// use C++ bool.
+typedef unsigned char lto_bool_t;
+#endif
+#else
+typedef bool lto_bool_t;
+#endif
+
 /**
  * @defgroup LLVMCLTO LTO
  * @ingroup LLVMC
@@ -86,29 +100,29 @@
 /**
  * Checks if a file is a loadable object file.
  */
-extern int
+extern lto_bool_t
 lto_module_is_object_file(const char* path);
 
 
 /**
  * Checks if a file is a loadable object compiled for requested target.
  */
-extern int
+extern lto_bool_t
 lto_module_is_object_file_for_target(const char* path,
                                      const char* target_triple_prefix);
 
 
 /**
  * Checks if a buffer is a loadable object file.
  */
-extern int
+extern lto_bool_t
 lto_module_is_object_file_in_memory(const void* mem, size_t length);
 
 
 /**
  * Checks if a buffer is a loadable object compiled for requested target.
  */
-extern int
+extern lto_bool_t
 lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length,
                                               const char* target_triple_prefix);
 
@@ -207,24 +221,24 @@
  * Add an object module to the set of modules for which code will be generated.
  * Returns true on error (check lto_get_error_message() for details).
  */
-extern int
+extern lto_bool_t
 lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod);
 
 
 
 /**
  * Sets if debug info should be generated.
  * Returns true on error (check lto_get_error_message() for details).
  */
-extern int
+extern lto_bool_t
 lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model);
 
 
 /**
  * Sets which PIC code model to generated.
  * Returns true on error (check lto_get_error_message() for details).
  */
-extern int
+extern lto_bool_t
 lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model);
 
 
@@ -270,7 +284,7 @@
  * merged contents of all modules added so far.
  * Returns true on error (check lto_get_error_message() for details).
  */
-extern int
+extern lto_bool_t
 lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path);
 
 /**
@@ -288,7 +302,7 @@
  * Generates code for all added modules into one native object file.
  * The name of the file is written to name. Returns true on error.
  */
-extern int
+extern lto_bool_t
 lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name);
 
 
Index: tools/lto/lto.cpp
===================================================================
--- tools/lto/lto.cpp
+++ tools/lto/lto.cpp
@@ -90,26 +90,26 @@
 }
 
 /// lto_module_is_object_file - Validates if a file is a loadable object file.
-int lto_module_is_object_file(const char* path) {
+bool lto_module_is_object_file(const char* path) {
   return LTOModule::isBitcodeFile(path);
 }
 
 /// lto_module_is_object_file_for_target - Validates if a file is a loadable
 /// object file compilable for requested target.
-int lto_module_is_object_file_for_target(const char* path,
+bool lto_module_is_object_file_for_target(const char* path,
                                           const char* target_triplet_prefix) {
   return LTOModule::isBitcodeFileForTarget(path, target_triplet_prefix);
 }
 
 /// lto_module_is_object_file_in_memory - Validates if a buffer is a loadable
 /// object file.
-int lto_module_is_object_file_in_memory(const void* mem, size_t length) {
+bool lto_module_is_object_file_in_memory(const void* mem, size_t length) {
   return LTOModule::isBitcodeFile(mem, length);
 }
 
 /// lto_module_is_object_file_in_memory_for_target - Validates if a buffer is a
 /// loadable object file compilable for the target.
-int
+bool
 lto_module_is_object_file_in_memory_for_target(const void* mem,
                                             size_t length,
                                             const char* target_triplet_prefix) {
@@ -216,21 +216,21 @@
 /// lto_codegen_add_module - Add an object module to the set of modules for
 /// which code will be generated. Returns true on error (check
 /// lto_get_error_message() for details).
-int lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
+bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
   return !cg->addModule(mod, sLastErrorString);
 }
 
 /// lto_codegen_set_debug_model - Sets what if any format of debug info should
 /// be generated. Returns true on error (check lto_get_error_message() for
 /// details).
-int lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
+bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
   cg->setDebugInfo(debug);
   return false;
 }
 
 /// lto_codegen_set_pic_model - Sets what code model to generated. Returns true
 /// on error (check lto_get_error_message() for details).
-int lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
+bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
   cg->setCodePICModel(model);
   return false;
 }
@@ -267,7 +267,7 @@
 /// lto_codegen_write_merged_modules - Writes a new file at the specified path
 /// that contains the merged contents of all modules added so far. Returns true
 /// on error (check lto_get_error_message() for details).
-int lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
+bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
   if (!parsedOptions) {
     cg->parseCodeGenDebugOptions();
     parsedOptions = true;
@@ -293,7 +293,7 @@
 /// lto_codegen_compile_to_file - Generates code for all added modules into one
 /// native object file. The name of the file is written to name. Returns true on
 /// error.
-int lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
+bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
   if (!parsedOptions) {
     cg->parseCodeGenDebugOptions();
     parsedOptions = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2019.2.patch
Type: text/x-patch
Size: 6218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131024/2b92ae03/attachment.bin>


More information about the llvm-commits mailing list