From 8f0895e0f8257da2fd10b6325931627a9a1792ba Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 11 Nov 2020 09:56:50 -0500 Subject: Include hierarchy output (#1595) * #include an absolute path didn't work - because paths were taken to always be relative. * Improve diagnostic for token pasting. * Token paste location test. * Output include hierarchy. * WIP on includes hierarchy. * Improved include hierarchy output - to handle source files without tokens. Improved test case. * Small comment improvements. Fixed a typo with not returning a reference. * Slight simplification of the ViewInitiatingHierarchy, by adding GetOrAddValue to Dictionary. * Remove the need for ViewInitiatingHierarchy type. * Improve output of path in diagnostic for includes hierarchy. * Remove comment in diagnostic for token-paste-location.slang * Update command line docs to include `-output-includes` Co-authored-by: Yong He --- source/slang/slang-options.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index db56e8115..8897a6549 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -441,7 +441,7 @@ struct OptionsParser char const* arg = *argCursor++; if (arg[0] == '-') { - String argStr = String(arg); + UnownedStringSlice argStr = UnownedStringSlice(arg); if(argStr == "-no-mangle" ) { @@ -461,6 +461,10 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, prefix)); requestImpl->getBackEndReq()->m_dumpIntermediatePrefix = prefix; } + else if (argStr == "-output-includes") + { + requestImpl->getFrontEndReq()->outputIncludes = true; + } else if(argStr == "-dump-ir" ) { requestImpl->getFrontEndReq()->shouldDumpIR = true; @@ -972,9 +976,10 @@ struct OptionsParser String name; SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, name)); - String slice = argStr.subString(1, index - 1); + // Skip the initial -, up to the last - + UnownedStringSlice passThruSlice(argStr.begin() + 1, argStr.begin() + index); SlangPassThrough passThrough = SLANG_PASS_THROUGH_NONE; - if (SLANG_SUCCEEDED(TypeTextUtil::findPassThrough(slice.getUnownedSlice(), passThrough))) + if (SLANG_SUCCEEDED(TypeTextUtil::findPassThrough(passThruSlice, passThrough))) { session->setDownstreamCompilerPath(passThrough, name.getBuffer()); continue; -- cgit v1.2.3