Skip to content

Commit 5673edf

Browse files
aleino-nvslangbot
andauthored
Add module reference options to options list when parsing them (#6539)
* Add module reference options to options list when parsing them Previously, the module was just added to the compile request directly. This is a problem because the non-deprecated command line option parsing interface IGlobalSession::parseCommandLineArguments just creates a temporary compile request. Therefore these options are currently not detected by the API. This helps to address issue #4760 since it will need to access these modules in order to supply all of the required code. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
1 parent b59d155 commit 5673edf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

source/slang/slang-options.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,20 @@ SlangResult OptionsParser::_parseReferenceModule(const CommandLineArg& arg)
18311831
CommandLineArg referenceModuleName;
18321832
SLANG_RETURN_ON_FAIL(m_reader.expectArg(referenceModuleName));
18331833

1834-
return addReferencedModule(referenceModuleName.value, referenceModuleName.loc, true);
1834+
// Add the module to the request
1835+
SLANG_RETURN_ON_FAIL(
1836+
addReferencedModule(referenceModuleName.value, referenceModuleName.loc, true));
1837+
1838+
// In addition to adding the module to the request, we also add to the options set, because
1839+
// the same options parser is also used for IGlobalSession::parseCommandLineArguments, which
1840+
// parses options via a dummy request that is destroyed once the command line options are
1841+
// obtained. Therefore, also add the option here so that
1842+
// IGlobalSession::parseCommandLineArguments can return them.
1843+
m_requestImpl->getLinkage()->m_optionSet.add(
1844+
CompilerOptionName::ReferenceModule,
1845+
referenceModuleName.value);
1846+
1847+
return SLANG_OK;
18351848
}
18361849

18371850
SlangResult OptionsParser::_parseReproFileSystem(const CommandLineArg& arg)

0 commit comments

Comments
 (0)