-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] Implement '__builtin_hlsl_is_intangible' type trait #104544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6d5f899
Implement `__builtin_is_intangible`
hekota d21ca2e
add caching
hekota d7e8bce
clang-format
hekota 481c118
add tests
hekota 2df0576
base classes!
hekota 227befd
Update default for incomplete type
hekota 4bbf083
Rename to `__builtin_hlsl_is_intangible`
hekota 6fd1bf7
clang-format
hekota 43d8d0c
Merge branch 'main' of https://github.com/llvm/llvm-project into inta…
hekota bd25ab6
Merge branch 'main' of https://github.com/llvm/llvm-project into inta…
hekota c761e5f
Merge branch 'main' of https://github.com/llvm/llvm-project into inta…
hekota 7f29d6f
Address code review feedback
hekota d666eb7
Remove accidentally added file
hekota dcd2c49
Simplify IsIntangible calculation, add empty new line
hekota 97ffb26
Replace DenseMap cache with 2 bits on RecordDeclBitfields
hekota 6701935
Merge branch 'main' of https://github.com/llvm/llvm-project into inta…
hekota 094e208
Store IsIntangible in CXXRecordDecl flags; set it when new field or b…
hekota 0e1b82c
clang-format & desugar
hekota 2eba03c
one more little space
hekota 027d473
Rename to IsHLSLIntangible; return false for variable length arrays a…
hekota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -fnative-half-type -verify %s | ||
// expected-no-diagnostics | ||
|
||
_Static_assert(__builtin_hlsl_is_intangible(__hlsl_resource_t), ""); | ||
// no need to check array of __hlsl_resource_t, arrays of sizeless types are not supported | ||
|
||
_Static_assert(!__builtin_hlsl_is_intangible(int), ""); | ||
_Static_assert(!__builtin_hlsl_is_intangible(float3), ""); | ||
_Static_assert(!__builtin_hlsl_is_intangible(half[4]), ""); | ||
|
||
typedef __hlsl_resource_t Res; | ||
_Static_assert(__builtin_hlsl_is_intangible(const Res), ""); | ||
// no need to check array of Res, arrays of sizeless types are not supported | ||
|
||
struct ABuffer { | ||
const int i[10]; | ||
__hlsl_resource_t h; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(ABuffer), ""); | ||
_Static_assert(__builtin_hlsl_is_intangible(ABuffer[10]), ""); | ||
|
||
struct MyStruct { | ||
half2 h2; | ||
int3 i3; | ||
}; | ||
_Static_assert(!__builtin_hlsl_is_intangible(MyStruct), ""); | ||
_Static_assert(!__builtin_hlsl_is_intangible(MyStruct[10]), ""); | ||
|
||
class MyClass { | ||
int3 ivec; | ||
float farray[12]; | ||
MyStruct ms; | ||
ABuffer buf; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(MyClass), ""); | ||
_Static_assert(__builtin_hlsl_is_intangible(MyClass[2]), ""); | ||
|
||
union U { | ||
double d[4]; | ||
Res buf; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(U), ""); | ||
_Static_assert(__builtin_hlsl_is_intangible(U[100]), ""); | ||
|
||
class MyClass2 { | ||
int3 ivec; | ||
float farray[12]; | ||
U u; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(MyClass2), ""); | ||
_Static_assert(__builtin_hlsl_is_intangible(MyClass2[5]), ""); | ||
|
||
class Simple { | ||
int a; | ||
}; | ||
|
||
template<typename T> struct TemplatedBuffer { | ||
T a; | ||
__hlsl_resource_t h; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(TemplatedBuffer<int>), ""); | ||
|
||
struct MyStruct2 : TemplatedBuffer<float> { | ||
float x; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(MyStruct2), ""); | ||
|
||
struct MyStruct3 { | ||
const TemplatedBuffer<float> TB[10]; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(MyStruct3), ""); | ||
|
||
template<typename T> struct SimpleTemplate { | ||
T a; | ||
}; | ||
_Static_assert(__builtin_hlsl_is_intangible(SimpleTemplate<__hlsl_resource_t>), ""); | ||
_Static_assert(!__builtin_hlsl_is_intangible(SimpleTemplate<float>), ""); |
11 changes: 11 additions & 0 deletions
11
clang/test/SemaHLSL/Types/Traits/IsIntangibleTypeErrors.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s | ||
|
||
struct Undefined; // expected-note {{forward declaration of 'Undefined'}} | ||
_Static_assert(!__builtin_hlsl_is_intangible(Undefined), ""); // expected-error{{incomplete type 'Undefined' used in type trait expression}} | ||
|
||
void fn(int X) { | ||
// expected-error@#vla {{variable length arrays are not supported for the current target}} | ||
// expected-error@#vla {{variable length arrays are not supported in '__builtin_hlsl_is_intangible'}} | ||
// expected-warning@#vla {{variable length arrays in C++ are a Clang extension}} | ||
_Static_assert(!__builtin_hlsl_is_intangible(int[X]), ""); // #vla | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.