Skip to content

Commit 08485d4

Browse files
committed
formatting
1 parent 671533f commit 08485d4

File tree

6 files changed

+45
-43
lines changed

6 files changed

+45
-43
lines changed

Diff for: include/swift/AST/AccessScope.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ class AccessScope {
2828
/// <DeclContext*, bool> pair to determine the scope, as shown
2929
/// in the table below.
3030
///
31-
/// <DeclContext*, bool> AccessScope AccessLevel
32-
/// --------------------------------------------
33-
/// <nullptr, false> Public public or open
34-
/// <nullptr, true> Public public `@_spi`
35-
/// <PackageUnit*, _> Package package
36-
/// <ModuleDecl*, _> Module internal
37-
/// <FileUnit*, false> FileScope fileprivate
38-
/// <FileUnit*, true> Private private
31+
/// <DeclContext*, bool> AccessScope AccessLevel
32+
/// ----------------------------------------------------------------
33+
/// <nullptr, false> Public public or open
34+
/// <nullptr, true> Public public `@_spi`
35+
/// <PackageUnit*, _> Package package
36+
/// <ModuleDecl*, _> Module internal
37+
/// <FileUnit*, false> FileScope fileprivate
38+
/// <FileUnit*, true> Private private
3939
///
4040
/// For example, if a decl with `public` access level is referenced outside of
4141
/// its defining module, it will be maped to the <nullptr, false> pair during
@@ -84,8 +84,8 @@ class AccessScope {
8484
/// child of the other.
8585
/// 2. This function does _not_ check the restrictiveness of the _access
8686
/// level_ between two decls.
87-
/// 3. The DeclContext of this (use site) may not be null even if the use site has
88-
/// a `public` access level.
87+
/// 3. The DeclContext of this (use site) may not be null even if the use site
88+
/// has a `public` access level.
8989
///
9090
/// Here's an example while typechecking a file with the following code.
9191
///
@@ -96,12 +96,12 @@ class AccessScope {
9696
/// public func myFunc(_ arg: OtherModule.Foo) {}
9797
/// ```
9898
///
99-
/// The use site of `Foo`is a function `myFunc`, and its DeclContext is non-null
100-
/// (FileUnit) even though the function decl itself has a `public` access level.
101-
/// When `isChildOf` is called, the argument passed in is a pair <nullptr,
102-
/// false> created in \c getAccessScopeForFormalAccess based on the access
103-
/// level of the decl `Foo`. Since FileUnit is a child of nullptr in the DeclContext
104-
/// hierarchy (described above), it returns true.
99+
/// The use site of `Foo`is a function `myFunc`, and its DeclContext is
100+
/// non-null (FileUnit) even though the function decl itself has a `public`
101+
/// access level. When `isChildOf` is called, the argument passed in is a pair
102+
/// <nullptr, false> created in \c getAccessScopeForFormalAccess based on the
103+
/// access level of the decl `Foo`. Since FileUnit is a child of nullptr in
104+
/// the DeclContext hierarchy (described above), it returns true.
105105
///
106106
/// \see AccessScope::getAccessScopeForFormalAccess
107107
/// \see AccessScope::checkAccessUsingAccessScope
@@ -114,7 +114,7 @@ class AccessScope {
114114
return allowsPrivateAccess(getDeclContext(), AS.getDeclContext());
115115
else
116116
return AS.isPublic();
117-
} else {// It's public, so can't be a child of the argument scope
117+
} else { // It's public, so can't be a child of the argument scope
118118
return false;
119119
}
120120
}

Diff for: include/swift/AST/DeclContext.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ struct FragileFunctionKind {
230230
/// macro context, please see GenericContext for how to minimize new entries in
231231
/// the ASTHierarchy enum below.
232232
///
233-
/// The hierarchy between DeclContext subclasses is set in their ctors. For example,
234-
/// FileUnit ctor takes ModuleDecl as its parent DeclContext. The hierarchy from the most
235-
/// to least restrictive order is:
236-
/// decl/expr (e.g. ClassDecl) -> FileUnit -> ModuleDecl -> PackageUnit -> nullptr
233+
/// The hierarchy between DeclContext subclasses is set in their ctors. For
234+
/// example, FileUnit ctor takes ModuleDecl as its parent DeclContext. The
235+
/// hierarchy from the most to least restrictive order is:
236+
/// decl/expr (e.g. ClassDecl) -> FileUnit -> ModuleDecl -> PackageUnit -> nullptr
237237
///
238-
/// There's an exception, however; the parent of ModuleDecl is set nullptr, not set to
239-
/// PackageUnit; ModuleDecl has a pointer to PackageUnit as its field, and it is treated as
240-
/// the enclosing scope of ModuleDecl.
238+
/// There's an exception, however; the parent of ModuleDecl is set nullptr, not
239+
/// set to PackageUnit; ModuleDecl has a pointer to PackageUnit as its field,
240+
/// and it is treated as the enclosing scope of ModuleDecl.
241241
class alignas(1 << DeclContextAlignInBits) DeclContext
242242
: public ASTAllocated<DeclContext> {
243243
enum class ASTHierarchy : unsigned {
@@ -332,7 +332,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
332332
bool isLocalContext() const {
333333
return getContextKind() <= DeclContextKind::Last_LocalDeclContextKind;
334334
}
335-
335+
336336
/// \returns true if this is a package context
337337
LLVM_READONLY
338338
bool isPackageContext() const; // see swift/AST/Module.h

Diff for: include/swift/AST/Module.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ class ModuleDecl
343343
return new (ctx) ModuleDecl(name, ctx, importInfo);
344344
}
345345

346-
static ModuleDecl *
347-
createMainModule(ASTContext &ctx, Identifier name, ImplicitImportInfo iinfo) {
346+
static ModuleDecl *createMainModule(ASTContext &ctx, Identifier name,
347+
ImplicitImportInfo iinfo) {
348348
auto *Mod = ModuleDecl::create(name, ctx, iinfo);
349349
Mod->Bits.ModuleDecl.IsMainModule = true;
350350
return Mod;

Diff for: lib/AST/Decl.cpp

+15-14
Original file line numberDiff line numberDiff line change
@@ -3926,7 +3926,7 @@ getAccessScopeForFormalAccess(const ValueDecl *VD,
39263926
case AccessLevel::Internal:
39273927
return AccessScope(resultDC->getParentModule());
39283928
case AccessLevel::Package: {
3929-
auto pkg = resultDC->getPackageContext(/*lookupIfNotCurrent*/true);
3929+
auto pkg = resultDC->getPackageContext(/*lookupIfNotCurrent*/ true);
39303930
if (!pkg) {
39313931
auto &d = VD->getASTContext().Diags;
39323932
d.diagnose(VD->getLoc(), diag::access_control_requires_package_name);
@@ -3966,18 +3966,19 @@ ValueDecl::getFormalAccessScope(const DeclContext *useDC,
39663966
/// The use site of `Foo`is a function `myFunc`, and its DeclContext (useDC)
39673967
/// is FileUnit. The call \c getAccessScopeForFormalAccess inside this function
39683968
/// to get the access scope of`Foo` returns a public scope based on its `public`
3969-
/// access level, which is a wrapper around a nullptr DeclContext. Note that the useDC
3970-
/// is still non-null (FileUnit) even though the use site itself also has a `public` acess
3971-
/// level.
3969+
/// access level, which is a wrapper around a nullptr DeclContext. Note that the
3970+
/// useDC is still non-null (FileUnit) even though the use site itself also has
3971+
/// a `public` acess level.
39723972
///
3973-
/// The `isChildOf` call compares the DeclContext hierarchy of the use site (useDC)
3974-
/// and the decl (VD) site, and returns true in this case, since FileUnit is a child of nullptr
3975-
/// based on the DeclContext hierarchy. The hierarchy is created when subclasses of
3976-
/// DeclContext such as FileUnit or ModuleDecl are constructed. For example, FileUnit
3977-
/// ctor takes ModuleDecl as its parent DeclContext. There's an exception, however; the
3978-
/// parent of ModuleDecl is nullptr, not set to PackageUnit; ModuleDecl has a pointer to
3979-
/// PackageUnit as its field, and it is treated as the enclosing scope of ModuleDecl in the
3980-
/// `isChildOf` call.
3973+
/// The `isChildOf` call compares the DeclContext hierarchy of the use site
3974+
/// (useDC) and the decl (VD) site, and returns true in this case, since
3975+
/// FileUnit is a child of nullptr based on the DeclContext hierarchy. The
3976+
/// hierarchy is created when subclasses of DeclContext such as FileUnit or
3977+
/// ModuleDecl are constructed. For example, FileUnit ctor takes ModuleDecl as
3978+
/// its parent DeclContext. There's an exception, however; the parent of
3979+
/// ModuleDecl is nullptr, not set to PackageUnit; ModuleDecl has a pointer to
3980+
/// PackageUnit as its field, and it is treated as the enclosing scope of
3981+
/// ModuleDecl in the `isChildOf` call.
39813982
///
39823983
/// \see DeclContext::ASTHierarchy
39833984
/// \see AccessScope::getAccessScopeForFormalAccess
@@ -4113,8 +4114,8 @@ static bool checkAccess(const DeclContext *useDC, const ValueDecl *VD,
41134114
return useSF && useSF->hasTestableOrPrivateImport(access, sourceModule);
41144115
}
41154116
case AccessLevel::Package: {
4116-
auto srcPkg = sourceDC->getPackageContext(/*lookupIfNotCurrent*/true);
4117-
auto usePkg = useDC->getPackageContext(/*lookupIfNotCurrent*/true);
4117+
auto srcPkg = sourceDC->getPackageContext(/*lookupIfNotCurrent*/ true);
4118+
auto usePkg = useDC->getPackageContext(/*lookupIfNotCurrent*/ true);
41184119
return usePkg->isSamePackageAs(srcPkg);
41194120
}
41204121
case AccessLevel::Public:

Diff for: lib/AST/DeclContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ bool AccessScope::allowsPrivateAccess(const DeclContext *useDC, const DeclContex
12891289
// has internal or less acl, check if it belongs to
12901290
// the same package as the decl site's to allow access.
12911291
if (auto srcPkg = sourceDC->getPackageContext()) {
1292-
if (auto usePkg = useDC->getPackageContext(/*lookupIfNotCurrent*/true)) {
1292+
if (auto usePkg = useDC->getPackageContext(/*lookupIfNotCurrent*/ true)) {
12931293
return usePkg->isSamePackageAs(srcPkg);
12941294
}
12951295
}

Diff for: lib/Sema/TypeCheckAccess.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,8 @@ static void checkExtensionGenericParamAccess(const ExtensionDecl *ED) {
22852285
desiredAccessScope = AccessScope(ED->getModuleContext());
22862286
break;
22872287
case AccessLevel::Package:
2288-
desiredAccessScope = AccessScope(ED->getPackageContext(/*lookupIfNotCurrent*/true));
2288+
desiredAccessScope =
2289+
AccessScope(ED->getPackageContext(/*lookupIfNotCurrent*/ true));
22892290
break;
22902291
case AccessLevel::Public:
22912292
case AccessLevel::Open:

0 commit comments

Comments
 (0)