[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-17 Thread Justin Bogner via cfe-commits
https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/135909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/135909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
https://github.com/bob80905 approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/135909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
bogner wrote: > As a general comment, your approach of just checking for the existence of the > binding attribute may not in itself be sufficient. Consider this PR: > https://github.com/llvm/llvm-project/pull/135287/files There is a potential > case where the binding attribute has a slot = -1,

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
@@ -3278,6 +3284,9 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) { << static_cast(RT); } } + + if (!HasBinding && VD->getType()->isHLSLResourceRecord()) bogner wrote: Good catch! Added some tests with arrays and updated this to

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
bob80905 wrote: As a general comment, your approach of just checking for the existence of the binding attribute may not in itself be sufficient. Consider this PR: https://github.com/llvm/llvm-project/pull/135287/files There is a potential case where the binding attribute has a slot = -1, signif

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
@@ -14,6 +14,12 @@ RWBuffer c; // No warning - explicit binding. RWBuffer d : register(u0); +// No warning - explicit binding. +RWBuffer dd : register(space1); bogner wrote: Yes, you're correct. I've updated the latest, though this is commented out now becau

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
@@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -Wno-error=hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify + +// expected-warning@+1 {{resource has implicit register binding}} +cbuffer cb0 { + int a; +} + +// No warning - this is an elemen

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
https://github.com/bogner updated https://github.com/llvm/llvm-project/pull/135909 >From cabe20bfd129a574f978c2a10e4f66a04cb85794 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 2 Apr 2025 11:34:00 -0700 Subject: [PATCH 1/6] [HLSL] Add a warning for implicit bindings Implicit bindings

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
@@ -14,6 +14,12 @@ RWBuffer c; // No warning - explicit binding. RWBuffer d : register(u0); +// No warning - explicit binding. +RWBuffer dd : register(space1); bob80905 wrote: Shouldn't there be a warning here? Though the space param is being explicitly bound

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
@@ -3278,6 +3284,9 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) { << static_cast(RT); } } + + if (!HasBinding && VD->getType()->isHLSLResourceRecord()) +SemaRef.Diag(VD->getLocation(), diag::warn_hlsl_implicit_binding); bob

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
https://github.com/bogner updated https://github.com/llvm/llvm-project/pull/135909 >From cabe20bfd129a574f978c2a10e4f66a04cb85794 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 2 Apr 2025 11:34:00 -0700 Subject: [PATCH 1/2] [HLSL] Add a warning for implicit bindings Implicit bindings

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Justin Bogner via cfe-commits
@@ -3278,6 +3284,9 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) { << static_cast(RT); } } + + if (!HasBinding && VD->getType()->isHLSLResourceRecord()) +SemaRef.Diag(VD->getLocation(), diag::warn_hlsl_implicit_binding); bog

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Finn Plummer via cfe-commits
@@ -3278,6 +3284,9 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) { << static_cast(RT); } } + + if (!HasBinding && VD->getType()->isHLSLResourceRecord()) inbelic wrote: I do also see the function `isResourceRecordTypeOrArrayOf`

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
@@ -1,12 +1,9 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \ -// RUN: -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \ -// RUN: -finclude-default-header -include-pch %t -ast-

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Damyan Pepper via cfe-commits
https://github.com/damyanp edited https://github.com/llvm/llvm-project/pull/135909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Damyan Pepper via cfe-commits
https://github.com/damyanp approved this pull request. LGTM, assuming we don't need to do / test the "only specifying a space" case. https://github.com/llvm/llvm-project/pull/135909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
@@ -1,12 +1,9 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \ -// RUN: -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \ -// RUN: -finclude-default-header -include-pch %t -ast-

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Joshua Batista via cfe-commits
@@ -1,13 +1,12 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \ -// RUN: -finclude-default-header -include-pch %t -ast-d

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

2025-04-16 Thread Damyan Pepper via cfe-commits
@@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -Wno-error=hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify + +// expected-warning@+1 {{resource has implicit register binding}} +cbuffer cb0 { + int a; +} + +// No warning - this is an elemen