[llvm] r187864 - Change public functions of LTOCodeGenerator from ret-false-on-succ to ret-true-on-succ.
Shuxin Yang
shuxin.llvm at gmail.com
Tue Aug 6 22:19:24 PDT 2013
Author: shuxin_yang
Date: Wed Aug 7 00:19:23 2013
New Revision: 187864
URL: http://llvm.org/viewvc/llvm-project?rev=187864&view=rev
Log:
Change public functions of LTOCodeGenerator from ret-false-on-succ to ret-true-on-succ.
As of this revision, all functions of LTOCodeGenerator are consistent in
ret-true-on-succ.
Tested on multiple OSes.
Modified:
llvm/trunk/tools/lto/LTOCodeGenerator.cpp
llvm/trunk/tools/lto/LTOCodeGenerator.h
llvm/trunk/tools/lto/lto.cpp
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=187864&r1=187863&r2=187864&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Aug 7 00:19:23 2013
@@ -128,31 +128,29 @@ bool LTOCodeGenerator::addModule(LTOModu
for (int i = 0, e = undefs.size(); i != e; ++i)
_asmUndefinedRefs[undefs[i]] = 1;
- return ret;
+ return !ret;
}
-bool LTOCodeGenerator::setDebugInfo(lto_debug_model debug,
- std::string& errMsg) {
+void LTOCodeGenerator::setDebugInfo(lto_debug_model debug) {
switch (debug) {
case LTO_DEBUG_MODEL_NONE:
_emitDwarfDebugInfo = false;
- return false;
+ return;
case LTO_DEBUG_MODEL_DWARF:
_emitDwarfDebugInfo = true;
- return false;
+ return;
}
llvm_unreachable("Unknown debug format!");
}
-bool LTOCodeGenerator::setCodePICModel(lto_codegen_model model,
- std::string& errMsg) {
+void LTOCodeGenerator::setCodePICModel(lto_codegen_model model) {
switch (model) {
case LTO_CODEGEN_PIC_MODEL_STATIC:
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
_codeModel = model;
- return false;
+ return;
}
llvm_unreachable("Unknown PIC model!");
}
@@ -160,7 +158,7 @@ bool LTOCodeGenerator::setCodePICModel(l
bool LTOCodeGenerator::writeMergedModules(const char *path,
std::string &errMsg) {
if (!determineTarget(errMsg))
- return true;
+ return false;
// Run the verifier on the merged modules.
PassManager passes;
@@ -173,7 +171,7 @@ bool LTOCodeGenerator::writeMergedModule
if (!ErrInfo.empty()) {
errMsg = "could not open bitcode file for writing: ";
errMsg += path;
- return true;
+ return false;
}
// write bitcode to it
@@ -184,11 +182,11 @@ bool LTOCodeGenerator::writeMergedModule
errMsg = "could not write bitcode file: ";
errMsg += path;
Out.os().clear_error();
- return true;
+ return false;
}
Out.keep();
- return false;
+ return true;
}
bool LTOCodeGenerator::compile_to_file(const char** name, std::string& errMsg) {
@@ -198,7 +196,7 @@ bool LTOCodeGenerator::compile_to_file(c
error_code EC = sys::fs::createTemporaryFile("lto-llvm", "o", FD, Filename);
if (EC) {
errMsg = EC.message();
- return true;
+ return false;
}
// generate object file
@@ -209,23 +207,23 @@ bool LTOCodeGenerator::compile_to_file(c
if (objFile.os().has_error()) {
objFile.os().clear_error();
sys::fs::remove(Twine(Filename));
- return true;
+ return false;
}
objFile.keep();
if (!genResult) {
sys::fs::remove(Twine(Filename));
- return true;
+ return false;
}
_nativeObjectPath = Filename.c_str();
*name = _nativeObjectPath.c_str();
- return false;
+ return true;
}
const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) {
const char *name;
- if (compile_to_file(&name, errMsg))
+ if (!compile_to_file(&name, errMsg))
return NULL;
// remove old buffer if compile() called twice
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=187864&r1=187863&r2=187864&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.h (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.h Wed Aug 7 00:19:23 2013
@@ -61,9 +61,11 @@ struct LTOCodeGenerator {
LTOCodeGenerator();
~LTOCodeGenerator();
+ // Merge given module, return true on success.
bool addModule(struct LTOModule*, std::string &errMsg);
- bool setDebugInfo(lto_debug_model, std::string &errMsg);
- bool setCodePICModel(lto_codegen_model, std::string &errMsg);
+
+ void setDebugInfo(lto_debug_model);
+ void setCodePICModel(lto_codegen_model);
void setCpu(const char* mCpu) { _mCpu = mCpu; }
@@ -78,11 +80,13 @@ struct LTOCodeGenerator {
//
void setCodeGenDebugOptions(const char *opts);
+ // Write the merged module to the file specified by the given path.
+ // Return true on success.
bool writeMergedModules(const char *path, std::string &errMsg);
// Compile the merged module into a *single* object file; the path to object
- // file is returned to the caller via argument "name". Return *FALSE* on
- // *SUCCESS*, true otherwise.
+ // file is returned to the caller via argument "name". Return true on
+ // success.
//
// NOTE that it is up to the linker to remove the intermediate object file.
// Do not try to remove the object file in LTOCodeGenerator's destructor
Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=187864&r1=187863&r2=187864&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Wed Aug 7 00:19:23 2013
@@ -140,20 +140,22 @@ void lto_codegen_dispose(lto_code_gen_t
/// which code will be generated. Returns true on error (check
/// lto_get_error_message() for details).
bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
- return cg->addModule(mod, sLastErrorString);
+ 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).
bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
- return cg->setDebugInfo(debug, sLastErrorString);
+ 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).
bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
- return cg->setCodePICModel(model, sLastErrorString);
+ cg->setCodePICModel(model);
+ return false;
}
/// lto_codegen_set_cpu - Sets the cpu to generate code for.
@@ -185,7 +187,7 @@ void lto_codegen_add_must_preserve_symbo
/// that contains the merged contents of all modules added so far. Returns true
/// on error (check lto_get_error_message() for details).
bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
- return cg->writeMergedModules(path, sLastErrorString);
+ return !cg->writeMergedModules(path, sLastErrorString);
}
/// lto_codegen_compile - Generates code for all added modules into one native
@@ -202,7 +204,7 @@ const void *lto_codegen_compile(lto_code
/// native object file. The name of the file is written to name. Returns true on
/// error.
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
- return cg->compile_to_file(name, sLastErrorString);
+ return !cg->compile_to_file(name, sLastErrorString);
}
/// lto_codegen_debug_options - Used to pass extra options to the code
More information about the llvm-commits
mailing list