Skip to content

Commit

Permalink
[clang][Sema][NFC] Simplify ActOnCXXThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Dec 19, 2023
1 parent 32aa7d8 commit 6905438
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,21 +843,21 @@ Sema::ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *Ex) {
// operation from the operand to the exception object (15.1) can be
// omitted by constructing the automatic object directly into the
// exception object
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Ex->IgnoreParens()))
if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
if (Var->hasLocalStorage() && !Var->getType().isVolatileQualified()) {
for( ; S; S = S->getParent()) {
if (S->isDeclScope(Var)) {
IsThrownVarInScope = true;
break;
}

// FIXME: Many of the scope checks here seem incorrect.
if (S->getFlags() &
(Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
Scope::ObjCMethodScope | Scope::TryScope))
break;
if (const auto *DRE = dyn_cast<DeclRefExpr>(Ex->IgnoreParens()))
if (const auto *Var = dyn_cast<VarDecl>(DRE->getDecl());
Var && Var->hasLocalStorage() &&
!Var->getType().isVolatileQualified()) {
for (; S; S = S->getParent()) {
if (S->isDeclScope(Var)) {
IsThrownVarInScope = true;
break;
}

// FIXME: Many of the scope checks here seem incorrect.
if (S->getFlags() &
(Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
Scope::ObjCMethodScope | Scope::TryScope))
break;
}
}
}
Expand Down

0 comments on commit 6905438

Please sign in to comment.