Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ function(set_default_compile_options target)
-Wno-invalid-offsetof
-Wno-newline-eof
-Wno-return-std-move
# Allow unused variables with a pattern of `if (auto v = as<...>(...))`.
# This pattern is very common in Slang code base.
-Wno-unused-but-set-variable
# Allowed warnings:
# If a function returns an address/reference to a local, we want it to
# produce an error, because it probably means something very bad.
-Werror=return-local-addr
# Allow unused variables with a pattern of `if (auto v = as<...>(...))`.
# This pattern is very common in Slang code base.
-Wno-error=unused-but-set-variable
# Some warnings which are on by default in MSVC
-Wnarrowing
)
Expand All @@ -135,7 +135,6 @@ function(set_default_compile_options target)
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-value
-Wno-unused-but-set-variable
-Wno-implicit-fallthrough
-Wno-missing-field-initializers
-Wno-strict-aliasing
Expand Down
2 changes: 1 addition & 1 deletion examples/mlp-training-coopvec/mlp-training-coopvec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ struct ExampleProgram : public TestBase
std::vector<float> inputBufferData;
for (int i = 0; i < inputCount; i++)
{
inputBufferData.push_back((float)rand() / RAND_MAX);
inputBufferData.push_back(rand() / static_cast<float>(RAND_MAX));
}
auto inputBuffer = createBuffer(inputCount * sizeof(float), inputBufferData.data());

Expand Down
2 changes: 1 addition & 1 deletion examples/mlp-training/mlp-training.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct ExampleProgram : public TestBase
std::vector<float> inputBufferData;
for (int i = 0; i < inputCount; i++)
{
inputBufferData.push_back((float)rand() / RAND_MAX);
inputBufferData.push_back(rand() / static_cast<float>(RAND_MAX));
}
auto inputBuffer = createBuffer(inputCount * sizeof(float), inputBufferData.data());

Expand Down
30 changes: 10 additions & 20 deletions source/slang/slang-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2303,8 +2303,7 @@ IRConstant* IRBuilder::_findOrEmitConstant(IRConstant& keyInst)

IRInst* IRBuilder::getBoolValue(bool inValue)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};
keyInst.m_op = kIROp_BoolLit;
keyInst.typeUse.usedValue = getBoolType();
keyInst.value.intVal = IRIntegerValue(inValue);
Expand All @@ -2318,8 +2317,7 @@ IRInst* IRBuilder::getIntValue(IRIntegerValue value)

IRInst* IRBuilder::getIntValue(IRType* type, IRIntegerValue inValue)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};
keyInst.m_op = kIROp_IntLit;
keyInst.typeUse.usedValue = type;
// Truncate the input value based on `type`.
Expand Down Expand Up @@ -2356,8 +2354,7 @@ IRInst* IRBuilder::getIntValue(IRType* type, IRIntegerValue inValue)

IRInst* IRBuilder::getFloatValue(IRType* type, IRFloatingPointValue inValue)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};
keyInst.m_op = kIROp_FloatLit;
keyInst.typeUse.usedValue = type;
// Truncate the input value based on `type`.
Expand All @@ -2379,12 +2376,10 @@ IRInst* IRBuilder::getFloatValue(IRType* type, IRFloatingPointValue inValue)

IRStringLit* IRBuilder::getStringValue(const UnownedStringSlice& inSlice)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};

// Mark that this is on the stack...
IRDecoration stackDecoration;
memset(&stackDecoration, 0, sizeof(stackDecoration));
IRDecoration stackDecoration{};
stackDecoration.m_op = kIROp_TransitoryDecoration;
stackDecoration.insertAtEnd(&keyInst);

Expand All @@ -2400,8 +2395,7 @@ IRStringLit* IRBuilder::getStringValue(const UnownedStringSlice& inSlice)

IRBlobLit* IRBuilder::getBlobValue(ISlangBlob* blob)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};

char* buffer = (char*)(getModule()->getMemoryArena().allocate(blob->getBufferSize()));
if (!buffer)
Expand All @@ -2413,8 +2407,7 @@ IRBlobLit* IRBuilder::getBlobValue(ISlangBlob* blob)
UnownedStringSlice inSlice(buffer, blob->getBufferSize());

// Mark that this is on the stack...
IRDecoration stackDecoration;
memset(&stackDecoration, 0, sizeof(stackDecoration));
IRDecoration stackDecoration{};
stackDecoration.m_op = kIROp_TransitoryDecoration;
stackDecoration.insertAtEnd(&keyInst);

Expand All @@ -2430,8 +2423,7 @@ IRBlobLit* IRBuilder::getBlobValue(ISlangBlob* blob)

IRPtrLit* IRBuilder::getPtrValue(IRType* type, void* data)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};
keyInst.m_op = kIROp_PtrLit;
keyInst.typeUse.usedValue = type;
keyInst.value.ptrVal = data;
Expand All @@ -2440,8 +2432,7 @@ IRPtrLit* IRBuilder::getPtrValue(IRType* type, void* data)

IRPtrLit* IRBuilder::getNullPtrValue(IRType* type)
{
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};
keyInst.m_op = kIROp_PtrLit;
keyInst.typeUse.usedValue = type;
keyInst.value.ptrVal = nullptr;
Expand All @@ -2452,8 +2443,7 @@ IRVoidLit* IRBuilder::getVoidValue()
{
IRType* type = getVoidType();

IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
IRConstant keyInst{};
keyInst.m_op = kIROp_VoidLit;
keyInst.typeUse.usedValue = type;
keyInst.value.intVal = 0;
Expand Down
7 changes: 6 additions & 1 deletion tools/slang-fiddle/slang-fiddle-lua.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// slang-fiddle-lua.cpp

#include "slang.h"

#define MAKE_LIB 1

#if SLANG_UNIX_FAMILY
#define LUA_USE_POSIX
#endif

#include "lua/onelua.c"