diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-05-21 18:41:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-21 15:41:54 -0700 |
| commit | 172538fdb418f7a2faab1f5a410f3b2cb8e18ba5 (patch) | |
| tree | b17fd1cae7ace4bb3f2dbdd4ad29f4f57df0b286 /source/slang/slang-options.cpp | |
| parent | 0389546b0b065303d3c6874891a9fab4428910b9 (diff) | |
Downstream option handling (#1850)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Added SourceLoc handling for command line parsing.
* Fix typo in debug.
* Fix issue around the DiagnosticSink used in options parsing not having a writer available - by having DiagnosticSink parenting.
* Small rename for clarity.
* WIP extracting command line args for downstream tools.
* Unit tests/bug fixes around extracting args.
* Use DownstreamArgs in the EndToEndCompileRequest
* Passing downstream compiler options downstream.
* Fix issue with endToEndReq being nullptr.
* Fix issue with diagnostics number change.
* Small improvements to how the source line is displayed if it's too long.
Default to 120, as suggested in previous review.
Co-authored-by: T. Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-options.cpp')
| -rw-r--r-- | source/slang/slang-options.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 4566bf5ec..f4cd2e4ef 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -410,13 +410,8 @@ struct OptionsParser DiagnosticSink* requestSink = requestImpl->getSink(); - SourceManager* parentSourceManager = requestSink->getSourceManager(); - - // We need a new source manager to track our command line 'source' - - SourceManager sourceManager; - sourceManager.initialize(parentSourceManager, parentSourceManager->getFileSystemExt()); - + CommandLineContext* cmdLineContext = requestImpl->m_downstreamArgs.getContext(); + // Why create a new DiagnosticSink? // We *don't* want the lexer that comes as default (it's for Slang source!) // We may want to set flags that are different @@ -432,7 +427,7 @@ struct OptionsParser // // The solution used here is to have DiagnosticsSink have a 'parent' that also gets diagnostics reported to. - DiagnosticSink parseSink(&sourceManager, nullptr); + DiagnosticSink parseSink(cmdLineContext->getSourceManager(), nullptr); { parseSink.setFlags(requestSink->getFlags()); @@ -451,9 +446,14 @@ struct OptionsParser DiagnosticSink* sink = &parseSink; // Set up the args - CommandLineArgs args(&sourceManager); + CommandLineArgs args(cmdLineContext); + // Converts input args into args in 'args'. + // Doing so will allocate some SourceLoc space from the CommandLineContext. args.setArgs(argv, argc); + // Before we do anything else lets strip out all of the downstream arguments. + SLANG_RETURN_ON_FAIL(requestImpl->m_downstreamArgs.stripDownstreamArgs(args, 0, sink)); + CommandLineReader reader(&args, sink); SlangMatrixLayoutMode defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_MODE_UNKNOWN; |
