Skip to content

Commit f50a9ec

Browse files
committed
[ser] Folded warn_hlsl_impcast_XYZ coherence diags into one
1 parent b263222 commit f50a9ec

2 files changed

Lines changed: 38 additions & 21 deletions

File tree

tools/clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7758,15 +7758,15 @@ def warn_hlsl_semantic_attribute_position_misuse_hint: Warning<
77587758
def warn_hlsl_unary_negate_unsigned : Warning<
77597759
"unary negate of unsigned value is still unsigned">,
77607760
InGroup<Conversion>, DefaultWarn;
7761-
def warn_hlsl_impcast_glc_mismatch : Warning<
7762-
"implicit conversion from %0 to %1 %select{loses|adds}2 globallycoherent annotation">,
7763-
InGroup<Conversion>, DefaultWarn;
7764-
def warn_hlsl_impcast_rdc_mismatch : Warning<
7765-
"implicit conversion from %0 to %1 %select{loses|adds}2 reordercoherent annotation">,
7766-
InGroup<Conversion>, DefaultWarn;
7767-
def warn_hlsl_impcast_rdc_glc_mismatch : Warning<
7768-
"implicit conversion from %0 to %1 %select{demotes globallycoherent to reordercoherent|promotes reordercoherent to globallycoherent}2 annotation">,
7769-
InGroup<Conversion>, DefaultWarn;
7761+
def warn_hlsl_impcast_coherence_mismatch : Warning<
7762+
"implicit conversion from %0 to %1 %select{"
7763+
"demotes globallycoherent to reordercoherent|"
7764+
"promotes reordercoherent to globallycoherent|"
7765+
"loses reordercoherent|"
7766+
"loses globallycoherent|"
7767+
"adds reordercoherent|"
7768+
"adds globallycoherent}2 annotation">,
7769+
InGroup<Conversion>;
77707770
def warn_hlsl_glc_implies_rdc : Warning<
77717771
"attribute 'globallycoherent' implies 'reordercoherent'">, InGroup<IgnoredAttributes>;
77727772
def warn_hlsl_narrowing : Warning<

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13716,18 +13716,35 @@ void Sema::DiagnoseCoherenceMismatch(const Expr *SrcExpr, QualType TargetType,
1371613716
// 'globallycoherent'
1371713717
bool SrcRD = hlsl::HasHLSLReorderCoherent(SrcTy);
1371813718
bool DstRD = hlsl::HasHLSLReorderCoherent(DstTy);
13719-
bool DemoteToRD = SrcGL && DstRD;
13720-
bool PromoteToGL = SrcRD && DstGL;
13721-
if (DemoteToRD || PromoteToGL)
13722-
Diag(Loc, diag::warn_hlsl_impcast_rdc_glc_mismatch)
13723-
<< SrcExpr->getType() << TargetType
13724-
<< /*demotes|promotes*/ PromoteToGL;
13725-
else if (SrcGL != DstGL)
13726-
Diag(Loc, diag::warn_hlsl_impcast_glc_mismatch)
13727-
<< SrcExpr->getType() << TargetType << /*loses|adds*/ DstGL;
13728-
else if (SrcRD != DstRD)
13729-
Diag(Loc, diag::warn_hlsl_impcast_rdc_mismatch)
13730-
<< SrcExpr->getType() << TargetType << /*loses|adds*/ DstRD;
13719+
13720+
enum {
13721+
NoMismatch = -1,
13722+
DemoteToRD = 0,
13723+
PromoteToGL = 1,
13724+
LosesRD = 2,
13725+
LosesGL = 3,
13726+
AddsRD = 4,
13727+
AddsGL = 5
13728+
} MismatchType = NoMismatch;
13729+
13730+
if (SrcGL && DstRD)
13731+
MismatchType = DemoteToRD;
13732+
else if (SrcRD && DstGL)
13733+
MismatchType = PromoteToGL;
13734+
else if (SrcRD && !DstRD)
13735+
MismatchType = LosesRD;
13736+
else if (SrcGL && !DstGL)
13737+
MismatchType = LosesGL;
13738+
else if (!SrcRD && DstRD)
13739+
MismatchType = AddsRD;
13740+
else if (!SrcGL && DstGL)
13741+
MismatchType = AddsGL;
13742+
13743+
if (MismatchType == NoMismatch)
13744+
return;
13745+
13746+
Diag(Loc, diag::warn_hlsl_impcast_coherence_mismatch)
13747+
<< SrcExpr->getType() << TargetType << MismatchType;
1373113748
}
1373213749
}
1373313750

0 commit comments

Comments
 (0)