Skip to content

Commit c938f35

Browse files
committed
CommandLineParser: Initialize inputMode earlier to make it usable in more functions
1 parent 3b104a3 commit c938f35

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

solc/CommandLineParser.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,19 @@ General Information)").c_str(),
871871
}))
872872
return false;
873873

874-
if (m_args.count(g_strStandardJSON))
875-
{
874+
if (m_args.count(g_strStandardJSON) > 0)
876875
m_options.input.mode = InputMode::StandardJson;
876+
else if (m_args.count(g_strAssemble) > 0 || m_args.count(g_strStrictAssembly) > 0 || m_args.count(g_strYul) > 0)
877+
m_options.input.mode = InputMode::Assembler;
878+
else if (m_args.count(g_strLink) > 0)
879+
m_options.input.mode = InputMode::Linker;
880+
else if (m_args.count(g_strImportAst) > 0)
881+
m_options.input.mode = InputMode::CompilerWithASTImport;
882+
else
883+
m_options.input.mode = InputMode::Compiler;
877884

885+
if (m_options.input.mode == InputMode::StandardJson)
886+
{
878887
vector<string> inputFiles;
879888
if (m_args.count(g_strInputFile))
880889
inputFiles = m_args[g_strInputFile].as<vector<string>>();
@@ -909,10 +918,8 @@ General Information)").c_str(),
909918
m_options.output.evmVersion = *versionOption;
910919
}
911920

912-
if (m_args.count(g_strAssemble) || m_args.count(g_strStrictAssembly) || m_args.count(g_strYul))
921+
if (m_options.input.mode == InputMode::Assembler)
913922
{
914-
m_options.input.mode = InputMode::Assembler;
915-
916923
vector<string> const nonAssemblyModeOptions = {
917924
// TODO: The list is not complete. Add more.
918925
g_strOutputDir,
@@ -1026,11 +1033,8 @@ General Information)").c_str(),
10261033
return false;
10271034
}
10281035

1029-
if (m_args.count(g_strLink))
1030-
{
1031-
m_options.input.mode = InputMode::Linker;
1036+
if (m_options.input.mode == InputMode::Linker)
10321037
return true;
1033-
}
10341038

10351039
if (m_args.count(g_strMetadataHash))
10361040
{
@@ -1123,9 +1127,7 @@ General Information)").c_str(),
11231127
m_options.optimizer.yulSteps = m_args[g_strYulOptimizations].as<string>();
11241128
}
11251129

1126-
if (m_args.count(g_strImportAst) > 0)
1127-
m_options.input.mode = InputMode::CompilerWithASTImport;
1128-
else
1130+
if (m_options.input.mode == InputMode::Compiler)
11291131
m_options.input.errorRecovery = (m_args.count(g_strErrorRecovery) > 0);
11301132

11311133
solAssert(m_options.input.mode == InputMode::Compiler || m_options.input.mode == InputMode::CompilerWithASTImport, "");

0 commit comments

Comments
 (0)