forked from OSchip/llvm-project
Stop abusing SuppressAllDiagnostics when speculatively determining
whether an expression would be valid during error recovery. llvm-svn: 369145
This commit is contained in:
parent
234eda563d
commit
2e3ed4a852
|
@ -1772,12 +1772,12 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
|
||||||
OpKind == tok::arrow ? tok::period : tok::arrow;
|
OpKind == tok::arrow ? tok::period : tok::arrow;
|
||||||
ExprResult CorrectedLHS(/*Invalid=*/true);
|
ExprResult CorrectedLHS(/*Invalid=*/true);
|
||||||
if (getLangOpts().CPlusPlus && OrigLHS) {
|
if (getLangOpts().CPlusPlus && OrigLHS) {
|
||||||
const bool DiagsAreSuppressed = Diags.getSuppressAllDiagnostics();
|
// FIXME: Creating a TentativeAnalysisScope from outside Sema is a
|
||||||
Diags.setSuppressAllDiagnostics(true);
|
// hack.
|
||||||
|
Sema::TentativeAnalysisScope Trap(Actions);
|
||||||
CorrectedLHS = Actions.ActOnStartCXXMemberReference(
|
CorrectedLHS = Actions.ActOnStartCXXMemberReference(
|
||||||
getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
|
getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
|
||||||
MayBePseudoDestructor);
|
MayBePseudoDestructor);
|
||||||
Diags.setSuppressAllDiagnostics(DiagsAreSuppressed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *Base = LHS.get();
|
Expr *Base = LHS.get();
|
||||||
|
|
|
@ -1929,11 +1929,9 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
|
||||||
// member templates with defaults/deduction of template arguments, overloads
|
// member templates with defaults/deduction of template arguments, overloads
|
||||||
// with default arguments, etc.
|
// with default arguments, etc.
|
||||||
if (IsMemExpr && !E.isTypeDependent()) {
|
if (IsMemExpr && !E.isTypeDependent()) {
|
||||||
bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
|
Sema::TentativeAnalysisScope Trap(*this);
|
||||||
getDiagnostics().setSuppressAllDiagnostics(true);
|
|
||||||
ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(),
|
ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(),
|
||||||
None, SourceLocation());
|
None, SourceLocation());
|
||||||
getDiagnostics().setSuppressAllDiagnostics(Suppress);
|
|
||||||
if (R.isUsable()) {
|
if (R.isUsable()) {
|
||||||
ZeroArgCallReturnTy = R.get()->getType();
|
ZeroArgCallReturnTy = R.get()->getType();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5798,8 +5798,7 @@ Expr *OpenMPIterationSpaceChecker::buildPreCond(
|
||||||
Scope *S, Expr *Cond,
|
Scope *S, Expr *Cond,
|
||||||
llvm::MapVector<const Expr *, DeclRefExpr *> &Captures) const {
|
llvm::MapVector<const Expr *, DeclRefExpr *> &Captures) const {
|
||||||
// Try to build LB <op> UB, where <op> is <, >, <=, or >=.
|
// Try to build LB <op> UB, where <op> is <, >, <=, or >=.
|
||||||
bool Suppress = SemaRef.getDiagnostics().getSuppressAllDiagnostics();
|
Sema::TentativeAnalysisScope Trap(SemaRef);
|
||||||
SemaRef.getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
|
|
||||||
|
|
||||||
ExprResult NewLB =
|
ExprResult NewLB =
|
||||||
InitDependOnLC ? LB : tryBuildCapture(SemaRef, LB, Captures);
|
InitDependOnLC ? LB : tryBuildCapture(SemaRef, LB, Captures);
|
||||||
|
@ -5821,7 +5820,7 @@ Expr *OpenMPIterationSpaceChecker::buildPreCond(
|
||||||
CondExpr.get(), SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
|
CondExpr.get(), SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
|
||||||
/*AllowExplicit=*/true);
|
/*AllowExplicit=*/true);
|
||||||
}
|
}
|
||||||
SemaRef.getDiagnostics().setSuppressAllDiagnostics(Suppress);
|
|
||||||
// Otherwise use original loop condition and evaluate it in runtime.
|
// Otherwise use original loop condition and evaluate it in runtime.
|
||||||
return CondExpr.isUsable() ? CondExpr.get() : Cond;
|
return CondExpr.isUsable() ? CondExpr.get() : Cond;
|
||||||
}
|
}
|
||||||
|
@ -6243,8 +6242,8 @@ static ExprResult buildCounterUpdate(
|
||||||
if (VarRef.get()->getType()->isOverloadableType() ||
|
if (VarRef.get()->getType()->isOverloadableType() ||
|
||||||
NewStart.get()->getType()->isOverloadableType() ||
|
NewStart.get()->getType()->isOverloadableType() ||
|
||||||
Update.get()->getType()->isOverloadableType()) {
|
Update.get()->getType()->isOverloadableType()) {
|
||||||
bool Suppress = SemaRef.getDiagnostics().getSuppressAllDiagnostics();
|
Sema::TentativeAnalysisScope Trap(SemaRef);
|
||||||
SemaRef.getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
|
|
||||||
Update =
|
Update =
|
||||||
SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), NewStart.get());
|
SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), NewStart.get());
|
||||||
if (Update.isUsable()) {
|
if (Update.isUsable()) {
|
||||||
|
@ -6256,7 +6255,6 @@ static ExprResult buildCounterUpdate(
|
||||||
UpdateVal.get());
|
UpdateVal.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SemaRef.getDiagnostics().setSuppressAllDiagnostics(Suppress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second attempt: try to build 'VarRef = Start (+|-) Iter * Step'.
|
// Second attempt: try to build 'VarRef = Start (+|-) Iter * Step'.
|
||||||
|
@ -13605,11 +13603,13 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind,
|
||||||
<< RefExpr->getSourceRange();
|
<< RefExpr->getSourceRange();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
|
|
||||||
getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
|
ExprResult Res;
|
||||||
ExprResult Res =
|
{
|
||||||
CreateBuiltinUnaryOp(ELoc, UO_AddrOf, RefExpr->IgnoreParenImpCasts());
|
Sema::TentativeAnalysisScope Trap(*this);
|
||||||
getDiagnostics().setSuppressAllDiagnostics(Suppress);
|
Res = CreateBuiltinUnaryOp(ELoc, UO_AddrOf,
|
||||||
|
RefExpr->IgnoreParenImpCasts());
|
||||||
|
}
|
||||||
if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr)) {
|
if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr)) {
|
||||||
Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
|
Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
|
||||||
<< RefExpr->getSourceRange();
|
<< RefExpr->getSourceRange();
|
||||||
|
|
Loading…
Reference in New Issue