summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-24 15:51:43 -0700
committerGitHub <noreply@github.com>2024-04-24 15:51:43 -0700
commitfc4c242442510fb97c3cfbf04d7582ebbc3bb0ed (patch)
tree0c19f6974dad99cbe1faa24b1aba41d0780008da /source
parent211b2ffc20d7798cab0b8483ccc3ec2b7ade49ab (diff)
Fix macos CI and clang warnings. (#4019)
* Fix macos CI. * Fix. * Fix. * Fix. * Fix clang warnings. * Fix more warnings.
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-perfect-hash.cpp6
-rw-r--r--source/slang/glsl.meta.slang1
-rw-r--r--source/slang/slang-emit-metal.cpp1
-rw-r--r--source/slang/slang-emit-source-writer.cpp16
-rw-r--r--source/slang/slang-ir-glsl-legalize.cpp4
-rw-r--r--source/slang/slang-parser.cpp2
6 files changed, 12 insertions, 18 deletions
diff --git a/source/compiler-core/slang-perfect-hash.cpp b/source/compiler-core/slang-perfect-hash.cpp
index d5c4902ed..a741f013c 100644
--- a/source/compiler-core/slang-perfect-hash.cpp
+++ b/source/compiler-core/slang-perfect-hash.cpp
@@ -146,7 +146,7 @@ String perfectHashToEmbeddableCpp(
w.print("bool %s(const UnownedStringSlice& str, %s& value)\n", String(funcName).getBuffer(), String(valueType).getBuffer());
line("{");
- w.print(" static const unsigned tableSalt[%ld] = {\n", hashParams.saltTable.getCount());
+ w.print(" static const unsigned tableSalt[%d] = {\n", (int)hashParams.saltTable.getCount());
w.print(" ");
for (Index i = 0; i < hashParams.saltTable.getCount(); ++i)
{
@@ -170,7 +170,7 @@ String perfectHashToEmbeddableCpp(
w.print(" using KV = std::pair<const char*, %s>;\n", String(valueType).getBuffer());
line("");
- w.print(" static const KV words[%ld] =\n", hashParams.destTable.getCount());
+ w.print(" static const KV words[%d] =\n", (int)hashParams.destTable.getCount());
line(" {");
for (Index i = 0; i < hashParams.destTable.getCount(); ++i)
{
@@ -191,7 +191,7 @@ String perfectHashToEmbeddableCpp(
line(" UInt32 h = salt;");
line(" for (const char c : str)");
line(" h = (h * 0x01000193) ^ c;");
- w.print(" return h %% %ld;\n", hashParams.saltTable.getCount());
+ w.print(" return h %% %d;\n", (int)hashParams.saltTable.getCount());
line(" };");
line("");
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang
index d04dfe8b9..79f5bfdb8 100644
--- a/source/slang/glsl.meta.slang
+++ b/source/slang/glsl.meta.slang
@@ -3236,7 +3236,6 @@ ${{{{
StringBuilder SPV_DEFAULT_SAMPLE_VAR_IF_MISSINGBuilder;
SPV_PREFIX_IMAGE_PARAMSBuilder << "$image $P";
- SPV_SUFFIX_IMAGE_PARAMSBuilder;
if (targetShape.isMS)
{
SPV_SUFFIX_IMAGE_PARAMSBuilder << " Sample $sample";
diff --git a/source/slang/slang-emit-metal.cpp b/source/slang/slang-emit-metal.cpp
index bf4a67b09..459104ac9 100644
--- a/source/slang/slang-emit-metal.cpp
+++ b/source/slang/slang-emit-metal.cpp
@@ -160,7 +160,6 @@ void MetalSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUnifor
void MetalSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor)
{
- auto profile = m_effectiveProfile;
auto stage = entryPointDecor->getProfile().getStage();
switch (stage)
diff --git a/source/slang/slang-emit-source-writer.cpp b/source/slang/slang-emit-source-writer.cpp
index d8364d5c3..ddce0ab89 100644
--- a/source/slang/slang-emit-source-writer.cpp
+++ b/source/slang/slang-emit-source-writer.cpp
@@ -3,10 +3,6 @@
#include "../core/slang-char-encode.h"
-// Disable warnings about sprintf
-#ifdef _WIN32
-# pragma warning(disable:4996)
-#endif
// Note: using C++ stdio just to get a locale-independent
// way to format floating-point values.
@@ -199,28 +195,28 @@ void SourceWriter::emitInt64(int64_t value)
void SourceWriter::emit(Int32 value)
{
char buffer[16];
- sprintf(buffer, "%" PRId32, value);
+ snprintf(buffer, sizeof(buffer), "%" PRId32, value);
emit(buffer);
}
void SourceWriter::emit(Int64 value)
{
char buffer[32];
- sprintf(buffer, "%" PRId64, value);
+ snprintf(buffer, sizeof(buffer), "%" PRId64, value);
emit(buffer);
}
void SourceWriter::emit(UInt32 value)
{
char buffer[32];
- sprintf(buffer, "%" PRIu32, value);
+ snprintf(buffer, sizeof(buffer), "%" PRIu32, value);
emit(buffer);
}
void SourceWriter::emit(UInt64 value)
{
char buffer[32];
- sprintf(buffer, "%" PRIu64, value);
+ snprintf(buffer, sizeof(buffer), "%" PRIu64, value);
emit(buffer);
}
@@ -463,7 +459,7 @@ void SourceWriter::_emitLineDirective(const HumaneSourceLoc& sourceLocation)
emitRawText("\n#line ");
char buffer[16];
- sprintf(buffer, "%llu", (unsigned long long)sourceLocation.line);
+ snprintf(buffer, sizeof(buffer), "%llu", (unsigned long long)sourceLocation.line);
emitRawText(buffer);
// Only emit the path part of a `#line` directive if needed
@@ -497,7 +493,7 @@ void SourceWriter::_emitLineDirective(const HumaneSourceLoc& sourceLocation)
m_mapGLSLSourcePathToID.add(path, id);
}
- sprintf(buffer, "%d", id);
+ snprintf(buffer, sizeof(buffer), "%d", id);
emitRawText(buffer);
break;
}
diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp
index b741e7ffa..54af7a746 100644
--- a/source/slang/slang-ir-glsl-legalize.cpp
+++ b/source/slang/slang-ir-glsl-legalize.cpp
@@ -2795,7 +2795,7 @@ void getAllNullLocationRayObjectsAndUsedLocations(
for (auto inst : module->getGlobalInsts())
{
auto instOp = inst->getOp();
- IRIntegerValue intLitVal = NULL;
+ IRIntegerValue intLitVal = 0;
if (instOp != kIROp_GlobalParam && instOp != kIROp_GlobalVar) continue;
for (auto decor : inst->getDecorations())
{
@@ -2839,7 +2839,7 @@ void assignRayPayloadHitObjectAttributeLocations(IRModule* module)
for (auto inst : nullRayObjects)
{
IRInst* location = nullptr;
- IRIntegerValue intLitVal = NULL;
+ IRIntegerValue intLitVal = 0;
for (auto decor : inst->getDecorations())
{
switch (decor->getOp())
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 9e0a94cae..e0b964a45 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -5453,7 +5453,7 @@ namespace Slang
bool lookAheadTokenAfterModifiers(Parser* parser, const char* token)
{
TokenReader tokenPreview = parser->tokenReader;
- for (Index i = 0;; i++)
+ for (;;)
{
if (tokenPreview.peekToken().getContent() == token)
return true;