diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index e86381bf3..1358dd484 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -610,10 +610,10 @@ bool CommandLineInterface::processInput() return false; case InputMode::License: printLicense(); - return true; + break; case InputMode::Version: printVersion(); - return true; + break; case InputMode::StandardJson: { solAssert(m_standardJsonInput.has_value(), ""); @@ -621,21 +621,25 @@ bool CommandLineInterface::processInput() StandardCompiler compiler(m_fileReader.reader(), m_options.formatting.json); sout() << compiler.compile(move(m_standardJsonInput.value())) << endl; m_standardJsonInput.reset(); - return true; + break; } case InputMode::Assembler: - { - return assemble(m_options.assembly.inputLanguage, m_options.assembly.targetMachine); - } + if (!assemble(m_options.assembly.inputLanguage, m_options.assembly.targetMachine)) + return false; + break; case InputMode::Linker: - return link(); + if (!link()) + return false; + writeLinkedFiles(); + break; case InputMode::Compiler: case InputMode::CompilerWithASTImport: - return compile(); + if (!compile()) + return false; + outputCompilationResults(); } - solAssert(false, ""); - return false; + return !m_outputFailed; } void CommandLineInterface::printVersion() @@ -883,29 +887,6 @@ void CommandLineInterface::handleAst() } } -bool CommandLineInterface::actOnInput() -{ - switch (m_options.input.mode) - { - case InputMode::Help: - case InputMode::License: - case InputMode::Version: - case InputMode::StandardJson: - case InputMode::Assembler: - // Already done in "processInput" phase. - break; - case InputMode::Linker: - writeLinkedFiles(); - break; - case InputMode::Compiler: - case InputMode::CompilerWithASTImport: - outputCompilationResults(); - break; - } - - return !m_outputFailed; -} - bool CommandLineInterface::link() { solAssert(m_options.input.mode == InputMode::Linker, ""); diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index e99ed1c07..ee5057468 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -55,11 +55,8 @@ public: bool parseArguments(int _argc, char const* const* _argv); /// Read the content of all input files and initialize the file reader. bool readInputFiles(); - /// Parse the files and create source code objects + /// Parse the files, create source code objects, print the output. bool processInput(); - /// Perform actions on the input depending on provided compiler arguments - /// @returns true on success. - bool actOnInput(); CommandLineOptions const& options() const { return m_options; } FileReader const& fileReader() const { return m_fileReader; } diff --git a/solc/main.cpp b/solc/main.cpp index 1299e2564..874ee13ca 100644 --- a/solc/main.cpp +++ b/solc/main.cpp @@ -65,8 +65,7 @@ int main(int argc, char** argv) bool success = cli.parseArguments(argc, argv) && cli.readInputFiles() && - cli.processInput() && - cli.actOnInput(); + cli.processInput(); return success ? 0 : 1; } diff --git a/test/solc/Common.cpp b/test/solc/Common.cpp index 28263e21e..8e40c1af6 100644 --- a/test/solc/Common.cpp +++ b/test/solc/Common.cpp @@ -70,6 +70,10 @@ string test::stripPreReleaseWarning(string const& _stderrContent) R"(Warning( \(3805\))?: This is a pre-release compiler version, please do not use it in production\.\n)" R"((\n)?)" }; + static regex const noOutputRegex{ + R"(Compiler run successful, no output requested\.\n)" + }; - return regex_replace(_stderrContent, preReleaseWarningRegex, ""); + string output = regex_replace(_stderrContent, preReleaseWarningRegex, ""); + return regex_replace(move(output), noOutputRegex, ""); }