Subzero: Misc fixes/cleanup.
1. Fix MINIMAL build.
(a) Add a void cast to a var only used in asserts.
(b) Use "REQUIRES:" instead of "REQUIRES" in a .ll file.
2. Use StrError instead of StrDump for errors.
3. Use a lambda instead of a functor because C++11.
4. Explicit check for -filetype=obj in a non-dump-enabled build, to avoid cryptic downstream error messages.
5. Run "make format" which was neglected earlier.
BUG= none
R=kschimpf@google.com
Review URL: https://codereview.chromium.org/1284493003.
diff --git a/src/IceCompiler.cpp b/src/IceCompiler.cpp
index 23733ce..e4d9b1c 100644
--- a/src/IceCompiler.cpp
+++ b/src/IceCompiler.cpp
@@ -93,8 +93,19 @@
return Ctx.getErrorStatus()->assign(EC_None);
if (!BuildDefs::disableIrGen() && Ctx.getFlags().getDisableIRGeneration()) {
- Ctx.getStrDump() << "Error: Build doesn't allow --no-ir-gen when not "
- << "ALLOW_DISABLE_IR_GEN!\n";
+ Ctx.getStrError() << "Error: Build doesn't allow --no-ir-gen when not "
+ << "ALLOW_DISABLE_IR_GEN!\n";
+ return Ctx.getErrorStatus()->assign(EC_Args);
+ }
+
+ // The Minimal build (specifically, when dump()/emit() are not implemented)
+ // allows only --filetype=obj. Check here to avoid cryptic error messages
+ // downstream.
+ if (!BuildDefs::dump() && Ctx.getFlags().getOutFileType() != FT_Elf) {
+ // TODO(stichnot): Access the actual command-line argument via
+ // llvm::Option.ArgStr and .ValueStr .
+ Ctx.getStrError()
+ << "Error: only --filetype=obj is supported in this build.\n";
return Ctx.getErrorStatus()->assign(EC_Args);
}
@@ -121,7 +132,7 @@
Translator.reset(PTranslator.release());
} else if (BuildDefs::llvmIr()) {
if (PNACL_BROWSER_TRANSLATOR) {
- Ctx.getStrDump()
+ Ctx.getStrError()
<< "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n";
return Ctx.getErrorStatus()->assign(EC_Args);
}
@@ -142,8 +153,8 @@
Converter->convertToIce();
Translator.reset(Converter.release());
} else {
- Ctx.getStrDump() << "Error: Build doesn't allow LLVM IR, "
- << "--build-on-read=0 not allowed\n";
+ Ctx.getStrError() << "Error: Build doesn't allow LLVM IR, "
+ << "--build-on-read=0 not allowed\n";
return Ctx.getErrorStatus()->assign(EC_Args);
}