Skip to content

Commit dfc9100

Browse files
authored
Bug fix in C++ extractor (shader-slang#1429)
* Fix bug from change in diagnostics. * Catch exceptions and display a message on problem with C++ extractor.
1 parent 5fc0185 commit dfc9100

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

tools/slang-cpp-extractor/slang-cpp-extractor-diagnostics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace CPPDiagnostics
66
{
77
using namespace Slang;
88

9-
#define DIAGNOSTIC(id, severity, name, messageFormat) const DiagnosticInfo name = { id, Severity::severity, messageFormat };
9+
#define DIAGNOSTIC(id, severity, name, messageFormat) const DiagnosticInfo name = { id, Severity::severity, #name, messageFormat };
1010
#include "slang-cpp-extractor-diagnostic-defs.h"
1111
}
1212

tools/slang-cpp-extractor/slang-cpp-extractor-main.cpp

+20-12
Original file line numberDiff line numberDiff line change
@@ -2478,26 +2478,34 @@ int main(int argc, const char*const* argv)
24782478
using namespace Slang;
24792479

24802480
{
2481-
RootNamePool rootNamePool;
2481+
ComPtr<ISlangWriter> writer(new FileWriter(stderr, WriterFlag::AutoFlush));
24822482

2483-
SourceManager sourceManager;
2484-
sourceManager.initialize(nullptr, nullptr);
2483+
try
2484+
{
2485+
RootNamePool rootNamePool;
24852486

2486-
ComPtr<ISlangWriter> writer(new FileWriter(stderr, WriterFlag::AutoFlush));
2487+
SourceManager sourceManager;
2488+
sourceManager.initialize(nullptr, nullptr);
24872489

2488-
DiagnosticSink sink(&sourceManager);
2489-
sink.writer = writer;
2490+
DiagnosticSink sink(&sourceManager);
2491+
sink.writer = writer;
24902492

2491-
CPPExtractorApp app(&sink, &sourceManager, &rootNamePool);
2492-
if (SLANG_FAILED(app.executeWithArgs(argc - 1, argv + 1)))
2493-
{
2494-
return 1;
2493+
CPPExtractorApp app(&sink, &sourceManager, &rootNamePool);
2494+
if (SLANG_FAILED(app.executeWithArgs(argc - 1, argv + 1)))
2495+
{
2496+
return 1;
2497+
}
2498+
if (sink.getErrorCount())
2499+
{
2500+
return 1;
2501+
}
24952502
}
2496-
if (sink.getErrorCount())
2503+
catch (...)
24972504
{
2505+
WriterHelper helper(writer);
2506+
helper.print("Unknown internal error in C++ extractor, aborted!\n");
24982507
return 1;
24992508
}
2500-
25012509
}
25022510
return 0;
25032511
}

0 commit comments

Comments
 (0)