Skip to content

Commit 74a4edc

Browse files
committed
NFC: Rename DeclVisibilityKind::LocalVariable -> LocalDecl
This includes local types, so make the name a bit more generic.
1 parent 747cbfc commit 74a4edc

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

include/swift/AST/NameLookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ inline UnqualifiedLookupOptions operator|(UnqualifiedLookupFlags flag1,
261261
/// Describes the reason why a certain declaration is visible.
262262
enum class DeclVisibilityKind {
263263
/// Declaration is a local variable or type.
264-
LocalVariable,
264+
LocalDecl,
265265

266266
/// Declaration is a function parameter.
267267
FunctionParameter,

lib/AST/NameLookup.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ void UsableFilteringDeclConsumer::foundDecl(ValueDecl *D,
160160
}
161161

162162
switch (reason) {
163-
case DeclVisibilityKind::LocalVariable:
163+
case DeclVisibilityKind::LocalDecl:
164164
case DeclVisibilityKind::FunctionParameter:
165165
// Skip if Loc is before the found decl if the decl is a var/let decl.
166166
// Type and func decls can be referenced before its declaration, or from
167167
// within nested type decls.
168168
if (isa<VarDecl>(D)) {
169-
if (reason == DeclVisibilityKind::LocalVariable) {
169+
if (reason == DeclVisibilityKind::LocalDecl) {
170170
// Workaround for fast-completion. A loc in the current context might be
171171
// in a loc
172172
auto tmpLoc = Loc;
@@ -240,7 +240,7 @@ void UsableFilteringDeclConsumer::foundDecl(ValueDecl *D,
240240
return;
241241

242242
switch (shadowingReason) {
243-
case DeclVisibilityKind::LocalVariable:
243+
case DeclVisibilityKind::LocalDecl:
244244
case DeclVisibilityKind::FunctionParameter:
245245
// Local func and var/let with a conflicting name.
246246
// func foo() {
@@ -251,7 +251,7 @@ void UsableFilteringDeclConsumer::foundDecl(ValueDecl *D,
251251
// So, for confilicting local values in the same decl context, even if the
252252
// 'var value' is reported after 'func value', don't shadow it, but we
253253
// shadow everything with the name after that.
254-
if (reason == DeclVisibilityKind::LocalVariable &&
254+
if (reason == DeclVisibilityKind::LocalDecl &&
255255
isa<VarDecl>(D) && !isa<VarDecl>(shadowingD) &&
256256
shadowingD->getDeclContext() == D->getDeclContext()) {
257257
// Replace the shadowing decl so we shadow subsequent conflicting decls.
@@ -3980,7 +3980,7 @@ void FindLocalVal::checkStmtCondition(const StmtCondition &Cond) {
39803980
if (auto *P = entry.getPatternOrNull()) {
39813981
SourceRange previousConditionsToHere = SourceRange(start, entry.getEndLoc());
39823982
if (!isReferencePointInRange(previousConditionsToHere))
3983-
checkPattern(P, DeclVisibilityKind::LocalVariable);
3983+
checkPattern(P, DeclVisibilityKind::LocalDecl);
39843984
}
39853985
}
39863986
}
@@ -4030,7 +4030,7 @@ void FindLocalVal::visitForEachStmt(ForEachStmt *S) {
40304030
return;
40314031
visit(S->getBody());
40324032
if (!isReferencePointInRange(S->getParsedSequence()->getSourceRange()))
4033-
checkPattern(S->getPattern(), DeclVisibilityKind::LocalVariable);
4033+
checkPattern(S->getPattern(), DeclVisibilityKind::LocalDecl);
40344034
}
40354035

40364036
void FindLocalVal::visitBraceStmt(BraceStmt *S, bool isTopLevelCode) {
@@ -4074,7 +4074,7 @@ void FindLocalVal::visitBraceStmt(BraceStmt *S, bool isTopLevelCode) {
40744074
std::function<void(Decl *)> visitDecl;
40754075
visitDecl = [&](Decl *D) {
40764076
if (auto *VD = dyn_cast<ValueDecl>(D))
4077-
checkValueDecl(VD, DeclVisibilityKind::LocalVariable);
4077+
checkValueDecl(VD, DeclVisibilityKind::LocalDecl);
40784078
D->visitAuxiliaryDecls(visitDecl);
40794079
};
40804080
for (auto elem : S->getElements()) {
@@ -4124,15 +4124,15 @@ void FindLocalVal::visitCaseStmt(CaseStmt *S) {
41244124
for (const auto &CLI : items) {
41254125
auto guard = CLI.getGuardExpr();
41264126
if (guard && isReferencePointInRange(guard->getSourceRange())) {
4127-
checkPattern(CLI.getPattern(), DeclVisibilityKind::LocalVariable);
4127+
checkPattern(CLI.getPattern(), DeclVisibilityKind::LocalDecl);
41284128
break;
41294129
}
41304130
}
41314131
}
41324132

41334133
if (!inPatterns && !items.empty()) {
41344134
for (auto *vd : S->getCaseBodyVariablesOrEmptyArray()) {
4135-
checkValueDecl(vd, DeclVisibilityKind::LocalVariable);
4135+
checkValueDecl(vd, DeclVisibilityKind::LocalDecl);
41364136
}
41374137
}
41384138
visit(S->getBody());

lib/IDE/CompletionLookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ CompletionLookup::getSemanticContext(const Decl *D, DeclVisibilityKind Reason,
394394
return *ForcedSemanticContext;
395395

396396
switch (Reason) {
397-
case DeclVisibilityKind::LocalVariable:
397+
case DeclVisibilityKind::LocalDecl:
398398
case DeclVisibilityKind::FunctionParameter:
399399
case DeclVisibilityKind::GenericParameter:
400400
return SemanticContextKind::Local;
@@ -2976,7 +2976,7 @@ void CompletionLookup::getGenericRequirementCompletions(
29762976
// qualified by the current type. Thus also suggest current self type so the
29772977
// user can do a memberwise lookup on it.
29782978
if (auto SelfType = typeContext->getSelfNominalTypeDecl()) {
2979-
addNominalTypeRef(SelfType, DeclVisibilityKind::LocalVariable,
2979+
addNominalTypeRef(SelfType, DeclVisibilityKind::LocalDecl,
29802980
DynamicLookupInfo());
29812981
}
29822982

lib/Sema/LookupVisibleDecls.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,12 @@ namespace llvm {
794794

795795
template <> struct DenseMapInfo<FoundDeclTy> {
796796
static inline FoundDeclTy getEmptyKey() {
797-
return FoundDeclTy{nullptr, DeclVisibilityKind::LocalVariable, {}};
797+
return FoundDeclTy{nullptr, DeclVisibilityKind::LocalDecl, {}};
798798
}
799799

800800
static inline FoundDeclTy getTombstoneKey() {
801801
return FoundDeclTy{reinterpret_cast<ValueDecl *>(0x1),
802-
DeclVisibilityKind::LocalVariable,
802+
DeclVisibilityKind::LocalDecl,
803803
{}};
804804
}
805805

@@ -988,7 +988,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
988988
VD->getFormalAccess() > OtherVD->getFormalAccess());
989989
if (preferVD) {
990990
FilteredResults.remove(
991-
FoundDeclTy(OtherVD, DeclVisibilityKind::LocalVariable, {}));
991+
FoundDeclTy(OtherVD, DeclVisibilityKind::LocalDecl, {}));
992992
FilteredResults.insert(DeclAndReason);
993993
*I = VD;
994994
}

0 commit comments

Comments
 (0)