Repository: shader-slang/slang
File: source/slang/slang-ast-print.cpp (C++)

Code before:
            if (as<BasicExpressionType>(elementType))
            {
                matrixType->getElementType()->toText(m_builder);
                if (as<ConstantIntVal>(matrixType->getRowCount()) &&
                    as<ConstantIntVal>(matrixType->getColumnCount()))
                {
                    m_builder << matrixType->getRowCount() << "x" << matrixType->getColumnCount();
                    return;
                }
            }
        }
    }
    type->toText(m_builder);
}

void ASTPrinter::addExpr(Expr* expr)
{
    if (!expr)
    {
        m_builder << "<error>";
        return;
    }

    auto& sb = m_builder;

    if (as<IncompleteExpr>(expr))
    {
        sb << "<incomplete>";
    }
    else if (const auto varExpr = as<VarExpr>(expr))
    {
        if (varExpr->declRef)
        {
            addDeclPath(varExpr->declRef);
        }
        else if (varExpr->name)
        {
            sb << varExpr->name->text;
        }
        else
        {
            sb << "<unknown-var>";
        }
    }
    else if (const auto memberExpr = as<MemberExpr>(expr))
    {
        if (memberExpr->baseExpression)
        {
            addExpr(memberExpr->baseExpression);
            sb << ".";
        }

Review comment (bug):
It may need more discussion about this.
But I treat this as a Slang coding style.

At some point, I think I made some changes to CMake to ignore this warning for Clang.
I am not sure why it didn't work for you.
If we go with fixing the source code rather than snoozing the warning, we will also need to revert my change in CMake.

I personally think that this is a kind of function parameter unused.
```
void myFunc(int probablyUnused)
{
 ... `probablyUnused` is not used ...
}
```
It sometimes helps us to find an unexpected mistake/bug.
And I see a value of having the warning enabled.

But the annoying part is that, when you are making code changes during the development, you have to keep removing them all. Or if you changed the code to use the variable, you have to bring them all again and you have to spend time coming up with a good variable name again.

Alternatively, we may snooze the warning with
```
(void)incompleteExpr; // We have SLANG_UNUSED macro too
```

It will be worth bringing up a discussion with more Slang dev members before committing this change.

Code after:
            if (as<BasicExpressionType>(elementType))
            {
                matrixType->getElementType()->toText(m_builder);
                if (as<ConstantIntVal>(matrixType->getRowCount()) &&
                    as<ConstantIntVal>(matrixType->getColumnCount()))
                {
                    m_builder << matrixType->getRowCount() << "x" << matrixType->getColumnCount();
                    return;
                }
            }
        }
    }
    type->toText(m_builder);
}

void ASTPrinter::addExpr(Expr* expr)
{
    if (!expr)
    {
        m_builder << "<error>";
        return;
    }

    auto& sb = m_builder;

    if (const auto incompleteExpr = as<IncompleteExpr>(expr))
    {
        sb << "<incomplete>";
    }
    else if (const auto varExpr = as<VarExpr>(expr))
    {
        if (varExpr->declRef)
        {
            addDeclPath(varExpr->declRef);
        }
        else if (varExpr->name)
        {
            sb << varExpr->name->text;
        }
        else
        {
            sb << "<unknown-var>";
        }
    }
    else if (const auto memberExpr = as<MemberExpr>(expr))
    {
        if (memberExpr->baseExpression)
        {
            addExpr(memberExpr->baseExpression);
            sb << ".";
        }