summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-08-14 12:57:33 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2019-08-14 09:57:33 -0700
commitdc493d492d4d9c090dab410a0cb80eca490c32aa (patch)
treef0de85ae64d53afd9b9144df23d2450436565d20 /source/slang
parentea200663ffe33d7b4c739c0d84e9c21a3ae2ffa6 (diff)
Small improvements around C/C++ testing (#1017)
* * Simplify some of test code around CPPCompiler * Test using 'callable' with pass-through * Small cpu doc improvements * Improvements to Clang output parsing. * Remove temporary file (base filename) . * Improve handling of external errors - handle severity. * On error dumping out to 'actual' file for runCPPCompilerCompile. * Small fixes. Set the source language type correctly for pass thru. * Remove warning for test for clang backend c
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-compiler.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 8ead63784..5b8643b02 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -768,7 +768,7 @@ namespace Slang
return result;
}
- void reportExternalCompileError(const char* compilerName, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink)
+ void reportExternalCompileError(const char* compilerName, Severity severity, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink)
{
StringBuilder builder;
if (compilerName)
@@ -792,10 +792,15 @@ namespace Slang
PlatformUtil::appendResult(res, builder);
}
+ sink->diagnoseRaw(severity, builder.getUnownedSlice());
+ }
+
+ void reportExternalCompileError(const char* compilerName, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink)
+ {
// TODO(tfoley): need a better policy for how we translate diagnostics
// back into the Slang world (although we should always try to generate
// HLSL that doesn't produce any diagnostics...)
- sink->diagnoseRaw(SLANG_FAILED(res) ? Severity::Error : Severity::Warning, builder.getUnownedSlice());
+ reportExternalCompileError(compilerName, SLANG_FAILED(res) ? Severity::Error : Severity::Warning, res, diagnostic, sink);
}
static String _getDisplayPath(DiagnosticSink* sink, SourceFile* sourceFile)
@@ -1341,10 +1346,16 @@ SlangResult dissassembleDXILUsingDXC(
CPPCompiler::CompileOptions options;
+ // Set the source type
+ options.sourceType = (rawSourceLanguage == SourceLanguage::C) ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP;
+
// Generate a path a temporary filename for output module
String modulePath;
SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), modulePath));
+ // Remove the temporary path/file when done
+ temporaryFileSet.add(modulePath);
+
options.modulePath = modulePath;
options.sourceFiles.add(compileSourcePath);
@@ -1483,17 +1494,36 @@ SlangResult dissassembleDXILUsingDXC(
builder << "link ";
}
+ //
+ Severity severity = Severity::Error;
+
switch (msg.type)
{
- case OutputMessage::Type::Error: builder << "error"; break;
- case OutputMessage::Type::Unknown: builder << "warning"; break;
- case OutputMessage::Type::Info: builder << "info"; break;
+ case OutputMessage::Type::Unknown:
+ case OutputMessage::Type::Error:
+ {
+ severity = Severity::Error;
+ builder << "error";
+ break;
+ }
+ case OutputMessage::Type::Warning:
+ {
+ severity = Severity::Warning;
+ builder << "warning";
+ break;
+ }
+ case OutputMessage::Type::Info:
+ {
+ severity = Severity::Note;
+ builder << "info";
+ break;
+ }
default: break;
}
builder << " " << msg.code << ": " << msg.text;
- reportExternalCompileError(compilerText.getBuffer(), SLANG_OK, builder.getUnownedSlice(), sink);
+ reportExternalCompileError(compilerText.getBuffer(), severity, SLANG_OK, builder.getUnownedSlice(), sink);
}
}