Skip to content

Commit 578e61b

Browse files
committed
[Clang] Simplify BindingDecl scoping logic using getDecomposedDecl()->hasLocalStorage()
1 parent 27fc9b7 commit 578e61b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8513,18 +8513,15 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
85138513
}
85148514
// Apply scoping logic to both VarDecl and BindingDecl with local storage
85158515
if (isa<VarDecl, BindingDecl>(ShadowedDecl)) {
8516-
bool hasLocalStorage = false;
8516+
bool HasLocalStorage = false;
85178517
if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
8518-
hasLocalStorage = VD->hasLocalStorage();
8519-
} else {
8520-
// For BindingDecl, apply the same logic as
8521-
// VarDecl::hasLocalStorage(): local storage means not at file context
8522-
hasLocalStorage = !ShadowedDecl->getLexicalDeclContext()
8523-
->getRedeclContext()
8524-
->isFileContext();
8518+
HasLocalStorage = VD->hasLocalStorage();
8519+
} else if (const auto *BD = dyn_cast<BindingDecl>(ShadowedDecl)) {
8520+
HasLocalStorage =
8521+
cast<VarDecl>(BD->getDecomposedDecl())->hasLocalStorage();
85258522
}
85268523

8527-
if (hasLocalStorage) {
8524+
if (HasLocalStorage) {
85288525
// A variable can't shadow a local variable or binding in an enclosing
85298526
// scope, if they are separated by a non-capturing declaration
85308527
// context.

0 commit comments

Comments
 (0)