diff options
| -rw-r--r-- | source/core/slang-string.h | 1 | ||||
| -rw-r--r-- | source/slang/slang-ast-base.h | 22 | ||||
| -rw-r--r-- | source/slang/slang-ast-type.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-check-shader.cpp | 1 | ||||
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 6 | ||||
| -rw-r--r-- | source/slang/slang-syntax.cpp | 2 |
7 files changed, 16 insertions, 20 deletions
diff --git a/source/core/slang-string.h b/source/core/slang-string.h index 3f401b7bb..7c43ad647 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -56,6 +56,7 @@ namespace Slang buffer[i++] = (char)(digit - 10 + 'A'); } while ((val /= radix) > 0); + SLANG_ASSERT(i >= 0); while(i < padTo) buffer[i++] = '0'; diff --git a/source/slang/slang-ast-base.h b/source/slang/slang-ast-base.h index 777098943..0170ca493 100644 --- a/source/slang/slang-ast-base.h +++ b/source/slang/slang-ast-base.h @@ -350,34 +350,34 @@ class Val : public NodeBase { return as<T>(val->getOperand(index + offset)); } - struct Iterator + struct ConstIterator { const Val* val; Index i; - bool operator==(Iterator other) const + bool operator==(ConstIterator other) const { return val == other.val && i == other.i; } - bool operator!=(Iterator other) const + bool operator!=(ConstIterator other) const { return val != other.val || i != other.i; } - T*& operator*() const + T *const & operator*() const { - return *(T**)&val->m_operands[i].values.nodeOperand; + return *(this->operator->()); } - T** operator->() const + T *const * operator->() const { - return (T**)&val->m_operands[i].values.nodeOperand; + return reinterpret_cast<T *const *>(&val->m_operands[i].values.nodeOperand); } - Iterator& operator++() + ConstIterator& operator++() { i++; return *this; } }; - Iterator begin() const { return Iterator { val, offset }; } - Iterator end() const { return Iterator{ val, offset + count }; } + ConstIterator begin() const { return ConstIterator { val, offset }; } + ConstIterator end() const { return ConstIterator{ val, offset + count }; } }; typedef IValVisitor Visitor; @@ -397,7 +397,7 @@ class Val : public NodeBase bool equals(Val* val) const { - return this == val || const_cast<Val*>(this)->resolve() == val->resolve(); + return this == val || (val && const_cast<Val*>(this)->resolve() == val->resolve()); } // Appends as text to the end of the builder diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp index 6d4a52cae..9704b4c87 100644 --- a/source/slang/slang-ast-type.cpp +++ b/source/slang/slang-ast-type.cpp @@ -103,7 +103,7 @@ Val* DeclRefType::_substituteImplOverride(ASTBuilder* astBuilder, SubstitutionSe // if (as<DirectDeclRef>(substDeclRef.declRefBase)) { - if (auto thisDecl = as<ThisTypeDecl>(substDeclRef.getDecl())) + if (as<ThisTypeDecl>(substDeclRef.getDecl())) { auto lookupDeclRef = subst.findLookupDeclRef(); if (lookupDeclRef && lookupDeclRef->getSupDecl() == substDeclRef.getDecl()->parentDecl) diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 8c9ca2936..cb3db9e39 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -1335,7 +1335,7 @@ namespace Slang auto newDeclRef = createDefaultSubstitutionsIfNeeded(m_astBuilder, this, declRefType->getDeclRef()); auto newType = DeclRefType::create(m_astBuilder, newDeclRef); sharedTypeExpr->base.type = newType; - if (auto typetype = as<TypeType>(typeExp.exp->type)) + if (as<TypeType>(typeExp.exp->type)) typeExp.exp->type = m_astBuilder->getTypeType(newType); } } diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp index d9bb11548..d2ac0d12f 100644 --- a/source/slang/slang-check-shader.cpp +++ b/source/slang/slang-check-shader.cpp @@ -1206,7 +1206,6 @@ namespace Slang auto specializationArg = args[ii]; genericArgs.add(specializationArg.val); } - auto genericInnerDeclRef = getLinkage()->getASTBuilder()->getGenericAppDeclRef(genericDeclRef, genericArgs.getArrayView()); ASTBuilder* astBuilder = getLinkage()->getASTBuilder(); for (auto constraintDecl : getMembersOfType<GenericTypeConstraintDecl>( diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index a3051fadb..10adb9708 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -2806,11 +2806,7 @@ struct SPIRVEmitContext SpvWord baseId = 0; // Only used in debug build, but we don't want a warning/error for an unused initialized variable - if (auto ptrLikeType = as<IRPointerLikeType>(base->getDataType())) - { - baseId = getID(ensureInst(base)); - } - else if (auto ptrType = as<IRPtrTypeBase>(base->getDataType())) + if (as<IRPointerLikeType>(base->getDataType()) || as<IRPtrTypeBase>(base->getDataType())) { baseId = getID(ensureInst(base)); } diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index b7e9af43a..1f96df2f0 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -411,7 +411,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt ASTBuilder* astBuilder, DeclRef<Decl> declRef) { - if (auto builtinMod = declRef.getDecl()->findModifier<BuiltinTypeModifier>()) + if (declRef.getDecl()->findModifier<BuiltinTypeModifier>()) { // Always create builtin types in global AST builder. if (astBuilder->getSharedASTBuilder()->getInnerASTBuilder() != astBuilder) |
