From 80ff45f095db5a08db264921fda2db210788d529 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 3 Dec 2021 09:46:08 -0500 Subject: Improvements to repro diagnostics (#2039) * #include an absolute path didn't work - because paths were taken to always be relative. * Improvements to repro diagnostics. * Fix typo. --- source/slang/slang-options.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 1c7d8fbc2..8f5c75efa 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -413,7 +413,7 @@ struct OptionsParser Slang::List m_filenames; }; - static SlangResult _compileReproDirectory(SlangSession* session, EndToEndCompileRequest* originalRequest, const String& dir) + static SlangResult _compileReproDirectory(SlangSession* session, EndToEndCompileRequest* originalRequest, const String& dir, DiagnosticSink* sink) { auto stdOut = originalRequest->getWriter(WriterChannel::StdOutput); @@ -430,7 +430,7 @@ struct OptionsParser auto requestImpl = asInternal(request); List buffer; - SLANG_RETURN_ON_FAIL(ReproUtil::loadState(path, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(path, sink, buffer)); auto requestState = ReproUtil::getRequest(buffer); MemoryOffsetBase base; @@ -671,7 +671,14 @@ struct OptionsParser CommandLineArg reproName; SLANG_RETURN_ON_FAIL(reader.expectArg(reproName)); - SLANG_RETURN_ON_FAIL(ReproUtil::extractFilesToDirectory(reproName.value)); + { + const Result res = ReproUtil::extractFilesToDirectory(reproName.value, sink); + if (SLANG_FAILED(res)) + { + sink->diagnose(reproName.loc, Diagnostics::unableExtractReproToDirectory, reproName.value); + return res; + } + } } else if (argValue == "-module-name") { @@ -686,7 +693,14 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(reader.expectArg(reproName)); List buffer; - SLANG_RETURN_ON_FAIL(ReproUtil::loadState(reproName.value, buffer)); + { + const Result res = ReproUtil::loadState(reproName.value, sink, buffer); + if (SLANG_FAILED(res)) + { + sink->diagnose(reproName.loc, Diagnostics::unableToReadFile, reproName.value); + return res; + } + } auto requestState = ReproUtil::getRequest(buffer); MemoryOffsetBase base; @@ -713,7 +727,7 @@ struct OptionsParser CommandLineArg reproDirectory; SLANG_RETURN_ON_FAIL(reader.expectArg(reproDirectory)); - SLANG_RETURN_ON_FAIL(_compileReproDirectory(session, requestImpl, reproDirectory.value)); + SLANG_RETURN_ON_FAIL(_compileReproDirectory(session, requestImpl, reproDirectory.value, sink)); } else if (argValue == "-repro-file-system") { @@ -721,7 +735,14 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(reader.expectArg(reproName)); List buffer; - SLANG_RETURN_ON_FAIL(ReproUtil::loadState(reproName.value, buffer)); + { + const Result res = ReproUtil::loadState(reproName.value, sink, buffer); + if (SLANG_FAILED(res)) + { + sink->diagnose(reproName.loc, Diagnostics::unableToReadFile, reproName.value); + return res; + } + } auto requestState = ReproUtil::getRequest(buffer); MemoryOffsetBase base; -- cgit v1.2.3