summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-artifact-desc-util.cpp2
-rw-r--r--source/compiler-core/slang-artifact-handler-impl.cpp3
-rw-r--r--source/compiler-core/slang-doc-extractor.cpp2
-rw-r--r--source/compiler-core/slang-downstream-compiler-util.cpp1
-rw-r--r--source/compiler-core/slang-json-lexer.cpp7
-rw-r--r--source/compiler-core/slang-visual-studio-compiler-util.cpp5
-rw-r--r--source/core/slang-crypto.cpp7
-rw-r--r--source/core/slang-crypto.h4
-rw-r--r--source/core/slang-io.cpp2
-rw-r--r--source/core/slang-persistent-cache.cpp2
-rw-r--r--source/core/slang-platform.cpp6
-rw-r--r--source/core/slang-process.h1
-rw-r--r--source/core/slang-render-api-util.cpp6
-rw-r--r--source/core/slang-riff.cpp4
-rw-r--r--source/core/slang-secure-crt.h15
-rw-r--r--source/core/slang-stream.cpp7
-rw-r--r--source/core/slang-string-slice-pool.h9
-rw-r--r--source/core/slang-string-util.cpp4
-rw-r--r--source/core/slang-string.cpp2
-rw-r--r--source/core/slang-string.h4
-rw-r--r--source/core/slang-type-text-util.cpp2
-rw-r--r--source/core/unix/slang-unix-process.cpp4
-rw-r--r--source/slang/core.meta.slang4
-rw-r--r--source/slang/slang-ast-dump.cpp8
-rw-r--r--source/slang/slang-ast-print.cpp4
-rw-r--r--source/slang/slang-ast-type.cpp8
-rw-r--r--source/slang/slang-ast-val.cpp16
-rw-r--r--source/slang/slang-ast-val.h4
-rw-r--r--source/slang/slang-check-conformance.cpp2
-rw-r--r--source/slang/slang-check-constraint.cpp4
-rw-r--r--source/slang/slang-check-conversion.cpp2
-rw-r--r--source/slang/slang-check-decl.cpp29
-rw-r--r--source/slang/slang-check-expr.cpp21
-rw-r--r--source/slang/slang-check-modifier.cpp10
-rw-r--r--source/slang/slang-check-overload.cpp27
-rw-r--r--source/slang/slang-check-shader.cpp1
-rw-r--r--source/slang/slang-check-type.cpp8
-rw-r--r--source/slang/slang-compiler.cpp8
-rw-r--r--source/slang/slang-doc-ast.cpp6
-rw-r--r--source/slang/slang-doc-markdown-writer.cpp4
-rw-r--r--source/slang/slang-emit-c-like.cpp16
-rw-r--r--source/slang/slang-emit-cpp.cpp2
-rw-r--r--source/slang/slang-emit-cuda.cpp2
-rw-r--r--source/slang/slang-emit-glsl.cpp8
-rw-r--r--source/slang/slang-emit-hlsl.cpp8
-rw-r--r--source/slang/slang-emit-spirv.cpp5
-rw-r--r--source/slang/slang-emit.cpp1
-rw-r--r--source/slang/slang-intrinsic-expand.cpp4
-rw-r--r--source/slang/slang-ir-autodiff-fwd.cpp14
-rw-r--r--source/slang/slang-ir-autodiff-pairs.cpp5
-rw-r--r--source/slang/slang-ir-autodiff-primal-hoist.cpp20
-rw-r--r--source/slang/slang-ir-autodiff-rev.cpp4
-rw-r--r--source/slang/slang-ir-autodiff-rev.h2
-rw-r--r--source/slang/slang-ir-autodiff-transcriber-base.cpp6
-rw-r--r--source/slang/slang-ir-autodiff-transpose.h4
-rw-r--r--source/slang/slang-ir-autodiff-unzip.h4
-rw-r--r--source/slang/slang-ir-autodiff.cpp15
-rw-r--r--source/slang/slang-ir-check-differentiability.cpp4
-rw-r--r--source/slang/slang-ir-constexpr.cpp2
-rw-r--r--source/slang/slang-ir-glsl-legalize.cpp8
-rw-r--r--source/slang/slang-ir-legalize-types.cpp2
-rw-r--r--source/slang/slang-ir-legalize-varying-params.cpp4
-rw-r--r--source/slang/slang-ir-lower-witness-lookup.cpp2
-rw-r--r--source/slang/slang-ir-marshal-native-call.cpp2
-rw-r--r--source/slang/slang-ir-peephole.cpp2
-rw-r--r--source/slang/slang-ir-redundancy-removal.cpp2
-rw-r--r--source/slang/slang-ir-restructure.cpp2
-rw-r--r--source/slang/slang-ir-sccp.cpp2
-rw-r--r--source/slang/slang-ir-specialize-arrays.cpp2
-rw-r--r--source/slang/slang-ir-specialize-buffer-load-arg.cpp2
-rw-r--r--source/slang/slang-ir-specialize-dispatch.cpp3
-rw-r--r--source/slang/slang-ir-specialize.cpp4
-rw-r--r--source/slang/slang-ir-ssa.cpp2
-rw-r--r--source/slang/slang-ir-union.cpp4
-rw-r--r--source/slang/slang-ir.cpp10
-rw-r--r--source/slang/slang-ir.h4
-rw-r--r--source/slang/slang-language-server-ast-lookup.cpp4
-rw-r--r--source/slang/slang-language-server-completion.cpp2
-rw-r--r--source/slang/slang-language-server-document-symbols.cpp2
-rw-r--r--source/slang/slang-language-server.cpp9
-rw-r--r--source/slang/slang-legalize-types.cpp12
-rw-r--r--source/slang/slang-lookup.cpp8
-rw-r--r--source/slang/slang-lower-to-ir.cpp48
-rw-r--r--source/slang/slang-mangle.cpp8
-rw-r--r--source/slang/slang-options.cpp4
-rw-r--r--source/slang/slang-parameter-binding.cpp17
-rw-r--r--source/slang/slang-parser.cpp4
-rw-r--r--source/slang/slang-preprocessor.cpp5
-rw-r--r--source/slang/slang-reflection-api.cpp39
-rw-r--r--source/slang/slang-serialize-container.cpp11
-rw-r--r--source/slang/slang-serialize-ir.cpp6
-rw-r--r--source/slang/slang-syntax.cpp2
-rw-r--r--source/slang/slang-type-layout.cpp14
-rw-r--r--source/slang/slang-workspace-version.cpp1
-rw-r--r--source/slang/slang.cpp2
95 files changed, 306 insertions, 340 deletions
diff --git a/source/compiler-core/slang-artifact-desc-util.cpp b/source/compiler-core/slang-artifact-desc-util.cpp
index 140ac780d..18558eab9 100644
--- a/source/compiler-core/slang-artifact-desc-util.cpp
+++ b/source/compiler-core/slang-artifact-desc-util.cpp
@@ -945,7 +945,7 @@ SlangResult ArtifactDescUtil::appendDefaultExtension(const ArtifactDesc& desc, S
{
StringBuilder buf;
appendText(desc, buf);
- return buf;
+ return std::move(buf);
}
} // namespace Slang
diff --git a/source/compiler-core/slang-artifact-handler-impl.cpp b/source/compiler-core/slang-artifact-handler-impl.cpp
index 5d2a74036..6fc96dc44 100644
--- a/source/compiler-core/slang-artifact-handler-impl.cpp
+++ b/source/compiler-core/slang-artifact-handler-impl.cpp
@@ -29,8 +29,9 @@ namespace Slang {
SlangResult DefaultArtifactHandler::queryInterface(SlangUUID const& uuid, void** outObject)
{
- if (auto ptr = getInterface(uuid))
+ if ([[maybe_unused]] auto ptr = getInterface(uuid))
{
+ SLANG_ASSERT(ptr == this);
addRef();
*outObject = static_cast<IArtifactHandler*>(this);
return SLANG_OK;
diff --git a/source/compiler-core/slang-doc-extractor.cpp b/source/compiler-core/slang-doc-extractor.cpp
index c2d36ee89..ca947c94f 100644
--- a/source/compiler-core/slang-doc-extractor.cpp
+++ b/source/compiler-core/slang-doc-extractor.cpp
@@ -717,8 +717,6 @@ SlangResult DocMarkupExtractor::extract(const SearchItemInput* inputs, Index inp
{
struct Entry
{
- typedef Entry ThisType;
-
Index viewIndex; ///< The view/file index this loc is found in
SourceLoc::RawValue locOrOffset; ///< Can be a loc or an offset into the file
diff --git a/source/compiler-core/slang-downstream-compiler-util.cpp b/source/compiler-core/slang-downstream-compiler-util.cpp
index 9f43a6c88..d00c3fecb 100644
--- a/source/compiler-core/slang-downstream-compiler-util.cpp
+++ b/source/compiler-core/slang-downstream-compiler-util.cpp
@@ -41,7 +41,6 @@ struct DownstreamCompilerInfos
{
typedef DownstreamCompilerInfo Info;
typedef Info::SourceLanguageFlag SourceLanguageFlag;
- typedef Info::SourceLanguageFlags SourceLanguageFlags;
DownstreamCompilerInfos infos;
diff --git a/source/compiler-core/slang-json-lexer.cpp b/source/compiler-core/slang-json-lexer.cpp
index 428afca63..0476ca37a 100644
--- a/source/compiler-core/slang-json-lexer.cpp
+++ b/source/compiler-core/slang-json-lexer.cpp
@@ -156,7 +156,6 @@ JSONTokenType JSONLexer::advance()
{
// Line comment
cursor = _lexLineComment(cursor);
- break;
}
else if (nextChar == '*')
{
@@ -166,8 +165,12 @@ JSONTokenType JSONLexer::advance()
{
return _setInvalidToken();
}
- break;
}
+ else
+ {
+ return _setInvalidToken();
+ }
+ break;
}
case ' ':
case '\t':
diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp
index 32b4d7f25..81e00d73e 100644
--- a/source/compiler-core/slang-visual-studio-compiler-util.cpp
+++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp
@@ -462,7 +462,10 @@ static SlangResult _parseVisualStudioLine(SliceAllocator& allocator, const Unown
return SLANG_OK;
}
-/* static */SlangResult VisualStudioCompilerUtil::locateCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set)
+/* static */SlangResult VisualStudioCompilerUtil::locateCompilers(
+ const String& path,
+ ISlangSharedLibraryLoader* loader,
+ [[maybe_unused]] DownstreamCompilerSet* set)
{
SLANG_UNUSED(loader);
diff --git a/source/core/slang-crypto.cpp b/source/core/slang-crypto.cpp
index dfe246c7c..138454140 100644
--- a/source/core/slang-crypto.cpp
+++ b/source/core/slang-crypto.cpp
@@ -75,10 +75,11 @@ void MD5::init()
m_d = 0x10325476;
}
-void MD5::update(const void* data, SlangInt size)
+void MD5::update(const void* data, SlangSizeT size)
{
uint32_t saved_lo;
- SlangInt used, available;
+ uint32_t used;
+ uint32_t available;
saved_lo = m_lo;
if ((m_lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
@@ -330,7 +331,7 @@ void SHA1::init()
m_state[4] = 0xc3d2e1f0;
}
-void SHA1::update(const void* data, SlangInt len)
+void SHA1::update(const void* data, SlangSizeT len)
{
if (!data || len <= 0)
{
diff --git a/source/core/slang-crypto.h b/source/core/slang-crypto.h
index 94078861b..01d6004d0 100644
--- a/source/core/slang-crypto.h
+++ b/source/core/slang-crypto.h
@@ -87,7 +87,7 @@ namespace Slang
MD5();
void init();
- void update(const void* data, SlangInt size);
+ void update(const void* data, SlangSizeT size);
Digest finalize();
static Digest compute(const void* data, SlangInt size);
@@ -110,7 +110,7 @@ namespace Slang
SHA1();
void init();
- void update(const void* data, SlangInt size);
+ void update(const void* data, SlangSizeT size);
Digest finalize();
static Digest compute(const void* data, SlangInt size);
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp
index 52187bd47..81f0cbf87 100644
--- a/source/core/slang-io.cpp
+++ b/source/core/slang-io.cpp
@@ -822,7 +822,7 @@ namespace Slang
{
return SLANG_FAIL;
}
- if (resSize >= bufferSize)
+ if (size_t(resSize) >= bufferSize)
{
return SLANG_E_BUFFER_TOO_SMALL;
}
diff --git a/source/core/slang-persistent-cache.cpp b/source/core/slang-persistent-cache.cpp
index 2b4113e16..d934d1b26 100644
--- a/source/core/slang-persistent-cache.cpp
+++ b/source/core/slang-persistent-cache.cpp
@@ -226,7 +226,7 @@ String PersistentCache::getEntryFileName(const Key& key)
{
StringBuilder str;
str << m_cacheDirectory << "/" << key.toString();
- return str;
+ return std::move(str);
}
struct CacheIndexHeader
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp
index e5af0ba7e..e84f9095f 100644
--- a/source/core/slang-platform.cpp
+++ b/source/core/slang-platform.cpp
@@ -158,14 +158,14 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY);
#else // _WIN32
-/* static */SlangResult PlatformUtil::getInstancePath(StringBuilder& out)
+/* static */SlangResult PlatformUtil::getInstancePath([[maybe_unused]] StringBuilder& out)
{
// On non Windows it's typically hard to get the instance path, so we'll say not implemented.
// The meaning is also somewhat more ambiguous - is it the exe or the shared library path?
return SLANG_E_NOT_IMPLEMENTED;
}
-/* static */SlangResult PlatformUtil::appendResult(SlangResult res, StringBuilder& builderOut)
+/* static */SlangResult PlatformUtil::appendResult([[maybe_unused]] SlangResult res, [[maybe_unused]] StringBuilder& builderOut)
{
return SLANG_E_NOT_IMPLEMENTED;
}
@@ -301,7 +301,7 @@ static const PlatformFlags s_familyFlags[int(PlatformFamily::CountOf)] =
return s_familyFlags[int(family)];
}
-/* static */SlangResult PlatformUtil::outputDebugMessage(const char* text)
+/* static */SlangResult PlatformUtil::outputDebugMessage([[maybe_unused]] const char* text)
{
#ifdef _WIN32
OutputDebugStringA(text);
diff --git a/source/core/slang-process.h b/source/core/slang-process.h
index 6d86d8b14..ab54f36c9 100644
--- a/source/core/slang-process.h
+++ b/source/core/slang-process.h
@@ -21,6 +21,7 @@ public:
{
enum Enum : Flags
{
+ // Ignored on non-Windows platforms
AttachDebugger = 0x01,
};
};
diff --git a/source/core/slang-render-api-util.cpp b/source/core/slang-render-api-util.cpp
index fa39f46ee..ca58091af 100644
--- a/source/core/slang-render-api-util.cpp
+++ b/source/core/slang-render-api-util.cpp
@@ -56,7 +56,7 @@ UnownedStringSlice RenderApiUtil::getApiName(RenderApiType type)
{
using namespace Slang;
List<UnownedStringSlice> namesList;
- for (int j = 0; j < SLANG_COUNT_OF(RenderApiUtil::s_infos); j++)
+ for (Index j = 0; j < SLANG_COUNT_OF(RenderApiUtil::s_infos); j++)
{
const auto& apiInfo = RenderApiUtil::s_infos[j];
const UnownedStringSlice names(apiInfo.names);
@@ -218,7 +218,7 @@ static Token nextToken(Slang::UnownedStringSlice& textInOut, Slang::UnownedStrin
/* static */RenderApiType RenderApiUtil::findRenderApiType(const Slang::UnownedStringSlice& text)
{
using namespace Slang;
- for (int j = 0; j < SLANG_COUNT_OF(RenderApiUtil::s_infos); j++)
+ for (Index j = 0; j < SLANG_COUNT_OF(RenderApiUtil::s_infos); j++)
{
const auto& apiInfo = RenderApiUtil::s_infos[j];
if (StringUtil::indexOfInSplit(UnownedStringSlice(apiInfo.names), ',', text) >= 0)
@@ -233,7 +233,7 @@ static Token nextToken(Slang::UnownedStringSlice& textInOut, Slang::UnownedStrin
/* static */RenderApiType RenderApiUtil::findImplicitLanguageRenderApiType(const Slang::UnownedStringSlice& text)
{
using namespace Slang;
- for (int j = 0; j < SLANG_COUNT_OF(RenderApiUtil::s_infos); j++)
+ for (Index j = 0; j < SLANG_COUNT_OF(RenderApiUtil::s_infos); j++)
{
const auto& apiInfo = RenderApiUtil::s_infos[j];
if (StringUtil::indexOfInSplit(UnownedStringSlice(apiInfo.languageNames), ',', text) >= 0)
diff --git a/source/core/slang-riff.cpp b/source/core/slang-riff.cpp
index 670fed7a2..a90c65db9 100644
--- a/source/core/slang-riff.cpp
+++ b/source/core/slang-riff.cpp
@@ -278,7 +278,6 @@ struct DumpVisitor : public RiffContainer::Visitor
/* static */SlangResult RiffUtil::read(Stream* stream, RiffContainer& outContainer)
{
typedef RiffContainer::ScopeChunk ScopeChunk;
- typedef RiffContainer::ScopeChunk ScopeContainer;
outContainer.reset();
size_t remaining;
@@ -773,7 +772,8 @@ void RiffContainer::endChunk()
size_t chunkPayloadSize;
// The chunk we are popping
- Chunk* chunk = nullptr;
+ // Only keep track of this in debug builds
+ [[maybe_unused]] Chunk* chunk = nullptr;
ListChunk* parent;
if (m_dataChunk)
diff --git a/source/core/slang-secure-crt.h b/source/core/slang-secure-crt.h
index b6f6671dd..46552914a 100644
--- a/source/core/slang-secure-crt.h
+++ b/source/core/slang-secure-crt.h
@@ -6,12 +6,14 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#include <assert.h>
#include <wchar.h>
-inline void memcpy_s(void *dest, size_t numberOfElements, const void * src, size_t count)
+inline void memcpy_s(void *dest, [[maybe_unused]] size_t destSize, const void * src, size_t count)
{
- memcpy(dest, src, count);
+ assert(destSize >= count);
+ memcpy(dest, src, count);
}
#define _TRUNCATE ((size_t)-1)
@@ -22,9 +24,10 @@ inline void fopen_s(FILE**f, const char * fileName, const char * mode)
*f = fopen(fileName, mode);
}
-inline size_t fread_s(void * buffer, size_t bufferSize, size_t elementSize, size_t count, FILE * stream)
+inline size_t fread_s(void * buffer, [[maybe_unused]] size_t bufferSize, size_t elementSize, size_t count, FILE * stream)
{
- return fread(buffer, elementSize, count, stream);
+ assert(bufferSize >= elementSize * count);
+ return fread(buffer, elementSize, count, stream);
}
inline size_t wcsnlen_s(const wchar_t * str, size_t /*numberofElements*/)
@@ -80,13 +83,11 @@ inline void strcpy_s(char * strDestination, size_t /*numberOfElements*/, const c
inline void wcsncpy_s(wchar_t * strDestination, size_t /*numberOfElements*/, const wchar_t * strSource, size_t count)
{
- wcscpy(strDestination, strSource);
- //wcsncpy(strDestination, strSource, count);
+ wcsncpy(strDestination, strSource, count);
}
inline void strncpy_s(char * strDestination, size_t /*numberOfElements*/, const char * strSource, size_t count)
{
strncpy(strDestination, strSource, count);
- //wcsncpy(strDestination, strSource, count);
}
#endif
#endif
diff --git a/source/core/slang-stream.cpp b/source/core/slang-stream.cpp
index 47cf533eb..4b5d92228 100644
--- a/source/core/slang-stream.cpp
+++ b/source/core/slang-stream.cpp
@@ -37,7 +37,12 @@ SlangResult FileStream::init(const String& fileName, FileMode fileMode, FileAcce
return _init(fileName, fileMode, access, share);
}
-SlangResult FileStream::_init(const String& fileName, FileMode fileMode, FileAccess access, FileShare share)
+SlangResult FileStream::_init(
+ const String& fileName,
+ FileMode fileMode,
+ FileAccess access,
+ // Only used on Windows
+ [[maybe_unused]] FileShare share)
{
// Make sure it's closed to start with
close();
diff --git a/source/core/slang-string-slice-pool.h b/source/core/slang-string-slice-pool.h
index 843556296..f50ac8dde 100644
--- a/source/core/slang-string-slice-pool.h
+++ b/source/core/slang-string-slice-pool.h
@@ -85,7 +85,14 @@ public:
Index getSlicesCount() const { return m_slices.getCount(); }
/// Returns true if the handle is a default one. Only meaningful on a Style::Default.
- bool isDefaultHandle(Handle handle) const { SLANG_ASSERT(m_style == Style::Default && Index(handle) >= 0); return Index(handle) < kDefaultHandlesCount; }
+ bool isDefaultHandle(Handle handle) const
+ {
+ SLANG_ASSERT(
+ m_style == Style::Default &&
+ // TODO(C++20), use bit_cast here
+ HandleIntegral(handle) <= HandleIntegral(std::numeric_limits<Index>::max()));
+ return Index(handle) < kDefaultHandlesCount;
+ }
/// Convert a handle to and index. (A handle is just an index!)
static Index asIndex(Handle handle) { return Index(handle); }
diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp
index a1f310401..29e0dad5d 100644
--- a/source/core/slang-string-util.cpp
+++ b/source/core/slang-string-util.cpp
@@ -290,7 +290,7 @@ UnownedStringSlice StringUtil::getAtInSplit(const UnownedStringSlice& in, char s
append(format, args, builder);
va_end(args);
- return builder;
+ return std::move(builder);
}
/* static */UnownedStringSlice StringUtil::getSlice(ISlangBlob* blob)
@@ -342,7 +342,7 @@ ComPtr<ISlangBlob> StringUtil::createStringBlob(const String& string)
}
builder.appendInPlace(dstChars, numChars);
- return builder;
+ return std::move(builder);
}
/* static */String StringUtil::calcCharReplaced(const String& string, char fromChar, char toChar)
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp
index 0cb034604..dd2138c83 100644
--- a/source/core/slang-string.cpp
+++ b/source/core/slang-string.cpp
@@ -367,7 +367,7 @@ namespace Slang
if (outLength)
*outLength = length;
- for(int ii = 0; ii < sizeof(wchar_t); ++ii)
+ for(size_t ii = 0; ii < sizeof(wchar_t); ++ii)
buf.add(0);
wchar_t* beginData = (wchar_t*)buf.getBuffer();
diff --git a/source/core/slang-string.h b/source/core/slang-string.h
index 4c78cc32e..429a60c46 100644
--- a/source/core/slang-string.h
+++ b/source/core/slang-string.h
@@ -583,6 +583,10 @@ namespace Slang
char operator[](Index id) const
{
SLANG_ASSERT(id >= 0 && id < getLength());
+ // Silence a pedantic warning on GCC
+#if __GNUC__
+ if(id < 0) __builtin_unreachable();
+#endif
return begin()[id];
}
diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp
index 9d2f93ba3..0d396195f 100644
--- a/source/core/slang-type-text-util.cpp
+++ b/source/core/slang-type-text-util.cpp
@@ -197,7 +197,7 @@ struct DebugInfoFormatTable
switch (type)
{
- default: /* fall-through to none */
+ default: [[fallthrough]]; /* fall-through to none */
SLANG_PASS_THROUGH_HUMAN_TEXT(SLANG_PASS_THROUGH_HUMAN_CASE)
}
}
diff --git a/source/core/unix/slang-unix-process.cpp b/source/core/unix/slang-unix-process.cpp
index e440bbb38..428bef874 100644
--- a/source/core/unix/slang-unix-process.cpp
+++ b/source/core/unix/slang-unix-process.cpp
@@ -345,7 +345,7 @@ SlangResult UnixPipeStream::write(const void* buffer, size_t length)
const ssize_t writeResult = ::write(m_fd, buffer, length);
- if (writeResult < 0 || writeResult != length)
+ if (writeResult < 0 || size_t(writeResult) != length)
{
return SLANG_FAIL;
}
@@ -389,7 +389,7 @@ static int pipeCLOEXEC(int pipefd[2])
#endif
}
-/* static */SlangResult Process::create(const CommandLine& commandLine, Process::Flags flags, RefPtr<Process>& outProcess)
+/* static */SlangResult Process::create(const CommandLine& commandLine, Process::Flags, RefPtr<Process>& outProcess)
{
const char* whatFailed = nullptr;
pid_t childPid;
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index c272da75d..764e39cce 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -363,7 +363,7 @@ ${{{{
}}}}
, __BuiltinSignedArithmeticType
${{{{
- ; // fall through to:
+ ; // fall through
case BaseType::UInt8:
case BaseType::UInt16:
case BaseType::UInt:
@@ -373,7 +373,7 @@ ${{{{
, __BuiltinArithmeticType
, __BuiltinIntegerType
${{{{
- ; // fall through to:
+ ; // fall through
case BaseType::Bool:
}}}}
, __BuiltinLogicalType
diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp
index 2c98af65c..723608bb2 100644
--- a/source/slang/slang-ast-dump.cpp
+++ b/source/slang/slang-ast-dump.cpp
@@ -1,6 +1,7 @@
// slang-ast-dump.cpp
#include "slang-ast-dump.h"
#include <assert.h>
+#include <limits>
#include "slang-compiler.h"
@@ -240,9 +241,10 @@ struct ASTDumpContext
return (v < 10) ? char(v + '0') : char('a' + v - 10);
}
- static bool _isPrintableChar(char c)
+ static bool _charNeedsEscaping(char c)
{
- return c >= 0x20 && c < 0x80;
+ // Escape everything except the printable characters (except DEL)
+ return c < 0x20 || c >= 0x7F;
}
void dump(const UnownedStringSlice& slice)
@@ -253,7 +255,7 @@ struct ASTDumpContext
buf.appendChar('\"');
for (const char c : slice)
{
- if (_isPrintableChar(c))
+ if (!_charNeedsEscaping(c))
{
buf << c;
}
diff --git a/source/slang/slang-ast-print.cpp b/source/slang/slang-ast-print.cpp
index 107ec64c5..b38b58385 100644
--- a/source/slang/slang-ast-print.cpp
+++ b/source/slang/slang-ast-print.cpp
@@ -396,7 +396,7 @@ void ASTPrinter::addDeclKindPrefix(Decl* decl)
m_builder << " ";
}
}
- else if (auto propertyDecl = as<PropertyDecl>(decl))
+ else if (const auto propertyDecl = as<PropertyDecl>(decl))
{
m_builder << "property ";
}
@@ -424,7 +424,7 @@ void ASTPrinter::addDeclKindPrefix(Decl* decl)
m_builder << " ";
}
}
- else if (auto assocType = as<AssocTypeDecl>(decl))
+ else if (const auto assocType = as<AssocTypeDecl>(decl))
{
m_builder << "associatedtype ";
}
diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp
index 72f1764df..987d73994 100644
--- a/source/slang/slang-ast-type.cpp
+++ b/source/slang/slang-ast-type.cpp
@@ -128,9 +128,7 @@ void ErrorType::_toTextOverride(StringBuilder& out)
bool ErrorType::_equalsImplOverride(Type* type)
{
- if (auto errorType = as<ErrorType>(type))
- return true;
- return false;
+ return as<ErrorType>(type);
}
Type* ErrorType::_createCanonicalTypeOverride()
@@ -154,9 +152,7 @@ void BottomType::_toTextOverride(StringBuilder& out) { out << toSlice("never");
bool BottomType::_equalsImplOverride(Type* type)
{
- if (auto bottomType = as<BottomType>(type))
- return true;
- return false;
+ return as<BottomType>(type);
}
Type* BottomType::_createCanonicalTypeOverride() { return this; }
diff --git a/source/slang/slang-ast-val.cpp b/source/slang/slang-ast-val.cpp
index fde31c730..c8b9d0bb8 100644
--- a/source/slang/slang-ast-val.cpp
+++ b/source/slang/slang-ast-val.cpp
@@ -35,7 +35,7 @@ String Val::toString()
{
StringBuilder builder;
toText(builder);
- return builder;
+ return std::move(builder);
}
HashCode Val::getHashCode()
@@ -159,11 +159,11 @@ Val* maybeSubstituteGenericParam(Val* paramVal, Decl* paramDecl, SubstitutionSet
(*ioDiff)++;
return genSubst->getArgs()[argIndex];
}
- else if (auto typeParam = as<GenericTypeParamDecl>(m))
+ else if (const auto typeParam = as<GenericTypeParamDecl>(m))
{
argIndex++;
}
- else if (auto valParam = as<GenericValueParamDecl>(m))
+ else if (const auto valParam = as<GenericValueParamDecl>(m))
{
argIndex++;
}
@@ -190,11 +190,7 @@ Val* GenericParamIntVal::_substituteImplOverride(ASTBuilder* /* astBuilder */, S
bool ErrorIntVal::_equalsValOverride(Val* val)
{
- if (auto errorIntVal = as<ErrorIntVal>(val))
- {
- return true;
- }
- return false;
+ return as<ErrorIntVal>(val);
}
void ErrorIntVal::_toTextOverride(StringBuilder& out)
@@ -538,7 +534,7 @@ Val* ExtractExistentialSubtypeWitness::_substituteImplOverride(ASTBuilder* astBu
(*ioDiff)++;
ExtractExistentialSubtypeWitness* substValue = astBuilder->create<ExtractExistentialSubtypeWitness>();
- substValue->declRef = declRef;
+ substValue->declRef = substDeclRef;
substValue->sub = substSub;
substValue->sup = substSup;
return substValue;
@@ -1077,7 +1073,7 @@ PolynomialIntVal* PolynomialIntVal::mul(ASTBuilder* astBuilder, IntVal* op0, Int
}
else if (auto val0 = as<IntVal>(op0))
{
- if (auto poly1 = as<PolynomialIntVal>(op1))
+ if (const auto poly1 = as<PolynomialIntVal>(op1))
{
return mul(astBuilder, op1, op0);
}
diff --git a/source/slang/slang-ast-val.h b/source/slang/slang-ast-val.h
index 49aec8c5e..0eb77e06e 100644
--- a/source/slang/slang-ast-val.h
+++ b/source/slang/slang-ast-val.h
@@ -128,7 +128,7 @@ public:
}
else
{
- if (auto thatGenParam = as<GenericParamIntVal>(other.param))
+ if (const auto thatGenParam = as<GenericParamIntVal>(other.param))
{
return false;
}
@@ -143,7 +143,7 @@ public:
{
if (auto thatGenParam = as<GenericParamIntVal>(other.param))
{
- if (param->equalsVal(other.param) && power == other.power)
+ if (thisGenParam->equalsVal(thatGenParam) && power == other.power)
return true;
}
return false;
diff --git a/source/slang/slang-check-conformance.cpp b/source/slang/slang-check-conformance.cpp
index 9bf343876..34d6c34cd 100644
--- a/source/slang/slang-check-conformance.cpp
+++ b/source/slang/slang-check-conformance.cpp
@@ -264,7 +264,7 @@ namespace Slang
}
return true;
}
- if (auto dynamicType = as<DynamicType>(subType))
+ if (const auto dynamicType = as<DynamicType>(subType))
{
// A __Dynamic type always conforms to the interface via its witness table.
if (outWitness)
diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp
index 6e9d73b61..12988ebcf 100644
--- a/source/slang/slang-check-constraint.cpp
+++ b/source/slang/slang-check-constraint.cpp
@@ -782,10 +782,10 @@ namespace Slang
// An error type can unify with anything, just so we avoid cascading errors.
- if (auto fstErrorType = as<ErrorType>(fst))
+ if (const auto fstErrorType = as<ErrorType>(fst))
return true;
- if (auto sndErrorType = as<ErrorType>(snd))
+ if (const auto sndErrorType = as<ErrorType>(snd))
return true;
// If one or the other of the types is a conjunction `X & Y`,
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp
index 7011e535a..d1231c72a 100644
--- a/source/slang/slang-check-conversion.cpp
+++ b/source/slang/slang-check-conversion.cpp
@@ -838,7 +838,7 @@ namespace Slang
}
// Disallow converting to a ParameterGroupType.
- if (auto toParameterGroupType = as<ParameterGroupType>(toType))
+ if (const auto toParameterGroupType = as<ParameterGroupType>(toType))
{
return _failedCoercion(toType, outToExpr, fromExpr);
}
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index b3470e882..bbbbaae2f 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1106,7 +1106,7 @@ namespace Slang
void SemanticsDeclHeaderVisitor::checkExtensionExternVarAttribute(VarDeclBase* varDecl, ExtensionExternVarModifier* extensionExternMemberModifier)
{
- if (auto parentExtension = as<ExtensionDecl>(varDecl->parentDecl))
+ if (const auto parentExtension = as<ExtensionDecl>(varDecl->parentDecl))
{
if (auto originalVarDecl = extensionExternMemberModifier->originalDecl.as<VarDeclBase>())
{
@@ -1275,7 +1275,7 @@ namespace Slang
}
}
- if (auto interfaceDecl = as<InterfaceDecl>(varDecl->parentDecl))
+ if (const auto interfaceDecl = as<InterfaceDecl>(varDecl->parentDecl))
{
if (auto basicType = as<BasicExpressionType>(varDecl->getType()))
{
@@ -2339,7 +2339,7 @@ namespace Slang
if(auto requiredTypeParamDeclRef = requiredMemberDeclRef.as<GenericTypeParamDecl>())
{
- auto satisfyingTypeParamDeclRef = satisfyingMemberDeclRef.as<GenericTypeParamDecl>();
+ [[maybe_unused]] auto satisfyingTypeParamDeclRef = satisfyingMemberDeclRef.as<GenericTypeParamDecl>();
SLANG_ASSERT(satisfyingTypeParamDeclRef);
// There are no additional checks we need to make on plain old
@@ -2349,7 +2349,6 @@ namespace Slang
// then this is possibly where we'd want to check that the kinds of
// the two parameters match.
//
- SLANG_UNUSED(satisfyingGenericDeclRef);
}
else if (auto requiredValueParamDeclRef = requiredMemberDeclRef.as<GenericValueParamDecl>())
{
@@ -3961,7 +3960,7 @@ namespace Slang
getSink()->diagnose(inheritanceDecl, Diagnostics::interfaceInheritingComMustBeCom);
}
}
- else if (auto structDecl = as<StructDecl>(superTypeDecl))
+ else if (const auto structDecl = as<StructDecl>(superTypeDecl))
{
getSink()->diagnose(inheritanceDecl, Diagnostics::structCannotImplementComInterface);
}
@@ -4042,12 +4041,12 @@ namespace Slang
// confirm that the type actually provides whatever
// those clauses require.
- if (auto interfaceDecl = as<InterfaceDecl>(decl))
+ if (const auto interfaceDecl = as<InterfaceDecl>(decl))
{
// Don't check that an interface conforms to the
// things it inherits from.
}
- else if (auto assocTypeDecl = as<AssocTypeDecl>(decl))
+ else if (const auto assocTypeDecl = as<AssocTypeDecl>(decl))
{
// Don't check that an associated type decl conforms to the
// things it inherits from.
@@ -4165,7 +4164,7 @@ namespace Slang
// It is possible that there was an error in checking the base type
// expression, and in such a case we shouldn't emit a cascading error.
//
- if( auto baseErrorType = as<ErrorType>(baseType) )
+ if( const auto baseErrorType = as<ErrorType>(baseType) )
{
continue;
}
@@ -4233,7 +4232,7 @@ namespace Slang
// It is possible that there was an error in checking the base type
// expression, and in such a case we shouldn't emit a cascading error.
//
- if( auto baseErrorType = as<ErrorType>(baseType) )
+ if( const auto baseErrorType = as<ErrorType>(baseType) )
{
continue;
}
@@ -4302,7 +4301,7 @@ namespace Slang
// It is possible that there was an error in checking the base type
// expression, and in such a case we shouldn't emit a cascading error.
//
- if (auto baseErrorType = as<ErrorType>(baseType))
+ if (const auto baseErrorType = as<ErrorType>(baseType))
{
continue;
}
@@ -4443,7 +4442,7 @@ namespace Slang
// It is possible that there was an error in checking the base type
// expression, and in such a case we shouldn't emit a cascading error.
//
- if( auto baseErrorType = as<ErrorType>(baseType) )
+ if( const auto baseErrorType = as<ErrorType>(baseType) )
{
continue;
}
@@ -4756,7 +4755,7 @@ namespace Slang
m_parentDifferentiableAttr = oldAttr;
}
- if (auto body = decl->body)
+ if (const auto body = decl->body)
{
checkStmt(decl->body, newContext);
}
@@ -4821,9 +4820,9 @@ namespace Slang
Decl* leftParam = leftParams[pp];
Decl* rightParam = rightParams[pp];
- if (auto leftTypeParam = as<GenericTypeParamDecl>(leftParam))
+ if (const auto leftTypeParam = as<GenericTypeParamDecl>(leftParam))
{
- if (auto rightTypeParam = as<GenericTypeParamDecl>(rightParam))
+ if (const auto rightTypeParam = as<GenericTypeParamDecl>(rightParam))
{
// Right now any two type parameters are a match.
// Names are irrelevant to matching, and any constraints
@@ -5828,7 +5827,7 @@ namespace Slang
// It is possible that there was an error in checking the base type
// expression, and in such a case we shouldn't emit a cascading error.
//
- if( auto baseErrorType = as<ErrorType>(baseType) )
+ if( const auto baseErrorType = as<ErrorType>(baseType) )
{
continue;
}
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 7a2c78c71..dd0cd4eab 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -933,7 +933,7 @@ namespace Slang
return type;
}
}
- if (auto witness = as<SubtypeWitness>(tryGetInterfaceConformanceWitness(type, builder->getDifferentiableInterface())))
+ if (const auto witness = as<SubtypeWitness>(tryGetInterfaceConformanceWitness(type, builder->getDifferentiableInterface())))
{
auto diffTypeLookupResult = lookUpMember(
getASTBuilder(),
@@ -1128,7 +1128,7 @@ namespace Slang
{
binding->type = type;
- if (auto body = binding->body)
+ if (const auto body = binding->body)
{
binding = as<LetExpr>(binding->body);
SLANG_ASSERT(binding);
@@ -1158,7 +1158,7 @@ namespace Slang
{
// TODO: we may want other cases here...
- if (auto errorType = as<ErrorType>(expr->type))
+ if (const auto errorType = as<ErrorType>(expr->type))
return true;
return false;
@@ -2637,7 +2637,7 @@ namespace Slang
//
if( auto declRefType = as<DeclRefType>(typeExp.type) )
{
- if(auto structDeclRef = as<StructDecl>(declRefType->declRef))
+ if(const auto structDeclRef = as<StructDecl>(declRefType->declRef))
{
if( expr->arguments.getCount() == 1 )
{
@@ -3056,7 +3056,6 @@ namespace Slang
int elementIndices[4];
int elementCount = 0;
- bool elementUsed[4] = { false, false, false, false };
bool anyDuplicates = false;
bool anyError = false;
if (memberRefExpr->name == getSession()->getCompletionRequestTokenName())
@@ -3444,7 +3443,7 @@ namespace Slang
{
return _lookupStaticMember(expr, expr->baseExpression);
}
- else if(auto typeType = as<TypeType>(baseType))
+ else if(const auto typeType = as<TypeType>(baseType))
{
return _lookupStaticMember(expr, expr->baseExpression);
}
@@ -3507,11 +3506,11 @@ namespace Slang
{
auto containerDecl = scope->containerDecl;
- if( auto ctorDecl = as<ConstructorDecl>(containerDecl) )
+ if( const auto ctorDecl = as<ConstructorDecl>(containerDecl) )
{
expr->type.isLeftValue = true;
}
- else if( auto setterDecl = as<SetterDecl>(containerDecl) )
+ else if( const auto setterDecl = as<SetterDecl>(containerDecl) )
{
expr->type.isLeftValue = true;
}
@@ -3655,18 +3654,18 @@ namespace Slang
{
SLANG_UNUSED(type);
- if( auto unormModifier = as<UNormModifier>(modifier) )
+ if( const auto unormModifier = as<UNormModifier>(modifier) )
{
// TODO: validate that `type` is either `float` or a vector of `float`s
return m_astBuilder->getUNormModifierVal();
}
- else if( auto snormModifier = as<SNormModifier>(modifier) )
+ else if( const auto snormModifier = as<SNormModifier>(modifier) )
{
// TODO: validate that `type` is either `float` or a vector of `float`s
return m_astBuilder->getSNormModifierVal();
}
- else if (auto noDiffModifier = as<NoDiffModifier>(modifier))
+ else if (const auto noDiffModifier = as<NoDiffModifier>(modifier))
{
return m_astBuilder->getNoDiffModifierVal();
}
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index e9c78e155..78a9fd163 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -500,7 +500,7 @@ namespace Slang
return false;
}
}
- else if (auto unrollAttr = as<UnrollAttribute>(attr))
+ else if (const auto unrollAttr = as<UnrollAttribute>(attr))
{
// Check has an argument. We need this because default behavior is to give an error
// if an attribute has arguments, but not handled explicitly (and the default param will come through
@@ -532,7 +532,7 @@ namespace Slang
}
}
}
- else if (auto userDefAttr = as<UserDefinedAttribute>(attr))
+ else if (const auto userDefAttr = as<UserDefinedAttribute>(attr))
{
// check arguments against attribute parameters defined in attribClassDecl
Index paramIndex = 0;
@@ -704,7 +704,7 @@ namespace Slang
return false;
}
}
- else if (auto derivativeMemberAttr = as<DerivativeMemberAttribute>(attr))
+ else if (const auto derivativeMemberAttr = as<DerivativeMemberAttribute>(attr))
{
auto varDecl = as<VarDeclBase>(attrTarget);
if (!varDecl)
@@ -801,7 +801,7 @@ namespace Slang
{
// We didn't have enough arguments for the
// number of parameters declared.
- if(auto defaultArg = paramDecl->initExpr)
+ if(const auto defaultArg = paramDecl->initExpr)
{
// The attribute declaration provided a default,
// so we should use that.
@@ -884,7 +884,7 @@ namespace Slang
}
}
- if (auto externModifier = as<ExternModifier>(m))
+ if (const auto externModifier = as<ExternModifier>(m))
{
if (auto varDecl = as<VarDeclBase>(syntaxNode))
{
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp
index eaa89c008..fbd8fb288 100644
--- a/source/slang/slang-check-overload.cpp
+++ b/source/slang/slang-check-overload.cpp
@@ -158,7 +158,7 @@ namespace Slang
auto decl = candidate.item.declRef.decl;
- if(auto prefixExpr = as<PrefixExpr>(expr))
+ if(const auto prefixExpr = as<PrefixExpr>(expr))
{
if(decl->hasModifier<PrefixModifier>())
return true;
@@ -171,7 +171,7 @@ namespace Slang
return false;
}
- else if(auto postfixExpr = as<PostfixExpr>(expr))
+ else if(const auto postfixExpr = as<PostfixExpr>(expr))
{
if(decl->hasModifier<PostfixModifier>())
return true;
@@ -1007,7 +1007,8 @@ namespace Slang
if (context.bestCandidates.getCount() != 0)
{
// We have multiple candidates right now, so filter them.
- bool anyFiltered = false;
+ // This is only used in an assert in debug builds
+ [[maybe_unused]] bool anyFiltered = false;
// Note that we are querying the list length on every iteration,
// because we might remove things.
for (Index cc = 0; cc < context.bestCandidates.getCount(); ++cc)
@@ -1214,7 +1215,6 @@ namespace Slang
// generic itself.
//
Substitutions* substForInnerDecl = genericDeclRef.substitutions;
- Count knownGenericArgCount = 0;
//
// In the case where we have explicit/known arguments,
// we will use those as our baseline substitutions.
@@ -1222,7 +1222,6 @@ namespace Slang
if (substWithKnownGenericArgs)
{
substForInnerDecl = substWithKnownGenericArgs;
- knownGenericArgCount = substWithKnownGenericArgs->getArgs().getCount();
}
auto innerDecl = getInner(genericDeclRef);
@@ -1375,11 +1374,6 @@ namespace Slang
auto genericDeclRef = genericItem.declRef.as<GenericDecl>();
SLANG_ASSERT(genericDeclRef);
- if (substWithKnownGenericArgs)
- {
- substWithKnownGenericArgs = substWithKnownGenericArgs;
- }
-
// Try to infer generic arguments, based on the context
DeclRef<Decl> innerRef = inferGenericArguments(genericDeclRef, context, substWithKnownGenericArgs);
@@ -1412,8 +1406,6 @@ namespace Slang
LookupResultItem item,
OverloadResolveContext& context)
{
- auto declRef = item.declRef;
-
if (auto funcDeclRef = item.declRef.as<CallableDecl>())
{
AddFuncOverloadCandidate(item, funcDeclRef, context);
@@ -1560,18 +1552,9 @@ namespace Slang
}
else if (auto baseFuncGenericDeclRef = funcDeclRefExpr->declRef.as<GenericDecl>())
{
- // Get inner function
- DeclRef<Decl> unspecializedInnerRef = DeclRef<Decl>(
- getInner(baseFuncGenericDeclRef),
- baseFuncGenericDeclRef.substitutions);
-
// Process func type to generate JVP func type.
auto diffFuncType = as<FuncType>(expr->type.type);
- if (!diffFuncType)
- {
- // This shouldn't happen, but we check to be safe.
- return;
- }
+ SLANG_ASSERT(diffFuncType);
// Extract parameter list from processed type.
List<Type*> paramTypes;
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index ce9715d4c..ed426831c 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -1160,7 +1160,6 @@ namespace Slang
for(Index ii = 0; ii < argCount; ++ii )
{
auto argExpr = argExprs[ii];
- auto paramInfo = componentType->getSpecializationParam(ii);
SpecializationArg arg;
arg.val = semanticsVisitor.ExtractGenericArgVal(argExpr);
diff --git a/source/slang/slang-check-type.cpp b/source/slang/slang-check-type.cpp
index 1b2179144..a5a46c435 100644
--- a/source/slang/slang-check-type.cpp
+++ b/source/slang/slang-check-type.cpp
@@ -100,11 +100,11 @@ namespace Slang
expr = resolveOverloadedExpr(overloadedExpr, LookupMask::type);
}
- if (auto typeType = as<TypeType>(expr->type))
+ if (const auto typeType = as<TypeType>(expr->type))
{
return expr;
}
- else if (auto errorType = as<ErrorType>(expr->type))
+ else if (const auto errorType = as<ErrorType>(expr->type))
{
return expr;
}
@@ -162,7 +162,7 @@ namespace Slang
{
return typeType->type;
}
- else if (auto errorType = as<ErrorType>(exp->type))
+ else if (const auto errorType = as<ErrorType>(exp->type))
{
return exp->type.type;
}
@@ -397,7 +397,7 @@ namespace Slang
{
return leftVar->declRef.equals(rightVar->declRef);
}
- else if (auto rightPoly = as<PolynomialIntVal>(right))
+ else if (const auto rightPoly = as<PolynomialIntVal>(right))
{
return right->equalsVal(leftVar);
}
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index ff7228854..0aa7e48a9 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -189,7 +189,7 @@ namespace Slang
// "dummy" entry points we create for pass-through
// compilation will not have an associated module.
//
- if( auto module = getModule() )
+ if( const auto module = getModule() )
{
return 1;
}
@@ -241,7 +241,7 @@ namespace Slang
List<SourceFile*> const& EntryPoint::getFileDependencies()
{
- if(auto module = getModule())
+ if(const auto module = getModule())
return getModule()->getFileDependencies();
static List<SourceFile*> empty;
@@ -850,7 +850,7 @@ namespace Slang
{
builder << ";" << _getDisplayPath(sink, sourceFiles[i]);
}
- return builder;
+ return std::move(builder);
}
}
}
@@ -1527,7 +1527,7 @@ namespace Slang
SLANG_RETURN_ON_FAIL(emitSPIRVForEntryPointsDirectly(this, outArtifact));
return SLANG_OK;
}
- /* fall through to: */
+ [[fallthrough]];
case CodeGenTarget::DXIL:
case CodeGenTarget::DXBytecode:
case CodeGenTarget::PTX:
diff --git a/source/slang/slang-doc-ast.cpp b/source/slang/slang-doc-ast.cpp
index eec0aa650..54155f06c 100644
--- a/source/slang/slang-doc-ast.cpp
+++ b/source/slang/slang-doc-ast.cpp
@@ -12,15 +12,15 @@ namespace Slang {
{
typedef Extractor::SearchStyle SearchStyle;
- if (auto enumCaseDecl = as<EnumCaseDecl>(decl))
+ if (const auto enumCaseDecl = as<EnumCaseDecl>(decl))
{
return SearchStyle::EnumCase;
}
- if (auto paramDecl = as<ParamDecl>(decl))
+ if (const auto paramDecl = as<ParamDecl>(decl))
{
return SearchStyle::Param;
}
- else if (auto callableDecl = as<CallableDecl>(decl))
+ else if (const auto callableDecl = as<CallableDecl>(decl))
{
return SearchStyle::Function;
}
diff --git a/source/slang/slang-doc-markdown-writer.cpp b/source/slang/slang-doc-markdown-writer.cpp
index 9993dc53e..f2e6158d5 100644
--- a/source/slang/slang-doc-markdown-writer.cpp
+++ b/source/slang/slang-doc-markdown-writer.cpp
@@ -493,8 +493,6 @@ static void _addRequirementFromTargetToken(const Token& tok, List<DocMarkdownWri
static void _addRequirements(Decl* decl, List<DocMarkdownWriter::Requirement>& ioReqs)
{
- typedef DocMarkdownWriter::Requirement Requirement;
-
StringBuilder buf;
if (auto spirvRequiredModifier = decl->findModifier<RequiredSPIRVVersionModifier>())
@@ -527,7 +525,7 @@ static void _addRequirements(Decl* decl, List<DocMarkdownWriter::Requirement>& i
_addRequirement(CodeGenTarget::GLSL, buf, ioReqs);
}
- if (auto requiresNVAPIAttribute = decl->findModifier<RequiresNVAPIAttribute>())
+ if (const auto requiresNVAPIAttribute = decl->findModifier<RequiresNVAPIAttribute>())
{
_addRequirement(CodeGenTarget::HLSL, "NVAPI", ioReqs);
}
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 34467d25d..5a40b51ef 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -582,12 +582,12 @@ void CLikeSourceEmitter::emitStringLiteral(String const& value)
m_writer->emit(buffer);
break;
- case '\"': m_writer->emit("\\\"");
- case '\'': m_writer->emit("\\\'");
- case '\\': m_writer->emit("\\\\");
- case '\n': m_writer->emit("\\n");
- case '\r': m_writer->emit("\\r");
- case '\t': m_writer->emit("\\t");
+ case '\"': m_writer->emit("\\\""); break;
+ case '\'': m_writer->emit("\\\'"); break;
+ case '\\': m_writer->emit("\\\\"); break;
+ case '\n': m_writer->emit("\\n"); break;
+ case '\r': m_writer->emit("\\r"); break;
+ case '\t': m_writer->emit("\\t"); break;
}
}
m_writer->emit("\"");
@@ -3094,7 +3094,7 @@ void CLikeSourceEmitter::emitStruct(IRStructType* structType)
{
// If the selected `struct` type is actually an intrinsic
// on our target, then we don't want to emit anything at all.
- if(auto intrinsicDecoration = findBestTargetIntrinsicDecoration(structType))
+ if(const auto intrinsicDecoration = findBestTargetIntrinsicDecoration(structType))
{
return;
}
@@ -3143,7 +3143,7 @@ void CLikeSourceEmitter::emitClass(IRClassType* classType)
{
// If the selected `class` type is actually an intrinsic
// on our target, then we don't want to emit anything at all.
- if (auto intrinsicDecoration = findBestTargetIntrinsicDecoration(classType))
+ if (const auto intrinsicDecoration = findBestTargetIntrinsicDecoration(classType))
{
return;
}
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 83f487cb9..df6ab4901 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -889,7 +889,7 @@ void CPPSourceEmitter::emitSimpleFuncImpl(IRFunc* func)
}
// We start by emitting the result type and function name.
//
- if (IREntryPointDecoration* entryPointDecor = func->findDecoration<IREntryPointDecoration>())
+ if (IREntryPointDecoration* const entryPointDecor = func->findDecoration<IREntryPointDecoration>())
{
// Note: we currently emit multiple functions to represent an entry point
// on CPU/CUDA, and these all bottleneck through the actual `IRFunc`
diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp
index 23b3ae686..a1e21f626 100644
--- a/source/slang/slang-emit-cuda.cpp
+++ b/source/slang/slang-emit-cuda.cpp
@@ -519,7 +519,7 @@ bool CUDASourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
m_writer->emit(")");
return true;
}
- else if (auto matrixType = as<IRMatrixType>(inst->getDataType()))
+ else if (const auto matrixType = as<IRMatrixType>(inst->getDataType()))
{
m_writer->emit("make");
emitType(inst->getDataType());
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index d0154ab91..0abd78137 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -1654,7 +1654,7 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
case kIROp_Not:
{
IRInst* operand = inst->getOperand(0);
- if (auto vectorType = as<IRVectorType>(operand->getDataType()))
+ if (const auto vectorType = as<IRVectorType>(operand->getDataType()))
{
EmitOpInfo outerPrec = inOuterPrec;
bool needClose = false;
@@ -1719,7 +1719,7 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
auto prec = getInfo(EmitOp::Postfix);
EmitOpInfo outerPrec = inOuterPrec;
- bool needClose = maybeEmitParens(outerPrec, outerPrec);
+ bool needClose = maybeEmitParens(outerPrec, prec);
m_writer->emit(funcName);
m_writer->emit("(");
@@ -1745,7 +1745,7 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
auto prec = getInfo(EmitOp::Postfix);
EmitOpInfo outerPrec = inOuterPrec;
- bool needClose = maybeEmitParens(outerPrec, outerPrec);
+ bool needClose = maybeEmitParens(outerPrec, prec);
// TODO: the GLSL `mod` function amounts to a floating-point
// modulus rather than a floating-point remainder. We need
@@ -2175,7 +2175,7 @@ void GLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
_emitGLSLTextureOrTextureSamplerType(imageType, "image");
return;
}
- else if (auto structuredBufferType = as<IRHLSLStructuredBufferTypeBase>(type))
+ else if (const auto structuredBufferType = as<IRHLSLStructuredBufferTypeBase>(type))
{
// TODO: We desugar global variables with structured-buffer type into GLSL
// `buffer` declarations, but we don't currently handle structured-buffer types
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 21cf677f9..e07d9facc 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -898,7 +898,7 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
_emitHLSLTextureType(texType);
return;
}
- else if (auto textureSamplerType = as<IRTextureSamplerType>(type))
+ else if (const auto textureSamplerType = as<IRTextureSamplerType>(type))
{
SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "this target should see combined texture-sampler types");
return;
@@ -929,7 +929,7 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
return;
}
- else if (auto untypedBufferType = as<IRUntypedBufferResourceType>(type))
+ else if (const auto untypedBufferType = as<IRUntypedBufferResourceType>(type))
{
switch (type->getOp())
{
@@ -1039,7 +1039,7 @@ void HLSLSourceEmitter::_emitStageAccessSemantic(IRStageAccessDecoration* decora
void HLSLSourceEmitter::emitPostKeywordTypeAttributesImpl(IRInst* inst)
{
- if( auto payloadDecoration = inst->findDecoration<IRPayloadDecoration>() )
+ if( const auto payloadDecoration = inst->findDecoration<IRPayloadDecoration>() )
{
m_writer->emit("[payload] ");
}
@@ -1235,7 +1235,7 @@ void HLSLSourceEmitter::emitFrontMatterImpl(TargetRequest* targetReq)
void HLSLSourceEmitter::emitGlobalInstImpl(IRInst* inst)
{
- if( auto nvapiDecor = inst->findDecoration<IRNVAPIMagicDecoration>() )
+ if( const auto nvapiDecor = inst->findDecoration<IRNVAPIMagicDecoration>() )
{
// When emitting one of the "magic" NVAPI declarations,
// we will wrap it in a preprocessor conditional that
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 8710c608a..fc2505d63 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -2281,6 +2281,7 @@ struct SPIRVEmitContext
element1,
element2);
}
+ break;
case SpvSnippet::ASMType::Int:
result = emitIntConstant((IRIntegerValue)constant.intValues[0], builder.getIntType());
break;
@@ -2359,7 +2360,7 @@ struct SPIRVEmitContext
emitOperand(kResultID);
break;
case SpvSnippet::ASMOperandType::ResultTypeId:
- if (operand.content != -1)
+ if (operand.content != 0xFFFFFFFF)
{
emitOperand(context.qualifiedResultTypes[(SpvStorageClass)operand.content]
.getValue());
@@ -2731,7 +2732,7 @@ struct SPIRVEmitContext
{
elementType = vectorType->getElementType();
}
- else if (auto matrixType = as<IRMatrixType>(inst->getDataType()))
+ else if (const auto matrixType = as<IRMatrixType>(inst->getDataType()))
{
//TODO: implement.
SLANG_ASSERT(!"unimplemented: matrix arithemetic");
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index 4412eccb8..62a1365c0 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -294,6 +294,7 @@ Result linkAndOptimizeIR(
case CodeGenTarget::CPPSource:
passOptions.alwaysCreateCollectedParam = true;
+ [[fallthrough]];
default:
collectEntryPointUniformParams(irModule, passOptions);
#if 0
diff --git a/source/slang/slang-intrinsic-expand.cpp b/source/slang/slang-intrinsic-expand.cpp
index 7a4744d59..53f113962 100644
--- a/source/slang/slang-intrinsic-expand.cpp
+++ b/source/slang/slang-intrinsic-expand.cpp
@@ -335,7 +335,7 @@ const char* IntrinsicExpandContext::_emitSpecial(const char* cursor)
auto textureArg = m_args[0].get();
- if (auto baseTextureSamplerType = as<IRTextureSamplerType>(textureArg->getDataType()))
+ if (const auto baseTextureSamplerType = as<IRTextureSamplerType>(textureArg->getDataType()))
{
// If the base object (first argument) has a combined texture-sampler type,
// then we can simply use that argument as-is.
@@ -513,7 +513,7 @@ const char* IntrinsicExpandContext::_emitSpecial(const char* cursor)
}
SLANG_ASSERT(elementType);
- if (auto basicType = as<IRBasicType>(elementType))
+ if (const auto basicType = as<IRBasicType>(elementType))
{
// A scalar result is expected
m_writer->emit(".x");
diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp
index 819c6bc57..e78217fe3 100644
--- a/source/slang/slang-ir-autodiff-fwd.cpp
+++ b/source/slang/slang-ir-autodiff-fwd.cpp
@@ -55,7 +55,7 @@ void ForwardDiffTranscriber::generateTrivialFwdDiffFunc(IRFunc* primalFunc, IRFu
for (auto param : primalFunc->getParams())
{
- transcribeFuncParam(&builder, param, param->getFullType()).differential;
+ transcribeFuncParam(&builder, param, param->getFullType());
}
List<IRParam*> diffParams;
for (auto param : diffFunc->getParams())
@@ -131,7 +131,7 @@ InstPair ForwardDiffTranscriber::transcribeUndefined(IRBuilder* builder, IRInst*
{
auto primalVal = maybeCloneForPrimalInst(builder, origInst);
- if (IRType* diffType = differentiateType(builder, origInst->getFullType()))
+ if (IRType* const diffType = differentiateType(builder, origInst->getFullType()))
{
auto dzero = getDifferentialZeroOfType(builder, origInst->getFullType());
if (dzero)
@@ -393,7 +393,7 @@ InstPair ForwardDiffTranscriber::transcribeConstruct(IRBuilder* builder, IRInst*
else
{
auto operandDataType = origConstruct->getOperand(ii)->getDataType();
- if (auto diffOperandType = differentiateType(builder, operandDataType))
+ if (const auto diffOperandType = differentiateType(builder, operandDataType))
{
operandDataType = (IRType*)findOrTranscribePrimalInst(builder, operandDataType);
diffOperands.add(getDifferentialZeroOfType(builder, operandDataType));
@@ -1083,7 +1083,7 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI
diffAccessChain.add(key);
}
}
- if (auto diffType = differentiateType(builder, originalInst->getDataType()))
+ if (const auto diffType = differentiateType(builder, originalInst->getDataType()))
{
auto diffBase = findOrTranscribeDiffInst(builder, origBase);
if (!diffBase)
@@ -1483,14 +1483,10 @@ IRFunc* ForwardDiffTranscriber::transcribeFuncHeaderImpl(IRBuilder* inBuilder, I
{
IRBuilder builder = *inBuilder;
- IRFunc* primalFunc = origFunc;
-
maybeMigrateDifferentiableDictionaryFromDerivativeFunc(inBuilder, origFunc);
differentiableTypeConformanceContext.setFunc(origFunc);
- primalFunc = origFunc;
-
auto diffFunc = builder.createFunc();
SLANG_ASSERT(as<IRFuncType>(origFunc->getFullType()));
@@ -1553,7 +1549,7 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func)
List<IRParam*> params;
for (auto param : firstBlock->getParams())
{
- if (auto ptrType = as<IRPtrTypeBase>(param->getDataType()))
+ if (const auto ptrType = as<IRPtrTypeBase>(param->getDataType()))
{
params.add(param);
}
diff --git a/source/slang/slang-ir-autodiff-pairs.cpp b/source/slang/slang-ir-autodiff-pairs.cpp
index 4082a1c86..7fc8ebbe6 100644
--- a/source/slang/slang-ir-autodiff-pairs.cpp
+++ b/source/slang/slang-ir-autodiff-pairs.cpp
@@ -7,8 +7,7 @@ struct DiffPairLoweringPass : InstPassBase
{
DiffPairLoweringPass(AutoDiffSharedContext* context) :
InstPassBase(context->moduleInst->getModule()),
- pairBuilderStorage(context),
- autodiffContext(context)
+ pairBuilderStorage(context)
{
pairBuilder = &pairBuilderStorage;
}
@@ -149,8 +148,6 @@ struct DiffPairLoweringPass : InstPassBase
private:
- AutoDiffSharedContext* autodiffContext;
-
DifferentialPairTypeBuilder* pairBuilder;
DifferentialPairTypeBuilder pairBuilderStorage;
diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp
index af47ffbca..906465384 100644
--- a/source/slang/slang-ir-autodiff-primal-hoist.cpp
+++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp
@@ -546,20 +546,6 @@ void applyCheckpointSet(
{
for (auto use : pendingUses)
cloneCtx->pendingUses.add(use);
-
- // Populate the clone context with all the primal uses that we may need to replace with
- // cloned versions. That way any insts we clone into the diff block will automatically replace
- // their uses.
- //
- auto addPrimalUsesToCloneContext = [&](IRInst* inst)
- {
- UIndex opIndex = 0;
- for (auto operand = inst->getOperands(); opIndex < inst->getOperandCount(); operand++, opIndex++)
- {
- if (!isDifferentialInst(operand->get()))
- cloneCtx->pendingUses.add(operand);
- }
- };
// Go back over the insts and move/clone them accoridngly.
auto paramPreludeBlock = getParamPreludeBlock(func);
@@ -933,7 +919,7 @@ RefPtr<HoistedPrimalsInfo> ensurePrimalAvailability(
for (auto instToStore : instSet)
{
IRBlock* defBlock = nullptr;
- if (auto ptrInst = as<IRPtrTypeBase>(instToStore->getDataType()))
+ if (const auto ptrInst = as<IRPtrTypeBase>(instToStore->getDataType()))
{
auto varInst = as<IRVar>(instToStore);
auto storeUse = findEarliestUniqueWriteUse(varInst);
@@ -998,7 +984,7 @@ RefPtr<HoistedPrimalsInfo> ensurePrimalAvailability(
defBlockIndices.clear();
}
}
- if (auto ptrInst = as<IRPtrTypeBase>(instToStore->getDataType()))
+ if (const auto ptrInst = as<IRPtrTypeBase>(instToStore->getDataType()))
{
IRVar* varToStore = as<IRVar>(instToStore);
SLANG_RELEASE_ASSERT(varToStore);
@@ -1388,7 +1374,7 @@ static bool isIntermediateContextType(IRType* type)
static bool shouldStoreVar(IRVar* var)
{
// Always store intermediate context var.
- if (auto typeDecor = var->findDecoration<IRBackwardDerivativePrimalContextDecoration>())
+ if (const auto typeDecor = var->findDecoration<IRBackwardDerivativePrimalContextDecoration>())
{
// If we are specializing a callee's intermediate context with types that can't be stored,
// we can't store the entire context.
diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp
index e5735b831..ecc36d6ba 100644
--- a/source/slang/slang-ir-autodiff-rev.cpp
+++ b/source/slang/slang-ir-autodiff-rev.cpp
@@ -421,7 +421,7 @@ namespace Slang
{
primalArg = builder.emitLoad(param);
}
- if (auto diffPairType = as<IRDifferentialPairType>(primalArg->getDataType()))
+ if (const auto diffPairType = as<IRDifferentialPairType>(primalArg->getDataType()))
{
primalArg = builder.emitDifferentialPairGetPrimal(primalArg);
}
@@ -544,7 +544,7 @@ namespace Slang
eliminateMultiLevelBreakForFunc(func->getModule(), func);
IRCFGNormalizationPass cfgPass = {this->getSink()};
- normalizeCFG(autoDiffSharedContext->moduleInst->getModule(), func);
+ normalizeCFG(autoDiffSharedContext->moduleInst->getModule(), func, cfgPass);
return SLANG_OK;
}
diff --git a/source/slang/slang-ir-autodiff-rev.h b/source/slang/slang-ir-autodiff-rev.h
index 845372ba7..15d558c22 100644
--- a/source/slang/slang-ir-autodiff-rev.h
+++ b/source/slang/slang-ir-autodiff-rev.h
@@ -106,7 +106,7 @@ struct BackwardDiffTranscriberBase : AutoDiffTranscriberBase
void writeBackDerivativeToInOutParams(ParameterBlockTransposeInfo& info, IRFunc* diffFunc);
- InstPair transcribeFuncParam(IRBuilder* builder, IRParam* origParam, IRInst* primalType);
+ virtual InstPair transcribeFuncParam(IRBuilder* builder, IRParam* origParam, IRInst* primalType) override;
InstPair transcribeSpecialize(IRBuilder* builder, IRSpecialize* origSpecialize);
diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp
index 1f7f5e413..0d39f879e 100644
--- a/source/slang/slang-ir-autodiff-transcriber-base.cpp
+++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp
@@ -411,6 +411,8 @@ IRType* AutoDiffTranscriberBase::_differentiateTypeImpl(IRBuilder* builder, IRTy
return differentiateType(builder, origType);
else if (as<IRWitnessTableType>(primalType->getDataType()))
return (IRType*)primalType;
+ else
+ return nullptr;
case kIROp_ArrayType:
{
@@ -990,7 +992,7 @@ InstPair AutoDiffTranscriberBase::transcribeGeneric(IRBuilder* inBuilder, IRGene
return InstPair(origGeneric, nullptr);
differentiableTypeConformanceContext.setFunc(innerFunc);
}
- else if (auto funcType = as<IRFuncType>(innerVal))
+ else if (const auto funcType = as<IRFuncType>(innerVal))
{
}
else
@@ -1029,7 +1031,7 @@ InstPair AutoDiffTranscriberBase::transcribeGeneric(IRBuilder* inBuilder, IRGene
auto bodyBlock = builder.emitBlock();
mapPrimalInst(origGeneric->getFirstBlock(), bodyBlock);
mapDifferentialInst(origGeneric->getFirstBlock(), bodyBlock);
- auto transcribedBlock = transcribeBlockImpl(&builder, origGeneric->getFirstBlock(), instsToSkip);
+ transcribeBlockImpl(&builder, origGeneric->getFirstBlock(), instsToSkip);
return InstPair(primalGeneric, diffGeneric);
}
diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h
index 910c23708..e8cb821bd 100644
--- a/source/slang/slang-ir-autodiff-transpose.h
+++ b/source/slang/slang-ir-autodiff-transpose.h
@@ -492,7 +492,7 @@ struct DiffTransposePass
branchInst->getTargetBlock(),
false);
}
- else if (auto returnInst = as<IRReturn>(currentBlock->getTerminator()))
+ else if (const auto returnInst = as<IRReturn>(currentBlock->getTerminator()))
{
return RegionEntryPoint(
revBlockMap[currentBlock],
@@ -1736,7 +1736,7 @@ struct DiffTransposePass
{
auto argOperand = fwdMakeMatrix->getOperand(ii);
IRInst* gradAtIndex = nullptr;
- if (auto vecType = as<IRVectorType>(argOperand->getDataType()))
+ if (const auto vecType = as<IRVectorType>(argOperand->getDataType()))
{
gradAtIndex = builder->emitElementExtract(
argOperand->getDataType(),
diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h
index 63b46f779..1d05a8081 100644
--- a/source/slang/slang-ir-autodiff-unzip.h
+++ b/source/slang/slang-ir-autodiff-unzip.h
@@ -321,7 +321,7 @@ struct DiffUnzipPass
SLANG_ASSERT(diffArg);
auto primalParamType = resolvedPrimalFuncType->getParamType(ii);
- if (auto outType = as<IROutType>(primalParamType))
+ if (const auto outType = as<IROutType>(primalParamType))
{
// For `out` parameters that expects an input derivative to propagate through,
// we insert a `LoadReverseGradient` inst here to signify the logic in `transposeStore`
@@ -334,7 +334,7 @@ struct DiffUnzipPass
diffBuilder->markInstAsDifferential(gradArg, primalArg->getDataType());
diffArgs.add(gradArg);
}
- else if (auto inoutType = as<IRInOutType>(primalParamType))
+ else if (const auto inoutType = as<IRInOutType>(primalParamType))
{
// Since arg is split into separate vars, we need a new temp var that represents
// the remerged diff pair.
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp
index 4e33a01ab..4889558a5 100644
--- a/source/slang/slang-ir-autodiff.cpp
+++ b/source/slang/slang-ir-autodiff.cpp
@@ -153,7 +153,7 @@ IRInst* DifferentialPairTypeBuilder::emitFieldAccessor(IRBuilder* builder, IRIns
if (auto ptrInnerSpecializedType = as<IRSpecialize>(ptrType->getValueType()))
{
auto genericType = findInnerMostGenericReturnVal(as<IRGeneric>(ptrInnerSpecializedType->getBase()));
- if (auto genericBasePairStructType = as<IRStructType>(genericType))
+ if (const auto genericBasePairStructType = as<IRStructType>(genericType))
{
return as<IRFieldAddress>(builder->emitFieldAddress(
builder->getPtrType((IRType*)
@@ -499,6 +499,8 @@ IRType* DifferentiableTypeConformanceContext::differentiateType(IRBuilder* build
return differentiateType(builder, primalType);
else if (as<IRWitnessTableType>(primalType->getDataType()))
return (IRType*)primalType;
+ else
+ return nullptr;
case kIROp_ArrayType:
{
@@ -1412,6 +1414,7 @@ struct AutoDiffPass : public InstPassBase
for (UInt i = 0; i < type->getOperandCount(); i++)
if (!isTypeFullyDifferentiated(type->getOperand(i)))
return false;
+ [[fallthrough]];
default:
fullyDifferentiatedInsts.add(type);
return true;
@@ -1780,7 +1783,7 @@ IRInst* getInstInBlock(IRInst* inst)
{
SLANG_RELEASE_ASSERT(inst);
- if (auto block = as<IRBlock>(inst->getParent()))
+ if (const auto block = as<IRBlock>(inst->getParent()))
return inst;
return getInstInBlock(inst->getParent());
@@ -1853,7 +1856,7 @@ IRUse* findUniqueStoredVal(IRVar* var)
IRUse* primalCallUse = nullptr;
for (auto use = var->firstUse; use; use = use->nextUse)
{
- if (auto callInst = as<IRCall>(use->getUser()))
+ if (const auto callInst = as<IRCall>(use->getUser()))
{
// Should not see more than one IRCall. If we do
// we'll need to pick the primal call.
@@ -1869,7 +1872,7 @@ IRUse* findUniqueStoredVal(IRVar* var)
IRUse* storeUse = nullptr;
for (auto use = var->firstUse; use; use = use->nextUse)
{
- if (auto storeInst = as<IRStore>(use->getUser()))
+ if (const auto storeInst = as<IRStore>(use->getUser()))
{
// Should not see more than one IRStore
SLANG_RELEASE_ASSERT(!storeUse);
@@ -1890,7 +1893,7 @@ IRUse* findLatestUniqueWriteUse(IRVar* var)
// If no unique store found, try to look for a call.
for (auto use = var->firstUse; use; use = use->nextUse)
{
- if (auto callInst = as<IRCall>(use->getUser()))
+ if (const auto callInst = as<IRCall>(use->getUser()))
{
SLANG_RELEASE_ASSERT(!storeUse);
storeUse = use;
@@ -1912,7 +1915,7 @@ IRUse* findEarliestUniqueWriteUse(IRVar* var)
// If no unique store found, try to look for a call.
for (auto use = var->firstUse; use; use = use->nextUse)
{
- if (auto callInst = as<IRCall>(use->getUser()))
+ if (const auto callInst = as<IRCall>(use->getUser()))
{
SLANG_RELEASE_ASSERT(!storeUse);
storeUse = use;
diff --git a/source/slang/slang-ir-check-differentiability.cpp b/source/slang/slang-ir-check-differentiability.cpp
index e1601c39a..1d6d2d039 100644
--- a/source/slang/slang-ir-check-differentiability.cpp
+++ b/source/slang/slang-ir-check-differentiability.cpp
@@ -269,8 +269,8 @@ public:
case kIROp_FloatLit:
return true;
case kIROp_Call:
- return inst->findDecoration<IRTreatAsDifferentiableDecoration>() || isDifferentiableFunc(as<IRCall>(inst)->getCallee(), requiredDiffLevel)
- && isDifferentiableType(diffTypeContext, inst->getFullType());
+ return inst->findDecoration<IRTreatAsDifferentiableDecoration>() ||
+ isDifferentiableFunc(as<IRCall>(inst)->getCallee(), requiredDiffLevel) && isDifferentiableType(diffTypeContext, inst->getFullType());
case kIROp_Load:
// We don't have more knowledge on whether diff is available at the destination address.
// Just assume it is producing diff if the dest address can hold a derivative.
diff --git a/source/slang/slang-ir-constexpr.cpp b/source/slang/slang-ir-constexpr.cpp
index 883997d8a..1174a53ae 100644
--- a/source/slang/slang-ir-constexpr.cpp
+++ b/source/slang/slang-ir-constexpr.cpp
@@ -30,7 +30,7 @@ bool isConstExpr(IRType* fullType)
if( auto rateQualifiedType = as<IRRateQualifiedType>(fullType))
{
auto rate = rateQualifiedType->getRate();
- if(auto constExprRate = as<IRConstExprRate>(rate))
+ if(const auto constExprRate = as<IRConstExprRate>(rate))
return true;
}
diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp
index 986f98c84..8181deb1b 100644
--- a/source/slang/slang-ir-glsl-legalize.cpp
+++ b/source/slang/slang-ir-glsl-legalize.cpp
@@ -1894,7 +1894,7 @@ void legalizeMeshOutputParam(
assign(builder, d,
ScalarizedVal::value(builder->emitLoad(tmp)));
}
- else if(auto swiz = as<IRSwizzledStore>(s))
+ else if(const auto swiz = as<IRSwizzledStore>(s))
{
SLANG_UNEXPECTED("Swizzled store to a non-address ScalarizedVal");
}
@@ -2107,7 +2107,7 @@ void legalizeEntryPointParameterForGLSL(
if (auto streamType = as<IRHLSLStreamOutputType>(type))
{
- if (auto decor = func->findDecoration<IRStreamOutputTypeDecoration>())
+ if ([[maybe_unused]] auto decor = func->findDecoration<IRStreamOutputTypeDecoration>())
{
// If it has the same stream out type, we *may* be ok (might not work for all types of streams)
SLANG_ASSERT(decor->getStreamType()->getOp() == streamType->getOp());
@@ -2155,7 +2155,7 @@ void legalizeEntryPointParameterForGLSL(
if( auto paramPtrType = as<IROutTypeBase>(paramType) )
{
auto valueType = paramPtrType->getValueType();
- if( auto gsStreamType = as<IRHLSLStreamOutputType>(valueType) )
+ if( const auto gsStreamType = as<IRHLSLStreamOutputType>(valueType) )
{
// An output stream type like `TriangleStream<Foo>` should
// more or less translate into `out Foo` (plus scalarization).
@@ -2321,7 +2321,7 @@ void legalizeEntryPointParameterForGLSL(
auto localVariable = builder->emitVar(valueType);
auto localVal = ScalarizedVal::address(localVariable);
- if( auto inOutType = as<IRInOutType>(paramPtrType) )
+ if( const auto inOutType = as<IRInOutType>(paramPtrType) )
{
// In the `in out` case we need to declare two
// sets of global variables: one for the `in`
diff --git a/source/slang/slang-ir-legalize-types.cpp b/source/slang/slang-ir-legalize-types.cpp
index c07da3e56..135425676 100644
--- a/source/slang/slang-ir-legalize-types.cpp
+++ b/source/slang/slang-ir-legalize-types.cpp
@@ -2820,7 +2820,7 @@ static void _addFieldsToWrappedBufferElementTypeLayout(
{
if( auto existentialTypeLayout = as<IRExistentialTypeLayout>(elementTypeLayout) )
{
- if( auto pendingTypeLayout = existentialTypeLayout->getPendingDataTypeLayout() )
+ if( const auto pendingTypeLayout = existentialTypeLayout->getPendingDataTypeLayout() )
{
SLANG_ASSERT(tupleInfo->elements.getCount() == 1);
diff --git a/source/slang/slang-ir-legalize-varying-params.cpp b/source/slang/slang-ir-legalize-varying-params.cpp
index a49c61499..d6a12b0b3 100644
--- a/source/slang/slang-ir-legalize-varying-params.cpp
+++ b/source/slang/slang-ir-legalize-varying-params.cpp
@@ -464,7 +464,7 @@ protected:
auto localVar = builder.emitVar(valueType);
auto localVal = LegalizedVaryingVal::makeAddress(localVar);
- if( auto inOutType = as<IRInOutType>(paramPtrType) )
+ if( const auto inOutType = as<IRInOutType>(paramPtrType) )
{
// If the parameter was an `inout` and not just an `out`
// parameter, we will create one more more legal `in`
@@ -1122,7 +1122,7 @@ struct CUDAEntryPointVaryingParamLegalizeContext : EntryPointVaryingParamLegaliz
}
return builder->emitMakeVector(typeToFetch, elementVals.getCount(), elementVals.getBuffer());
}
- else if (auto basicType = as<IRBasicType>(typeToFetch))
+ else if (const auto basicType = as<IRBasicType>(typeToFetch))
{
IRIntegerValue idx = ioBaseAttributeIndex;
auto idxInst = builder->getIntValue(builder->getIntType(), idx);
diff --git a/source/slang/slang-ir-lower-witness-lookup.cpp b/source/slang/slang-ir-lower-witness-lookup.cpp
index 0e46987c7..fd86e1d3c 100644
--- a/source/slang/slang-ir-lower-witness-lookup.cpp
+++ b/source/slang/slang-ir-lower-witness-lookup.cpp
@@ -258,7 +258,7 @@ struct WitnessLookupLoweringContext
auto entry = findWitnessTableEntry(witnessTable, requirementKey);
SLANG_RELEASE_ASSERT(entry);
// If the entry is a generic, we need to specialize it.
- if (auto genericEntry = as<IRGeneric>(entry))
+ if (const auto genericEntry = as<IRGeneric>(entry))
{
auto specializedFuncType = builder.emitSpecializeInst(
builder.getTypeKind(),
diff --git a/source/slang/slang-ir-marshal-native-call.cpp b/source/slang/slang-ir-marshal-native-call.cpp
index 4074a5c67..3fcc02de0 100644
--- a/source/slang/slang-ir-marshal-native-call.cpp
+++ b/source/slang/slang-ir-marshal-native-call.cpp
@@ -204,7 +204,7 @@ namespace Slang
}
auto originalReturnType = originalFunc->getResultType();
auto callInst = builder.emitCallInst(originalReturnType, originalFunc, args);
- if (auto resultType = as<IRResultType>(originalReturnType))
+ if (const auto resultType = as<IRResultType>(originalReturnType))
{
auto isResultError = builder.emitIsResultError(callInst);
IRBlock* trueBlock = nullptr;
diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp
index fa3e854f2..b9ce2893a 100644
--- a/source/slang/slang-ir-peephole.cpp
+++ b/source/slang/slang-ir-peephole.cpp
@@ -502,7 +502,7 @@ struct PeepholeContext : InstPassBase
}
}
}
- else if (auto structKey = as<IRStructKey>(key))
+ else if (const auto structKey = as<IRStructKey>(key))
{
auto oldVal = inst->getOperand(0);
if (oldVal->getOp() == kIROp_MakeStruct)
diff --git a/source/slang/slang-ir-redundancy-removal.cpp b/source/slang/slang-ir-redundancy-removal.cpp
index b139d4194..32c6abd39 100644
--- a/source/slang/slang-ir-redundancy-removal.cpp
+++ b/source/slang/slang-ir-redundancy-removal.cpp
@@ -246,7 +246,7 @@ bool tryRemoveRedundantStore(IRGlobalValueWithCode* func, IRStore* store)
// A store can be removed if it stores into a local variable
// that has no other uses than store.
- if (auto varInst = as<IRVar>(rootVar))
+ if (const auto varInst = as<IRVar>(rootVar))
{
bool hasNonStoreUse = false;
// If the entire access chain doesn't non-store use, we can safely remove it.
diff --git a/source/slang/slang-ir-restructure.cpp b/source/slang/slang-ir-restructure.cpp
index 9ba7a2b20..7606de263 100644
--- a/source/slang/slang-ir-restructure.cpp
+++ b/source/slang/slang-ir-restructure.cpp
@@ -251,7 +251,7 @@ namespace Slang
// information that can inform our control-flow restructuring pass.
//
SLANG_UNEXPECTED("unhandled terminator instruction opcode");
- ; // fall through to:
+ [[fallthrough]];
case kIROp_Unreachable:
case kIROp_MissingReturn:
case kIROp_Return:
diff --git a/source/slang/slang-ir-sccp.cpp b/source/slang/slang-ir-sccp.cpp
index d253163c0..9ad51e0e6 100644
--- a/source/slang/slang-ir-sccp.cpp
+++ b/source/slang/slang-ir-sccp.cpp
@@ -1011,7 +1011,7 @@ struct SCCPContext
// since abstract interpretation of them should cause blocks to
// be marked as executed, etc.
//
- if( auto terminator = as<IRTerminatorInst>(inst) )
+ if( const auto terminator = as<IRTerminatorInst>(inst) )
{
if( auto unconditionalBranch = as<IRUnconditionalBranch>(inst) )
{
diff --git a/source/slang/slang-ir-specialize-arrays.cpp b/source/slang/slang-ir-specialize-arrays.cpp
index 5b9a7b1c2..3f42fb4b0 100644
--- a/source/slang/slang-ir-specialize-arrays.cpp
+++ b/source/slang/slang-ir-specialize-arrays.cpp
@@ -21,7 +21,7 @@ struct ArrayParameterSpecializationCondition : FunctionCallSpecializeCondition
{
for (auto field : structType->getFields())
{
- if (auto arrayType = as<IRArrayType>(field->getFieldType()))
+ if (const auto arrayType = as<IRArrayType>(field->getFieldType()))
{
return true;
}
diff --git a/source/slang/slang-ir-specialize-buffer-load-arg.cpp b/source/slang/slang-ir-specialize-buffer-load-arg.cpp
index 891872582..8b4e1d5db 100644
--- a/source/slang/slang-ir-specialize-buffer-load-arg.cpp
+++ b/source/slang/slang-ir-specialize-buffer-load-arg.cpp
@@ -59,7 +59,7 @@ struct FuncBufferLoadSpecializationCondition : FunctionCallSpecializeCondition
// The "root" of the parameter must be a reference to a global-scope
// shader parameter, so that we know we can substitute it into the callee.
//
- if (auto argGlobalParam = as<IRGlobalParam>(a))
+ if (const auto argGlobalParam = as<IRGlobalParam>(a))
{
return true;
}
diff --git a/source/slang/slang-ir-specialize-dispatch.cpp b/source/slang/slang-ir-specialize-dispatch.cpp
index b7bab777a..4b26ced32 100644
--- a/source/slang/slang-ir-specialize-dispatch.cpp
+++ b/source/slang/slang-ir-specialize-dispatch.cpp
@@ -22,7 +22,8 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext,
// We now find the relavent instructions.
IRCall* callInst = nullptr;
IRLookupWitnessMethod* lookupInst = nullptr;
- IRReturn* returnInst = nullptr;
+ // Only used in debug builds as a sanity check
+ [[maybe_unused]] IRReturn* returnInst = nullptr;
for (auto inst : block->getOrdinaryInsts())
{
switch (inst->getOp())
diff --git a/source/slang/slang-ir-specialize.cpp b/source/slang/slang-ir-specialize.cpp
index fb00a960f..5962f6dbb 100644
--- a/source/slang/slang-ir-specialize.cpp
+++ b/source/slang/slang-ir-specialize.cpp
@@ -409,7 +409,7 @@ struct SpecializationContext
decor->getOp() == kIROp_UserDefinedBackwardDerivativeDecoration)
{
// If we already have a diff func on this specialize, skip.
- if (auto specDiffRef = specInst->findDecorationImpl(decor->getOp()))
+ if (const auto specDiffRef = specInst->findDecorationImpl(decor->getOp()))
{
continue;
}
@@ -1051,7 +1051,7 @@ struct SpecializationContext
// A subscript operation on mutable buffers returns a ptr type instead of a value type.
// We need to make sure the pointer-ness is preserved correctly.
auto innerResultType = elementType;
- if (auto ptrResultType = as<IRPtrType>(inst->getDataType()))
+ if (const auto ptrResultType = as<IRPtrType>(inst->getDataType()))
{
innerResultType = builder.getPtrType(elementType);
}
diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp
index e62952556..48cf2976f 100644
--- a/source/slang/slang-ir-ssa.cpp
+++ b/source/slang/slang-ir-ssa.cpp
@@ -820,7 +820,7 @@ void collectInstsToRemove(
case kIROp_FieldAddress:
{
auto ptrArg = ii->getOperand(0);
- if (auto var = asPromotableVarAccessChain(context, ptrArg))
+ if (const auto var = asPromotableVarAccessChain(context, ptrArg))
{
context->instsToRemove.add(ii);
}
diff --git a/source/slang/slang-ir-union.cpp b/source/slang/slang-ir-union.cpp
index caa646fb0..1eb4955e7 100644
--- a/source/slang/slang-ir-union.cpp
+++ b/source/slang/slang-ir-union.cpp
@@ -448,11 +448,11 @@ struct DesugarUnionTypesContext
}
return builder->emitMakeVector(vecType, elementVals);
}
- else if( auto matType = as<IRMatrixType>(payloadType) )
+ else if( const auto matType = as<IRMatrixType>(payloadType) )
{
SLANG_UNIMPLEMENTED_X("matrix in union type");
}
- else if( auto arrayType = as<IRArrayType>(payloadType) )
+ else if( const auto arrayType = as<IRArrayType>(payloadType) )
{
SLANG_UNIMPLEMENTED_X("array in union type");
}
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index eefcb9eea..78b62265b 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -1208,7 +1208,7 @@ namespace Slang
IRGlobalValueWithCode* IRInsertLoc::getFunc() const
{
auto pp = getParent();
- if (auto block = as<IRBlock>(pp))
+ if (const auto block = as<IRBlock>(pp))
{
pp = pp->getParent();
}
@@ -1710,7 +1710,9 @@ namespace Slang
Int const* listArgCounts,
IRInst* const* const* listArgs)
{
- m_dedupContext->getInstReplacementMap().tryGetValue((IRInst*)(type), *(IRInst**)&type);
+ IRInst* instReplacement = type;
+ m_dedupContext->getInstReplacementMap().tryGetValue(type, instReplacement);
+ type = (IRType*)instReplacement;
if (getIROpInfo(op).flags & kIROpFlag_Hoistable)
{
@@ -4699,7 +4701,7 @@ namespace Slang
{
type = getVectorType(matrixType->getElementType(), matrixType->getColumnCount());
}
- else if (auto basicType = as<IRBasicType>(basePtrType->getValueType()))
+ else if (const auto basicType = as<IRBasicType>(basePtrType->getValueType()))
{
// HLSL support things like float.x, in which case we just return the base pointer.
return basePtr;
@@ -6495,7 +6497,7 @@ namespace Slang
{
StringBuilder sb;
printSlangIRAssembly(sb, module, options, sourceManager);
- return sb;
+ return std::move(sb);
}
void dumpIR(IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager, ISlangWriter* writer)
diff --git a/source/slang/slang-ir.h b/source/slang/slang-ir.h
index 3dbd0c773..67f812134 100644
--- a/source/slang/slang-ir.h
+++ b/source/slang/slang-ir.h
@@ -2278,7 +2278,7 @@ R instMatch(IRInst* i, R def, F f, Fs... fs)
// Base case with no eliminators, return the default value
template<typename R>
-R instMatch(IRInst* i, R def)
+R instMatch(IRInst*, R def)
{
return def;
}
@@ -2309,7 +2309,7 @@ void instMatch_(IRInst* i, F f, Fs... fs)
}
template<typename... Fs>
-void instMatch_(IRInst* i)
+void instMatch_(IRInst*)
{
// Base case with no eliminators
}
diff --git a/source/slang/slang-language-server-ast-lookup.cpp b/source/slang/slang-language-server-ast-lookup.cpp
index 2f05dc1db..a9d7bf6d4 100644
--- a/source/slang/slang-language-server-ast-lookup.cpp
+++ b/source/slang/slang-language-server-ast-lookup.cpp
@@ -182,7 +182,7 @@ public:
if (expr->declRef.getDecl()->hasModifier<ImplicitConversionModifier>())
return false;
Int declLength = 0;
- if (auto ctorDecl = as<ConstructorDecl>(expr->declRef.getDecl()))
+ if (const auto ctorDecl = as<ConstructorDecl>(expr->declRef.getDecl()))
{
auto humaneLoc = context->sourceManager->getHumaneLoc(expr->loc, SourceLocType::Actual);
declLength = context->doc->getTokenLength(humaneLoc.line, humaneLoc.column);
@@ -658,7 +658,7 @@ bool _findAstNodeImpl(ASTLookupContext& context, SyntaxNode* node)
if (auto container = as<ContainerDecl>(node))
{
bool shouldInspectChildren = true;
- if (auto genericDecl = as<GenericDecl>(node))
+ if (const auto genericDecl = as<GenericDecl>(node))
{}
else if (container->closingSourceLoc.getRaw() >= container->loc.getRaw())
{
diff --git a/source/slang/slang-language-server-completion.cpp b/source/slang/slang-language-server-completion.cpp
index 337c77cc2..fc8331bce 100644
--- a/source/slang/slang-language-server-completion.cpp
+++ b/source/slang/slang-language-server-completion.cpp
@@ -658,7 +658,7 @@ LanguageServerProtocol::CompletionItem CompletionContext::generateGUIDCompletion
auto hashStr = String(docHash, 16);
sectionLengths[0] -= (int)hashStr.getLength();
sb << hashStr;
- for (int j = 0; j < SLANG_COUNT_OF(sectionLengths); j++)
+ for (Index j = 0; j < SLANG_COUNT_OF(sectionLengths); j++)
{
auto len = sectionLengths[j];
if (j != 0)
diff --git a/source/slang/slang-language-server-document-symbols.cpp b/source/slang/slang-language-server-document-symbols.cpp
index ae905caec..26366d6cf 100644
--- a/source/slang/slang-language-server-document-symbols.cpp
+++ b/source/slang/slang-language-server-document-symbols.cpp
@@ -180,7 +180,7 @@ namespace Slang
sym.range.end.line = (int)line;
sym.range.end.character = (int)col;
}
- if (auto childContainerDecl = as<ContainerDecl>(child))
+ if (const auto childContainerDecl = as<ContainerDecl>(child))
{
// Recurse
bool shouldRecurse = true;
diff --git a/source/slang/slang-language-server.cpp b/source/slang/slang-language-server.cpp
index 8b71d5bd3..a2cafa55a 100644
--- a/source/slang/slang-language-server.cpp
+++ b/source/slang/slang-language-server.cpp
@@ -524,7 +524,7 @@ SlangResult LanguageServer::hover(
{
if (auto declRefExpr = as<DeclRefExpr>(expr))
return fillDeclRefHoverInfo(declRefExpr->declRef);
- if (auto higherOrderExpr = as<HigherOrderInvokeExpr>(expr))
+ if (const auto higherOrderExpr = as<HigherOrderInvokeExpr>(expr))
{
String documentation;
String signature = getExprDeclSignature(expr, &documentation, nullptr);
@@ -1964,7 +1964,6 @@ SlangResult LanguageServer::execute()
{
// Consume all messages first.
commands.clear();
- auto start = platform::PerformanceCounter::now();
while (true)
{
m_connection->tryReadMessage();
@@ -1972,13 +1971,15 @@ SlangResult LanguageServer::execute()
break;
parseNextMessage();
}
- auto parseEnd = platform::PerformanceCounter::now();
+
+ auto workStart = platform::PerformanceCounter::now();
+
processCommands();
// Report diagnostics if it hasn't been updated for a while.
update();
- auto workTime = platform::PerformanceCounter::getElapsedTimeInSeconds(parseEnd);
+ auto workTime = platform::PerformanceCounter::getElapsedTimeInSeconds(workStart);
if (commands.getCount() > 0 && m_initialized && m_traceOptions != TraceOptions::Off)
{
diff --git a/source/slang/slang-legalize-types.cpp b/source/slang/slang-legalize-types.cpp
index 57735d459..c6d76205f 100644
--- a/source/slang/slang-legalize-types.cpp
+++ b/source/slang/slang-legalize-types.cpp
@@ -172,23 +172,23 @@ bool isResourceType(IRType* type)
type = arrayType->getElementType();
}
- if (auto resourceTypeBase = as<IRResourceTypeBase>(type))
+ if (const auto resourceTypeBase = as<IRResourceTypeBase>(type))
{
return true;
}
- else if (auto builtinGenericType = as<IRBuiltinGenericType>(type))
+ else if (const auto builtinGenericType = as<IRBuiltinGenericType>(type))
{
return true;
}
- else if (auto pointerLikeType = as<IRPointerLikeType>(type))
+ else if (const auto pointerLikeType = as<IRPointerLikeType>(type))
{
return true;
}
- else if (auto samplerType = as<IRSamplerStateTypeBase>(type))
+ else if (const auto samplerType = as<IRSamplerStateTypeBase>(type))
{
return true;
}
- else if(auto untypedBufferType = as<IRUntypedBufferResourceType>(type))
+ else if(const auto untypedBufferType = as<IRUntypedBufferResourceType>(type))
{
return true;
}
@@ -1480,7 +1480,7 @@ IRVarLayout* createVarLayout(
IRVarLayout::Builder varLayoutBuilder(irBuilder, typeLayout);
buildSimpleVarLayout(&varLayoutBuilder, varChain.primaryChain, typeLayout);
- if(auto pendingDataTypeLayout = typeLayout->getPendingDataTypeLayout())
+ if(const auto pendingDataTypeLayout = typeLayout->getPendingDataTypeLayout())
{
varLayoutBuilder.setPendingVarLayout(
createSimpleVarLayout(irBuilder, varChain.pendingChain, typeLayout));
diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp
index 9ac5fc940..484797344 100644
--- a/source/slang/slang-lookup.cpp
+++ b/source/slang/slang-lookup.cpp
@@ -45,21 +45,21 @@ bool DeclPassesLookupMask(Decl* decl, LookupMask mask)
}
}
// type declarations
- if(auto aggTypeDecl = as<AggTypeDecl>(decl))
+ if(const auto aggTypeDecl = as<AggTypeDecl>(decl))
{
return int(mask) & int(LookupMask::type);
}
- else if(auto simpleTypeDecl = as<SimpleTypeDecl>(decl))
+ else if(const auto simpleTypeDecl = as<SimpleTypeDecl>(decl))
{
return int(mask) & int(LookupMask::type);
}
// function declarations
- else if(auto funcDecl = as<FunctionDeclBase>(decl))
+ else if(const auto funcDecl = as<FunctionDeclBase>(decl))
{
return (int(mask) & int(LookupMask::Function)) != 0;
}
// attribute declaration
- else if( auto attrDecl = as<AttributeDecl>(decl) )
+ else if( const auto attrDecl = as<AttributeDecl>(decl) )
{
return (int(mask) & int(LookupMask::Attribute)) != 0;
}
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index c8a41c7c7..14ed8ea54 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -858,6 +858,7 @@ static LoweredValInfo _emitCallToAccessor(
/// encapsulates the reference to the storage so that downstream
/// code can decide which accessor(s) to invoke.
///
+
static LoweredValInfo lowerStorageReference(
IRGenContext* context,
IRType* type,
@@ -1305,22 +1306,22 @@ static void addLinkageDecoration(
bool shouldDeclBeTreatedAsInterfaceRequirement(Decl* requirementDecl)
{
- if (auto funcDecl = as<CallableDecl>(requirementDecl))
+ if (const auto funcDecl = as<CallableDecl>(requirementDecl))
{
}
- else if (auto propertyDecl = as<PropertyDecl>(requirementDecl))
+ else if (const auto propertyDecl = as<PropertyDecl>(requirementDecl))
{
}
- else if (auto assocTypeDecl = as<AssocTypeDecl>(requirementDecl))
+ else if (const auto assocTypeDecl = as<AssocTypeDecl>(requirementDecl))
{
}
- else if (auto typeConstraint = as<TypeConstraintDecl>(requirementDecl))
+ else if (const auto typeConstraint = as<TypeConstraintDecl>(requirementDecl))
{
}
- else if (auto varDecl = as<VarDeclBase>(requirementDecl))
+ else if (const auto varDecl = as<VarDeclBase>(requirementDecl))
{
}
- else if (auto genericDecl = as<GenericDecl>(requirementDecl))
+ else if (const auto genericDecl = as<GenericDecl>(requirementDecl))
{
return shouldDeclBeTreatedAsInterfaceRequirement(genericDecl->inner);
}
@@ -2382,7 +2383,7 @@ static String getNameForNameHint(
return String();
- if(auto varDecl = as<VarDeclBase>(decl))
+ if(const auto varDecl = as<VarDeclBase>(decl))
{
// For an ordinary local variable, global variable,
// parameter, or field, we will just use the name
@@ -3341,7 +3342,6 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
LoweredValInfo visitGetArrayLengthExpr(GetArrayLengthExpr* expr)
{
- auto baseVal = lowerSubExpr(expr->arrayExpr);
auto type = lowerType(context, expr->arrayExpr->type);
auto arrayType = as<IRArrayType>(type);
SLANG_ASSERT(arrayType);
@@ -3979,7 +3979,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
void addFuncBaseArgs(
LoweredValInfo funcVal,
- List<IRInst*>* ioArgs)
+ List<IRInst*>* /*ioArgs*/)
{
switch (funcVal.flavor)
{
@@ -4518,7 +4518,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
UNREACHABLE_RETURN(LoweredValInfo());
}
- LoweredValInfo visitAssocTypeDecl(AssocTypeDecl* decl)
+ LoweredValInfo visitAssocTypeDecl(AssocTypeDecl* /*decl*/)
{
SLANG_UNIMPLEMENTED_X("associatedtype expression during code generation");
UNREACHABLE_RETURN(LoweredValInfo());
@@ -5146,7 +5146,7 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor>
// Now that we are within the header block, we
// want to emit the expression for the loop condition:
- if (auto condExpr = stmt->predicateExpression)
+ if (const auto condExpr = stmt->predicateExpression)
{
auto irCondition = getSimpleVal(context,
lowerRValueExpr(context, stmt->predicateExpression));
@@ -5587,11 +5587,11 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor>
}
}
}
- else if (auto caseStmt = as<CaseStmt>(stmt))
+ else if (const auto caseStmt = as<CaseStmt>(stmt))
{
return true;
}
- else if (auto defaultStmt = as<DefaultStmt>(stmt))
+ else if (const auto defaultStmt = as<DefaultStmt>(stmt))
{
// A 'default:' is a kind of case.
return true;
@@ -5662,7 +5662,7 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor>
info->cases.add(caseVal);
info->cases.add(label);
}
- else if(auto defaultStmt = as<DefaultStmt>(stmt))
+ else if(const auto defaultStmt = as<DefaultStmt>(stmt))
{
auto label = getLabelForCase(info);
@@ -5671,7 +5671,7 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor>
info->defaultLabel = label;
}
- else if(auto emptyStmt = as<EmptyStmt>(stmt))
+ else if(const auto emptyStmt = as<EmptyStmt>(stmt))
{
// Special-case empty statements so they don't
// mess up our "trivial fall-through" optimization.
@@ -6483,7 +6483,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// generic associated types.
- if(auto interfaceDecl = as<InterfaceDecl>(assocTypeDecl->parentDecl))
+ if(const auto interfaceDecl = as<InterfaceDecl>(assocTypeDecl->parentDecl))
{
// Okay, this seems to be an interface rquirement, and
// we should lower it as such.
@@ -6491,7 +6491,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
}
}
- if(auto globalGenericParamDecl = as<GlobalGenericParamDecl>(decl->parentDecl))
+ if(const auto globalGenericParamDecl = as<GlobalGenericParamDecl>(decl->parentDecl))
{
// This is a constraint on a global generic type parameters,
// and so it should lower as a parameter of its own.
@@ -6631,7 +6631,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// interface requires, and not what it provides.
//
auto parentDecl = inheritanceDecl->parentDecl;
- if (auto parentInterfaceDecl = as<InterfaceDecl>(parentDecl))
+ if (const auto parentInterfaceDecl = as<InterfaceDecl>(parentDecl))
{
return LoweredValInfo::simple(getInterfaceRequirementKey(inheritanceDecl));
}
@@ -6842,7 +6842,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
}
if (auto extDecl = as<ExtensionDecl>(parent))
{
- if (auto declRefType = as<DeclRefType>(extDecl->targetType.type))
+ if (const auto declRefType = as<DeclRefType>(extDecl->targetType.type))
{
return true;
}
@@ -7457,7 +7457,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
subBuilder->addAnyValueSizeDecoration(irInterface, anyValueSizeAttr->size);
}
- if (auto specializeAttr = decl->findModifier<SpecializeAttribute>())
+ if (const auto specializeAttr = decl->findModifier<SpecializeAttribute>())
{
subBuilder->addSpecializeDecoration(irInterface);
}
@@ -7465,7 +7465,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
subBuilder->addComInterfaceDecoration(irInterface, comInterfaceAttr->guid.getUnownedSlice());
}
- if (auto builtinAttr = decl->findModifier<BuiltinAttribute>())
+ if (const auto builtinAttr = decl->findModifier<BuiltinAttribute>())
{
subBuilder->addBuiltinDecoration(irInterface);
}
@@ -7587,7 +7587,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
addNameHint(context, irAggType, decl);
addLinkageDecoration(context, irAggType, decl);
- if( auto payloadAttribute = decl->findModifier<PayloadAttribute>() )
+ if( const auto payloadAttribute = decl->findModifier<PayloadAttribute>() )
{
subBuilder->addDecoration(irAggType, kIROp_PayloadDecoration);
}
@@ -8199,7 +8199,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
builder->addTargetIntrinsicDecoration(irInst, targetCaps, definition.getUnownedSlice());
}
- if(auto nvapiMod = decl->findModifier<NVAPIMagicModifier>())
+ if(const auto nvapiMod = decl->findModifier<NVAPIMagicModifier>())
{
builder->addNVAPIMagicDecoration(irInst, decl->getName()->text.getUnownedSlice());
}
@@ -8318,7 +8318,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// have a name, but its parent should.
//
Decl* declForName = decl;
- if(auto accessorDecl = as<AccessorDecl>(decl))
+ if(const auto accessorDecl = as<AccessorDecl>(decl))
declForName = decl->parentDecl;
definition.append(getText(declForName->getName()));
diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp
index 77e6586ff..a8ab98254 100644
--- a/source/slang/slang-mangle.cpp
+++ b/source/slang/slang-mangle.cpp
@@ -234,7 +234,7 @@ namespace Slang
emitRaw(context, "t");
emitQualifiedName(context, thisType->interfaceDeclRef);
}
- else if (auto errorType = dynamicCast<ErrorType>(type))
+ else if (const auto errorType = dynamicCast<ErrorType>(type))
{
emitRaw(context, "E");
}
@@ -252,7 +252,7 @@ namespace Slang
{
emitType(context, type);
}
- else if( auto witness = dynamicCast<Witness>(val) )
+ else if( const auto witness = dynamicCast<Witness>(val) )
{
// We don't emit witnesses as part of a mangled
// name, because the way that the front-end
@@ -301,7 +301,7 @@ namespace Slang
emitVal(context, lookupIntVal->witness);
emitName(context, lookupIntVal->key->getName());
}
- else if (auto polynomialIntVal = dynamicCast<PolynomialIntVal>(val))
+ else if (const auto polynomialIntVal = dynamicCast<PolynomialIntVal>(val))
{
emitRaw(context, "KX");
}
@@ -634,7 +634,7 @@ namespace Slang
builder << "_Sh";
builder.append(uint64_t(hash), 16);
- return builder;
+ return std::move(builder);
}
}
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 0860ef4f2..8817095df 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -231,7 +231,7 @@ struct OptionsParser
{ ".comp", Profile::GLSL_Compute }
};
- for (int i = 0; i < SLANG_COUNT_OF(entries); ++i)
+ for (Index i = 0; i < SLANG_COUNT_OF(entries); ++i)
{
const Entry& entry = entries[i];
if (path.endsWith(entry.ext))
@@ -274,7 +274,7 @@ struct OptionsParser
};
- for (int i = 0; i < SLANG_COUNT_OF(entries); ++i)
+ for (Index i = 0; i < SLANG_COUNT_OF(entries); ++i)
{
const Entry& entry = entries[i];
if (path.endsWith(entry.ext))
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index 1edd87d3a..bd33b6f37 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -1089,8 +1089,7 @@ void generateParameterBindings(
static void completeBindingsForParameterImpl(
ParameterBindingContext* context,
RefPtr<VarLayout> firstVarLayout,
- ParameterBindingInfo bindingInfos[kLayoutResourceKindCount],
- RefPtr<ParameterInfo> parameterInfo)
+ ParameterBindingInfo bindingInfos[kLayoutResourceKindCount])
{
// For any resource kind used by the parameter
// we need to update its layout information
@@ -1316,8 +1315,7 @@ static void completeBindingsForParameter(
completeBindingsForParameterImpl(
context,
varLayout,
- parameterInfo->bindingInfo,
- parameterInfo);
+ parameterInfo->bindingInfo);
// At this point we should have explicit binding locations chosen for
// all the relevant resource kinds, so we can apply these to the
@@ -1334,8 +1332,7 @@ static void completeBindingsForParameter(
completeBindingsForParameterImpl(
context,
varLayout,
- bindingInfos,
- nullptr);
+ bindingInfos);
applyBindingInfoToParameter(varLayout, bindingInfos);
}
@@ -1942,9 +1939,9 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter(
return arrayTypeLayout;
}
// Ignore a bunch of types that don't make sense here...
- else if (auto textureType = as<TextureType>(type)) { return nullptr; }
- else if(auto samplerStateType = as<SamplerStateType>(type)) { return nullptr; }
- else if(auto constantBufferType = as<ConstantBufferType>(type)) { return nullptr; }
+ else if (const auto textureType = as<TextureType>(type)) { return nullptr; }
+ else if(const auto samplerStateType = as<SamplerStateType>(type)) { return nullptr; }
+ else if(const auto constantBufferType = as<ConstantBufferType>(type)) { return nullptr; }
// Catch declaration-reference types late in the sequence, since
// otherwise they will include all of the above cases...
else if( auto declRefType = as<DeclRefType>(type) )
@@ -2085,7 +2082,7 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter(
}
}
// If we ran into an error in checking the user's code, then skip this parameter
- else if( auto errorType = as<ErrorType>(type) )
+ else if( const auto errorType = as<ErrorType>(type) )
{
return nullptr;
}
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 256d7aae1..88cc6fac2 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -1094,8 +1094,6 @@ namespace Slang
Modifier** modifierLink = &modifiers.first;
for (;;)
{
- SourceLoc loc = parser->tokenReader.peekLoc();
-
switch (peekTokenType(parser))
{
default:
@@ -5433,7 +5431,7 @@ namespace Slang
// The reason for the restriction (which perhaps can be broadened), is we don't
// want the interpretation of something in parentheses to be determined by something as common as + or - whitespace.
- if (auto staticMemberExpr = dynamicCast<StaticMemberExpr>(expr))
+ if (const auto staticMemberExpr = dynamicCast<StaticMemberExpr>(expr))
{
// Apply the heuristic:
TokenReader::ParsingCursor cursor = parser->tokenReader.getCursor();
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp
index 28abaaf76..6e7ae7cfb 100644
--- a/source/slang/slang-preprocessor.cpp
+++ b/source/slang/slang-preprocessor.cpp
@@ -3342,7 +3342,6 @@ static void HandleDefineDirective(PreprocessorDirectiveContext* context)
macro->flavor = MacroDefinition::Flavor::ObjectLike;
}
- auto nameLoc = NameLoc(nameToken);
macro->nameAndLoc = NameLoc(nameToken);
context->m_preprocessor->globalEnv.macros[name] = macro;
@@ -3418,7 +3417,7 @@ static String _readDirectiveMessage(PreprocessorDirectiveContext* context)
result.append(token.getContent());
}
- return result;
+ return std::move(result);
}
// Handle a `#warning` directive
@@ -3500,7 +3499,7 @@ static void HandleLineDirective(PreprocessorDirectiveContext* context)
_handleDefaultLineDirective(context);
return;
}
- /* else, fall through to: */
+ [[fallthrough]];
default:
_diagnoseInvalidLineDirective(context);
return;
diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp
index e3e9de2cd..5d35c7eef 100644
--- a/source/slang/slang-reflection-api.cpp
+++ b/source/slang/slang-reflection-api.cpp
@@ -90,6 +90,7 @@ static inline ProgramLayout* convert(SlangReflection* program)
return (ProgramLayout*) program;
}
+[[maybe_unused]]
static inline SlangReflection* convert(ProgramLayout* program)
{
return (SlangReflection*) program;
@@ -311,27 +312,27 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType)
// TODO(tfoley: Don't emit the same type more than once...
- if (auto basicType = as<BasicExpressionType>(type))
+ if (const auto basicType = as<BasicExpressionType>(type))
{
return SLANG_TYPE_KIND_SCALAR;
}
- else if (auto vectorType = as<VectorExpressionType>(type))
+ else if (const auto vectorType = as<VectorExpressionType>(type))
{
return SLANG_TYPE_KIND_VECTOR;
}
- else if (auto matrixType = as<MatrixExpressionType>(type))
+ else if (const auto matrixType = as<MatrixExpressionType>(type))
{
return SLANG_TYPE_KIND_MATRIX;
}
- else if (auto parameterBlockType = as<ParameterBlockType>(type))
+ else if (const auto parameterBlockType = as<ParameterBlockType>(type))
{
return SLANG_TYPE_KIND_PARAMETER_BLOCK;
}
- else if (auto constantBufferType = as<ConstantBufferType>(type))
+ else if (const auto constantBufferType = as<ConstantBufferType>(type))
{
return SLANG_TYPE_KIND_CONSTANT_BUFFER;
}
- else if( auto streamOutputType = as<HLSLStreamOutputType>(type) )
+ else if( const auto streamOutputType = as<HLSLStreamOutputType>(type) )
{
return SLANG_TYPE_KIND_OUTPUT_STREAM;
}
@@ -347,15 +348,15 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType)
{
return SLANG_TYPE_KIND_SHADER_STORAGE_BUFFER;
}
- else if (auto samplerStateType = as<SamplerStateType>(type))
+ else if (const auto samplerStateType = as<SamplerStateType>(type))
{
return SLANG_TYPE_KIND_SAMPLER_STATE;
}
- else if (auto textureType = as<TextureTypeBase>(type))
+ else if (const auto textureType = as<TextureTypeBase>(type))
{
return SLANG_TYPE_KIND_RESOURCE;
}
- else if (auto feedbackType = as<FeedbackType>(type))
+ else if (const auto feedbackType = as<FeedbackType>(type))
{
return SLANG_TYPE_KIND_FEEDBACK;
}
@@ -376,7 +377,7 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType)
CASE(UntypedBufferResourceType);
#undef CASE
- else if (auto arrayType = as<ArrayExpressionType>(type))
+ else if (const auto arrayType = as<ArrayExpressionType>(type))
{
return SLANG_TYPE_KIND_ARRAY;
}
@@ -401,11 +402,11 @@ SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType)
return SLANG_TYPE_KIND_STRUCT;
}
}
- else if( auto specializedType = as<ExistentialSpecializedType>(type) )
+ else if( const auto specializedType = as<ExistentialSpecializedType>(type) )
{
return SLANG_TYPE_KIND_SPECIALIZED;
}
- else if (auto errorType = as<ErrorType>(type))
+ else if (const auto errorType = as<ErrorType>(type))
{
// This means we saw a type we didn't understand in the user's code
return SLANG_TYPE_KIND_NONE;
@@ -510,11 +511,11 @@ SLANG_API unsigned int spReflectionType_GetRowCount(SlangReflectionType* inType)
{
return (unsigned int) getIntVal(matrixType->getRowCount());
}
- else if(auto vectorType = as<VectorExpressionType>(type))
+ else if(const auto vectorType = as<VectorExpressionType>(type))
{
return 1;
}
- else if( auto basicType = as<BasicExpressionType>(type) )
+ else if( const auto basicType = as<BasicExpressionType>(type) )
{
return 1;
}
@@ -535,7 +536,7 @@ SLANG_API unsigned int spReflectionType_GetColumnCount(SlangReflectionType* inTy
{
return (unsigned int) getIntVal(vectorType->elementCount);
}
- else if( auto basicType = as<BasicExpressionType>(type) )
+ else if( const auto basicType = as<BasicExpressionType>(type) )
{
return 1;
}
@@ -1238,7 +1239,7 @@ namespace Slang
SlangBindingType _calcResourceBindingType(
Type* type)
{
- if(auto combinedTextureSamplerType = as<TextureSamplerType>(type))
+ if(const auto combinedTextureSamplerType = as<TextureSamplerType>(type))
{
return SLANG_BINDING_TYPE_COMBINED_TEXTURE_SAMPLER;
}
@@ -1260,7 +1261,7 @@ namespace Slang
return SlangBindingType(SLANG_BINDING_TYPE_TYPED_BUFFER | mutableFlag);
}
}
- else if( auto structuredBufferType = as<HLSLStructuredBufferTypeBase>(type) )
+ else if( const auto structuredBufferType = as<HLSLStructuredBufferTypeBase>(type) )
{
if( as<HLSLStructuredBufferType>(type) )
{
@@ -1275,7 +1276,7 @@ namespace Slang
{
return SLANG_BINDING_TYPE_RAY_TRACING_ACCELERATION_STRUCTURE;
}
- else if( auto untypedBufferType = as<UntypedBufferResourceType>(type) )
+ else if( const auto untypedBufferType = as<UntypedBufferResourceType>(type) )
{
if( as<HLSLByteAddressBufferType>(type) )
{
@@ -1928,7 +1929,7 @@ namespace Slang
m_extendedInfo->m_bindingRanges.add(bindingRange);
// For `StructuredBuffer` fields, we also make sure to report it as a sub-object range.
- if (auto structuredBufferTypeLayout = as<StructuredBufferTypeLayout>(typeLayout))
+ if (const auto structuredBufferTypeLayout = as<StructuredBufferTypeLayout>(typeLayout))
{
TypeLayout::ExtendedInfo::SubObjectRangeInfo subObjectRange;
subObjectRange.bindingRangeIndex = bindingRangeIndex;
diff --git a/source/slang/slang-serialize-container.cpp b/source/slang/slang-serialize-container.cpp
index 8d10235f0..c75237896 100644
--- a/source/slang/slang-serialize-container.cpp
+++ b/source/slang/slang-serialize-container.cpp
@@ -601,17 +601,6 @@ static List<ExtensionDecl*>& _getCandidateExtensionList(
{
auto reader = entryPointChunk->asReadHelper();
- auto readString = [&]()
- {
- uint32_t length = 0;
- reader.read(length);
-
- char* begin = (char*)reader.getData();
- reader.skip(length + 1);
-
- return UnownedStringSlice(begin, begin + length);
- };
-
SerialContainerBinary::EntryPoint srcEntryPoint;
SLANG_RETURN_ON_FAIL(reader.read(srcEntryPoint));
diff --git a/source/slang/slang-serialize-ir.cpp b/source/slang/slang-serialize-ir.cpp
index 2da923c43..d84049b74 100644
--- a/source/slang/slang-serialize-ir.cpp
+++ b/source/slang/slang-serialize-ir.cpp
@@ -323,7 +323,6 @@ Result IRSerialWriter::write(IRModule* module, SerialSourceLocWriter* sourceLocW
Result _encodeInsts(SerialCompressionType compressionType, const List<IRSerialData::Inst>& instsIn, List<uint8_t>& encodeArrayOut)
{
- typedef IRSerialBinary Bin;
typedef IRSerialData::Inst::PayloadType PayloadType;
if (compressionType != SerialCompressionType::VariableByteLite)
@@ -417,7 +416,6 @@ Result _writeInstArrayChunk(SerialCompressionType compressionType, FourCC chunkI
typedef RiffContainer::Chunk Chunk;
typedef RiffContainer::ScopeChunk ScopeChunk;
- typedef IRSerialBinary Bin;
if (array.getCount() == 0)
{
return SLANG_OK;
@@ -509,7 +507,6 @@ static Result _decodeInsts(SerialCompressionType compressionType, const uint8_t*
{
const uint8_t* encodeEnd = encodeCur + encodeInSize;
- typedef IRSerialBinary Bin;
typedef IRSerialData::Inst::PayloadType PayloadType;
if (compressionType != SerialCompressionType::VariableByteLite)
@@ -678,7 +675,8 @@ static Result _readInstArrayChunk(SerialCompressionType containerCompressionType
Result IRSerialReader::read(const IRSerialData& data, Session* session, SerialSourceLocReader* sourceLocReader, RefPtr<IRModule>& outModule)
{
- typedef Ser::Inst::PayloadType PayloadType;
+ // Only used in debug builds
+ [[maybe_unused]] typedef Ser::Inst::PayloadType PayloadType;
m_serialData = &data;
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index 9587c3c6c..11729800c 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -1277,7 +1277,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt
{
StringBuilder builder;
toText(builder);
- return builder;
+ return std::move(builder);
}
// Prints a partially qualified type name with generic substitutions.
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 90ab89ab1..0f1341afd 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -1471,7 +1471,7 @@ static LayoutSize GetElementCount(IntVal* val)
return LayoutSize::infinite();
return LayoutSize(LayoutSize::RawValue(constantVal->value));
}
- else if( auto varRefVal = as<GenericParamIntVal>(val) )
+ else if(const auto varRefVal = as<GenericParamIntVal>(val))
{
// TODO: We want to treat the case where the number of
// elements in an array depends on a generic parameter
@@ -1483,7 +1483,7 @@ static LayoutSize GetElementCount(IntVal* val)
//
return 0;
}
- else if (auto polyIntVal = as<PolynomialIntVal>(val))
+ else if (const auto polyIntVal = as<PolynomialIntVal>(val))
{
// TODO: We want to treat the case where the number of
// elements in an array depends on a generic parameter
@@ -1734,7 +1734,7 @@ RefPtr<TypeLayout> applyOffsetToTypeLayout(
bool anyHit = false;
for (auto oldResInfo : oldTypeLayout->resourceInfos)
{
- if (auto offsetResInfo = offsetVarLayout->FindResourceInfo(oldResInfo.kind))
+ if (const auto offsetResInfo = offsetVarLayout->FindResourceInfo(oldResInfo.kind))
{
anyHit = true;
break;
@@ -1746,7 +1746,7 @@ RefPtr<TypeLayout> applyOffsetToTypeLayout(
{
for (auto oldResInfo : oldPendingTypeLayout->resourceInfos)
{
- if (auto offsetResInfo = pendingOffsetVarLayout->FindResourceInfo(oldResInfo.kind))
+ if (const auto offsetResInfo = pendingOffsetVarLayout->FindResourceInfo(oldResInfo.kind))
{
anyHit = true;
break;
@@ -1878,7 +1878,7 @@ IRTypeLayout* applyOffsetToTypeLayout(
bool anyHit = false;
for (auto oldResInfo : oldTypeLayout->getSizeAttrs())
{
- if (auto offsetResInfo = offsetVarLayout->findOffsetAttr(oldResInfo->getResourceKind()))
+ if (const auto offsetResInfo = offsetVarLayout->findOffsetAttr(oldResInfo->getResourceKind()))
{
anyHit = true;
break;
@@ -3439,7 +3439,7 @@ static TypeLayoutResult _createTypeLayout(
return TypeLayoutResult(typeLayout, info);
}
- else if (auto samplerStateType = as<SamplerStateType>(type))
+ else if (const auto samplerStateType = as<SamplerStateType>(type))
{
return createSimpleTypeLayout(
rules->GetObjectLayout(ShaderParameterKind::SamplerState),
@@ -4023,7 +4023,7 @@ static TypeLayoutResult _createTypeLayout(
return createSimpleTypeLayout(
SimpleLayoutInfo(),
- type,
+ errorType,
rules);
}
else if( auto taggedUnionType = as<TaggedUnionType>(type) )
diff --git a/source/slang/slang-workspace-version.cpp b/source/slang/slang-workspace-version.cpp
index dde5b9325..2ac079047 100644
--- a/source/slang/slang-workspace-version.cpp
+++ b/source/slang/slang-workspace-version.cpp
@@ -429,7 +429,6 @@ void DocumentVersion::oneBasedUTF8LocToZeroBasedUTF16Loc(
}
Index rsLine = inLine - 1;
- auto line = lines[rsLine];
auto bounds = getUTF16Boundaries(inLine);
outLine = rsLine;
outCol = std::lower_bound(bounds.begin(), bounds.end(), inCol - 1) - bounds.begin();
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index ac8e0269d..1dc61b937 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -752,7 +752,7 @@ SlangPassThrough Session::getDownstreamCompilerForTransition(SlangCompileTarget
(source == CodeGenTarget::CSource || source == CodeGenTarget::CPPSource))
{
// We prefer LLVM if it's available
- if (auto llvm = getOrLoadDownstreamCompiler(PassThroughMode::LLVM, nullptr))
+ if (const auto llvm = getOrLoadDownstreamCompiler(PassThroughMode::LLVM, nullptr))
{
return SLANG_PASS_THROUGH_LLVM;
}