Skip to content

Commit a2aef53

Browse files
committed
Merge from 'main' to 'sycl-web' (13 commits)
2 parents 6aab14e + f1b0a4f commit a2aef53

File tree

29 files changed

+1180
-163
lines changed

29 files changed

+1180
-163
lines changed

clang/include/clang/AST/ComputeDependence.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class UnaryExprOrTypeTraitExpr;
3030
class ArraySubscriptExpr;
3131
class MatrixSubscriptExpr;
3232
class CompoundLiteralExpr;
33-
class CastExpr;
33+
class ImplicitCastExpr;
34+
class ExplicitCastExpr;
3435
class BinaryOperator;
3536
class ConditionalOperator;
3637
class BinaryConditionalOperator;
@@ -70,6 +71,7 @@ class CXXPseudoDestructorExpr;
7071
class OverloadExpr;
7172
class DependentScopeDeclRefExpr;
7273
class CXXConstructExpr;
74+
class CXXTemporaryObjectExpr;
7375
class CXXDefaultInitExpr;
7476
class CXXDefaultArgExpr;
7577
class LambdaExpr;
@@ -119,7 +121,8 @@ ExprDependence computeDependence(UnaryExprOrTypeTraitExpr *E);
119121
ExprDependence computeDependence(ArraySubscriptExpr *E);
120122
ExprDependence computeDependence(MatrixSubscriptExpr *E);
121123
ExprDependence computeDependence(CompoundLiteralExpr *E);
122-
ExprDependence computeDependence(CastExpr *E);
124+
ExprDependence computeDependence(ImplicitCastExpr *E);
125+
ExprDependence computeDependence(ExplicitCastExpr *E);
123126
ExprDependence computeDependence(BinaryOperator *E);
124127
ExprDependence computeDependence(ConditionalOperator *E);
125128
ExprDependence computeDependence(BinaryConditionalOperator *E);
@@ -161,6 +164,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool KnownDependent,
161164
bool KnownContainsUnexpandedParameterPack);
162165
ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
163166
ExprDependence computeDependence(CXXConstructExpr *E);
167+
ExprDependence computeDependence(CXXTemporaryObjectExpr *E);
164168
ExprDependence computeDependence(CXXDefaultInitExpr *E);
165169
ExprDependence computeDependence(CXXDefaultArgExpr *E);
166170
ExprDependence computeDependence(LambdaExpr *E,

clang/include/clang/AST/DependenceFlags.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ class Dependence {
130130

131131
// Dependence that is propagated syntactically, regardless of semantics.
132132
Syntactic = UnexpandedPack | Instantiation | Error,
133+
// Dependence that is propagated semantically, even in cases where the
134+
// type doesn't syntactically appear. This currently excludes only
135+
// UnexpandedPack. Even though Instantiation dependence is also notionally
136+
// syntactic, we also want to propagate it semantically because anything
137+
// that semantically depends on an instantiation-dependent entity should
138+
// always be instantiated when that instantiation-dependent entity is.
139+
Semantic =
140+
Instantiation | Type | Value | Dependent | Error | VariablyModified,
133141

134142
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/VariablyModified)
135143
};
@@ -175,6 +183,14 @@ class Dependence {
175183
return Result;
176184
}
177185

186+
/// Extract the semantic portions of this type's dependence that apply even
187+
/// to uses where the type does not appear syntactically.
188+
Dependence semantic() {
189+
Dependence Result = *this;
190+
Result.V &= Semantic;
191+
return Result;
192+
}
193+
178194
TypeDependence type() const {
179195
return translate(V, UnexpandedPack, TypeDependence::UnexpandedPack) |
180196
translate(V, Instantiation, TypeDependence::Instantiation) |
@@ -231,7 +247,10 @@ class Dependence {
231247
inline ExprDependence toExprDependence(TemplateArgumentDependence TA) {
232248
return Dependence(TA).expr();
233249
}
234-
inline ExprDependence toExprDependence(TypeDependence D) {
250+
inline ExprDependence toExprDependenceForImpliedType(TypeDependence D) {
251+
return Dependence(D).semantic().expr();
252+
}
253+
inline ExprDependence toExprDependenceAsWritten(TypeDependence D) {
235254
return Dependence(D).expr();
236255
}
237256
// Note: it's often necessary to strip `Dependent` from qualifiers.
@@ -269,6 +288,9 @@ inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
269288
inline TypeDependence toSyntacticDependence(TypeDependence D) {
270289
return Dependence(D).syntactic().type();
271290
}
291+
inline TypeDependence toSemanticDependence(TypeDependence D) {
292+
return Dependence(D).semantic().type();
293+
}
272294

273295
inline NestedNameSpecifierDependence
274296
toNestedNameSpecifierDependendence(TypeDependence D) {

clang/include/clang/AST/Expr.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,7 +3549,6 @@ class CastExpr : public Expr {
35493549
CastExprBits.BasePathSize = BasePathSize;
35503550
assert((CastExprBits.BasePathSize == BasePathSize) &&
35513551
"BasePathSize overflow!");
3552-
setDependence(computeDependence(this));
35533552
assert(CastConsistency());
35543553
CastExprBits.HasFPFeatures = HasFPFeatures;
35553554
}
@@ -3683,6 +3682,7 @@ class ImplicitCastExpr final
36833682
ExprValueKind VK)
36843683
: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength,
36853684
FPO.requiresTrailingStorage()) {
3685+
setDependence(computeDependence(this));
36863686
if (hasStoredFPFeatures())
36873687
*getTrailingFPFeatures() = FPO;
36883688
}
@@ -3760,7 +3760,9 @@ class ExplicitCastExpr : public CastExpr {
37603760
CastKind kind, Expr *op, unsigned PathSize,
37613761
bool HasFPFeatures, TypeSourceInfo *writtenTy)
37623762
: CastExpr(SC, exprTy, VK, kind, op, PathSize, HasFPFeatures),
3763-
TInfo(writtenTy) {}
3763+
TInfo(writtenTy) {
3764+
setDependence(computeDependence(this));
3765+
}
37643766

37653767
/// Construct an empty explicit cast.
37663768
ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize,

0 commit comments

Comments
 (0)