forked from OSchip/llvm-project
[clang] Make CXXDefaultArgExpr inherit dependence from the inner Expr
Before this change, CXXDefaultArgExpr would always have ExprDependence::None. This can lead to issues when, for example, the inner expression is RecoveryExpr and yet containsErrors() on the default expression is false. Differential Revision: https://reviews.llvm.org/D103982
This commit is contained in:
parent
cc86b87a57
commit
a95937452f
clang
include/clang/AST
lib/AST
test/AST
|
@ -71,6 +71,7 @@ class OverloadExpr;
|
|||
class DependentScopeDeclRefExpr;
|
||||
class CXXConstructExpr;
|
||||
class CXXDefaultInitExpr;
|
||||
class CXXDefaultArgExpr;
|
||||
class LambdaExpr;
|
||||
class CXXUnresolvedConstructExpr;
|
||||
class CXXDependentScopeMemberExpr;
|
||||
|
@ -156,6 +157,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool KnownDependent,
|
|||
ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
|
||||
ExprDependence computeDependence(CXXConstructExpr *E);
|
||||
ExprDependence computeDependence(CXXDefaultInitExpr *E);
|
||||
ExprDependence computeDependence(CXXDefaultArgExpr *E);
|
||||
ExprDependence computeDependence(LambdaExpr *E,
|
||||
bool ContainsUnexpandedParameterPack);
|
||||
ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);
|
||||
|
|
|
@ -1257,7 +1257,7 @@ class CXXDefaultArgExpr final : public Expr {
|
|||
Param->getDefaultArg()->getObjectKind()),
|
||||
Param(Param), UsedContext(UsedContext) {
|
||||
CXXDefaultArgExprBits.Loc = Loc;
|
||||
setDependence(ExprDependence::None);
|
||||
setDependence(computeDependence(this));
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -748,6 +748,10 @@ ExprDependence clang::computeDependence(CXXDefaultInitExpr *E) {
|
|||
return E->getExpr()->getDependence();
|
||||
}
|
||||
|
||||
ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) {
|
||||
return E->getExpr()->getDependence();
|
||||
}
|
||||
|
||||
ExprDependence clang::computeDependence(LambdaExpr *E,
|
||||
bool ContainsUnexpandedParameterPack) {
|
||||
auto D = toExprDependence(E->getType()->getDependence());
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump -frecovery-ast %s | FileCheck %s
|
||||
|
||||
// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this case
|
||||
// RecoveryExpr.
|
||||
void fun(int arg = foo());
|
||||
|
||||
void test() {
|
||||
fun();
|
||||
}
|
||||
// CHECK: -CXXDefaultArgExpr 0x{{[^ ]*}} <<invalid sloc>> '<dependent type>' contains-errors lvalue
|
Loading…
Reference in New Issue