Reject optimizer options as invalid in linker and Standard JSON modes

This commit is contained in:
Kamil Śliwak
2021-09-13 15:35:11 +02:00
parent b7c124911a
commit 7a36a1d1db
43 changed files with 52 additions and 4 deletions
+20
View File
@@ -940,6 +940,26 @@ General Information)").c_str(),
if (!parseInputPathsAndRemappings())
return false;
if (
m_options.input.mode != InputMode::Compiler &&
m_options.input.mode != InputMode::CompilerWithASTImport &&
m_options.input.mode != InputMode::Assembler
)
{
if (!m_args[g_strOptimizeRuns].defaulted())
{
serr() << "Option --" << g_strOptimizeRuns << " is only valid in compiler and assembler modes." << endl;
return false;
}
for (string const& option: {g_strOptimize, g_strNoOptimizeYul, g_strOptimizeYul, g_strYulOptimizations})
if (m_args.count(option) > 0)
{
serr() << "Option --" << option << " is only valid in compiler and assembler modes." << endl;
return false;
}
}
if (m_options.input.mode == InputMode::StandardJson)
return true;