Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7a4f217
[SER] Generalize long vector diagnostics to HitObject
simoll Mar 20, 2025
18e7c1c
Merge remote-tracking branch 'msft/main' into NEWBASE
simoll May 2, 2025
57ff5a3
Split-off from LongVector diagnostics / Fold err_hlsl_node_record_object
simoll Apr 30, 2025
2c128ef
Remove redundant '' around %0 in unsupported_object_context diag msg
simoll May 9, 2025
e39fe2f
'type parameters' -> 'builtin template parameters'
simoll May 9, 2025
92bb7fc
Update tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
simoll May 13, 2025
6bb2dbf
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
e0e063a
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
c039f8c
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
2a7b39c
Update tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp
simoll May 13, 2025
21447bc
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
2be84a2
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
85746fb
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
36d678c
Update tools/clang/test/SemaHLSL/hlsl/types/invalid-hitobject-decls-s…
simoll May 13, 2025
96c6b8c
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
c07e548
static_cast<unsigned>(TypeDiagContext)
simoll May 13, 2025
004dc1d
Default case: accept as non-Empty and add comment that only recursive
simoll May 13, 2025
244c59c
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
fa895f7
function description
simoll May 13, 2025
9db0556
Clang format
simoll May 13, 2025
e7f8c5a
Assert TypeDiagContext enum value compatible with unsupported_long_ve…
simoll May 13, 2025
fea88fb
Update tools/clang/lib/Sema/SemaHLSL.cpp
simoll May 13, 2025
701c680
Fold isGroupShared in with isStatic/isGlobal diag case
simoll May 13, 2025
001eb50
Clang format
simoll May 13, 2025
ae98e48
Fold unsupported_long_vec into DiagnoseElementTypes
simoll May 13, 2025
2fd825f
Remove HLSLLongVector tracking bit (DiagnoseElementTypes descends into
simoll May 13, 2025
43449f4
Merge remote-tracking branch 'msft/main' into ser_diaghitobject_patch
simoll May 15, 2025
1b8af76
Update test after merge
simoll May 15, 2025
36e9615
Revert "Update test after merge"
tex3d May 15, 2025
4b34518
Recurse bases in IsHLSLCopyableAnnotatableRecord
tex3d May 15, 2025
58b7642
Diagnose long vector in payload call argument case
tex3d May 15, 2025
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
11 changes: 0 additions & 11 deletions tools/clang/include/clang/AST/DeclCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,6 @@ class CXXRecordDecl : public RecordDecl {
/// \brief Whether we are currently parsing base specifiers.
bool IsParsingBaseSpecifiers : 1;

/// \brief Whether this class contains at least one member or base
/// class containing an HLSL vector longer than 4 elements.
bool HasHLSLLongVector : 1;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confess I didn't anticpate that merging the longvector check with the other type checks would result in removing this bit, but I see how it follows and I don't object.


/// \brief The number of base class specifiers in Bases.
unsigned NumBases;

Expand Down Expand Up @@ -1022,13 +1018,6 @@ class CXXRecordDecl : public RecordDecl {
return data().NeedOverloadResolutionForDestructor;
}

// HLSL Change add HLSL Long vector bit.
/// \brief Determine whether this class contains an HLSL long vector
/// of over 4 elements.
bool hasHLSLLongVector() { return data().HasHLSLLongVector; }
/// \brief Set that this class contains an HLSL long vector of over 4 elements
bool setHasHLSLLongVector() { return data().HasHLSLLongVector = true; }

/// \brief Determine whether this class describes a lambda function object.
bool isLambda() const {
// An update record can't turn a non-lambda into a lambda.
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -7884,7 +7884,7 @@ def err_hlsl_unsupported_long_vector
"entry function parameters|entry function return type|"
"patch constant function parameters|patch constant function return type|"
"payload parameters|attributes}0 are not supported">;
// %select options must be compatible with err_hlsl_unsupported_long_vector (same index used)
// First %select options must match err_hlsl_unsupported_long_vector (same index used)
def err_hlsl_unsupported_object_context
: Error<"object %0 is not allowed in "
"%select{ConstantBuffers or TextureBuffers|"
Expand Down
11 changes: 10 additions & 1 deletion tools/clang/include/clang/Sema/SemaHLSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ bool DiagnoseNodeStructArgument(clang::Sema *self,

// Keep this in sync with err_hlsl_unsupported_object in DiagnosticSemaKinds.td
enum class TypeDiagContext {
// Indices that the type context is valid and no diagnostics should be emitted
// for this type category.
Valid = -1,
// Supported indices for both `err_hlsl_unsupported_object_context` and
// `err_hlsl_unsupported_long_vector`
ConstantBuffersOrTextureBuffers = 0,
TessellationPatches = 1,
GeometryStreams = 2,
Expand All @@ -74,12 +79,16 @@ enum class TypeDiagContext {
PayloadParameters = 10,
Attributes = 11,
TypeParameter = 12,
LongVecDiagMaxSelectIndex = TypeParameter,
// Below only supported for `err_hlsl_diag_unsupported_object_context`
StructuredBuffers = 13,
GlobalVariables = 14,
GroupShared = 15,
DiagMaxSelectIndex = 15,
};
bool DiagnoseTypeElements(clang::Sema &S, clang::SourceLocation Loc,
clang::QualType Ty, TypeDiagContext DiagContext,
clang::QualType Ty, TypeDiagContext ObjDiagContext,
TypeDiagContext LongVecDiagContext,
const clang::FieldDecl *FD = nullptr);

void DiagnoseControlFlowConditionForHLSL(clang::Sema *self,
Expand Down
14 changes: 2 additions & 12 deletions tools/clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D)
ImplicitCopyAssignmentHasConstParam(true),
HasDeclaredCopyConstructorWithConstParam(false),
HasDeclaredCopyAssignmentWithConstParam(false), IsLambda(false),
IsParsingBaseSpecifiers(false), HasHLSLLongVector(false), NumBases(0),
NumVBases(0), Bases(), VBases(), Definition(D), FirstFriend() {}
IsParsingBaseSpecifiers(false), NumBases(0), NumVBases(0), Bases(),
VBases(), Definition(D), FirstFriend() {}
// HLSL Change End - Add HasLongVector and clang-format

CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const {
Expand Down Expand Up @@ -203,11 +203,6 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
if (!BaseClassDecl->isStandardLayout())
data().IsStandardLayout = false;

// HLSL Change Begin - Propagate presence of long vector to child classes.
if (BaseClassDecl->hasHLSLLongVector())
data().HasHLSLLongVector = true;
// HLSL Change End

// Record if this base is the first non-literal field or base.
if (!hasNonLiteralTypeFieldsOrBases() && !BaseType->isLiteralType(C))
data().HasNonLiteralTypeFieldsOrBases = true;
Expand Down Expand Up @@ -389,11 +384,6 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) {
data().NeedOverloadResolutionForMoveConstructor = true;
data().NeedOverloadResolutionForDestructor = true;
}

// HLSL Change Begin - Propagate presence of long vector to child classes.
if (Subobj->hasHLSLLongVector())
data().HasHLSLLongVector = true;
// HLSL Change End
}

/// Callback function for CXXRecordDecl::forallBases that acknowledges
Expand Down
10 changes: 2 additions & 8 deletions tools/clang/lib/Sema/SemaDXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,9 @@ void DiagnoseBuiltinCallWithPayload(Sema &S, const VarDecl *Payload,
}

// Verify that the payload type is legal
const TypeDiagContext DiagContext = TypeDiagContext::PayloadParameters;
if (DiagnoseTypeElements(S, Payload->getLocation(), Payload->getType(),
TypeDiagContext::PayloadParameters))
DiagContext, DiagContext))
return;
if (!hlsl::IsHLSLCopyableAnnotatableRecord(Payload->getType())) {
S.Diag(Payload->getLocation(), diag::err_payload_attrs_must_be_udt)
Expand All @@ -837,13 +838,6 @@ void DiagnoseBuiltinCallWithPayload(Sema &S, const VarDecl *Payload,
return;
}

if (ContainsLongVector(Payload->getType())) {
const unsigned PayloadParametersIdx = 10;
S.Diag(Payload->getLocation(), diag::err_hlsl_unsupported_long_vector)
<< PayloadParametersIdx;
return;
}

CollectNonAccessableFields(PayloadType, CallerStage, {}, {},
NonWriteableFields, NonReadableFields);

Expand Down
Loading