Skip to content

Commit

Permalink
Rename ASTContext::addedExternalDecl() to addExternalDecl() and impro…
Browse files Browse the repository at this point in the history
…ve some comments, NFC
  • Loading branch information
slavapestov committed Jan 11, 2016
1 parent 9bdb7d3 commit c3dd77a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
9 changes: 5 additions & 4 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class ASTContext {
// Retrieve the declaration of Swift._stdlib_isOSVersionAtLeast.
FuncDecl *getIsOSVersionAtLeastDecl(LazyResolver *resolver) const;

/// \brief Look for the declaration with the given name within the
/// Look for the declaration with the given name within the
/// swift module.
void lookupInSwiftModule(StringRef name,
SmallVectorImpl<ValueDecl *> &results) const;
Expand All @@ -499,9 +499,10 @@ class ASTContext {
Type type,
LazyResolver *resolver) const;

/// \brief Notify all of the mutation listeners that the given declaration
/// was just added.
void addedExternalDecl(Decl *decl);
/// Add a declaration to a list of declarations that need to be emitted
/// as part of the current module or source file, but are otherwise not
/// nested within it.
void addExternalDecl(Decl *decl);

/// Add a cleanup function to be called when the ASTContext is deallocated.
void addCleanup(std::function<void(void)> cleanup);
Expand Down
6 changes: 3 additions & 3 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3597,9 +3597,9 @@ class AbstractStorageDecl : public ValueDecl {
/// to and may be overridden.
/// 2) When a stored property satisfies a protocol requirement, these
/// accessors end up as entries in the witness table.
/// 3) Perhaps someday these will be used by accesses outside of this
/// resilience domain, when the owning type is resilient.
///
/// 3) When a stored property is accessed outside of the storage
/// declaration's resilience domain, when the owning type or
/// global variable is resilient.
StoredWithTrivialAccessors,

/// This is a stored property with either a didSet specifier or a
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ bool ASTContext::hasArrayLiteralIntrinsics(LazyResolver *resolver) const {
&& getDeallocateUninitializedArray(resolver);
}

void ASTContext::addedExternalDecl(Decl *decl) {
void ASTContext::addExternalDecl(Decl *decl) {
ExternalDefinitions.insert(decl);
}

Expand Down
16 changes: 7 additions & 9 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ static FuncDecl *makeRawValueTrivialGetter(ClangImporter::Implementation &Impl,
/*implicit*/ true);
getterDecl->setBody(body);

// Add as an external definition.
C.addedExternalDecl(getterDecl);
C.addExternalDecl(getterDecl);

return getterDecl;
}
Expand Down Expand Up @@ -394,8 +393,7 @@ static FuncDecl *makeRawValueTrivialSetter(ClangImporter::Implementation &Impl,
/*implicit*/ true);
setterDecl->setBody(body);

// Add as an external definition.
C.addedExternalDecl(setterDecl);
C.addExternalDecl(setterDecl);

return setterDecl;
}
Expand Down Expand Up @@ -461,7 +459,7 @@ makeEnumRawValueConstructor(ClangImporter::Implementation &Impl,

ctorDecl->setBody(body);

C.addedExternalDecl(ctorDecl);
C.addExternalDecl(ctorDecl);

return ctorDecl;
}
Expand Down Expand Up @@ -516,7 +514,7 @@ static FuncDecl *makeEnumRawValueGetter(ClangImporter::Implementation &Impl,
/*implicit*/ true);

getterDecl->setBody(body);
C.addedExternalDecl(getterDecl);
C.addExternalDecl(getterDecl);
return getterDecl;
}

Expand Down Expand Up @@ -631,7 +629,7 @@ makeUnionFieldAccessors(ClangImporter::Implementation &Impl,
auto body = BraceStmt::create(C, SourceLoc(), ASTNode(ret), SourceLoc(),
/*implicit*/ true);
getterDecl->setBody(body);
C.addedExternalDecl(getterDecl);
C.addExternalDecl(getterDecl);
}

// Synthesize the setter body
Expand Down Expand Up @@ -665,7 +663,7 @@ makeUnionFieldAccessors(ClangImporter::Implementation &Impl,
auto body = BraceStmt::create(C, SourceLoc(), { initialize }, SourceLoc(),
/*implicit*/ true);
setterDecl->setBody(body);
C.addedExternalDecl(setterDecl);
C.addExternalDecl(setterDecl);
}

return { getterDecl, setterDecl };
Expand Down Expand Up @@ -5396,7 +5394,7 @@ void ClangImporter::Implementation::finishPendingActions() {
RegisteredExternalDecls.clear();
} else {
Decl *D = RegisteredExternalDecls.pop_back_val();
SwiftContext.addedExternalDecl(D);
SwiftContext.addExternalDecl(D);
if (auto typeResolver = getTypeResolver())
if (auto *nominal = dyn_cast<NominalTypeDecl>(D))
if (!nominal->hasDelayedMembers())
Expand Down
16 changes: 8 additions & 8 deletions lib/Sema/CodeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static FuncDecl *createMaterializeForSetPrototype(AbstractStorageDecl *storage,
// If the property came from ObjC, we need to register this as an external
// definition to be compiled.
if (needsToBeRegisteredAsExternalDecl(storage))
TC.Context.addedExternalDecl(materializeForSet);
TC.Context.addExternalDecl(materializeForSet);

return materializeForSet;
}
Expand Down Expand Up @@ -722,7 +722,7 @@ static void synthesizeTrivialGetter(FuncDecl *getter,

// Register the accessor as an external decl if the storage was imported.
if (needsToBeRegisteredAsExternalDecl(storage))
TC.Context.addedExternalDecl(getter);
TC.Context.addExternalDecl(getter);
}

/// Synthesize the body of a trivial setter.
Expand All @@ -745,7 +745,7 @@ static void synthesizeTrivialSetter(FuncDecl *setter,

// Register the accessor as an external decl if the storage was imported.
if (needsToBeRegisteredAsExternalDecl(storage))
TC.Context.addedExternalDecl(setter);
TC.Context.addExternalDecl(setter);
}

/// Build the result expression of a materializeForSet accessor.
Expand Down Expand Up @@ -800,7 +800,7 @@ static void synthesizeStoredMaterializeForSet(FuncDecl *materializeForSet,

// Register the accessor as an external decl if the storage was imported.
if (needsToBeRegisteredAsExternalDecl(storage))
TC.Context.addedExternalDecl(materializeForSet);
TC.Context.addExternalDecl(materializeForSet);
}

/// Does a storage decl currently lacking accessor functions require a
Expand Down Expand Up @@ -1161,7 +1161,7 @@ static void synthesizeComputedMaterializeForSet(FuncDecl *materializeForSet,

// Register the accessor as an external decl if the storage was imported.
if (needsToBeRegisteredAsExternalDecl(storage))
TC.Context.addedExternalDecl(materializeForSet);
TC.Context.addExternalDecl(materializeForSet);
}

/// Build a direct call to an addressor from within a
Expand Down Expand Up @@ -1338,10 +1338,10 @@ static void synthesizeAddressedMaterializeForSet(FuncDecl *materializeForSet,
materializeForSet->getAttrs().add(new (ctx) TransparentAttr(IsImplicit));

TC.typeCheckDecl(materializeForSet, true);

// Register the accessor as an external decl if the storage was imported.
if (needsToBeRegisteredAsExternalDecl(storage))
TC.Context.addedExternalDecl(materializeForSet);
TC.Context.addExternalDecl(materializeForSet);
}

void swift::synthesizeMaterializeForSet(FuncDecl *materializeForSet,
Expand Down Expand Up @@ -1917,7 +1917,7 @@ ConstructorDecl *swift::createImplicitConstructor(TypeChecker &tc,
// If the struct in which this constructor is being added was imported,
// add it as an external definition.
if (decl->hasClangNode()) {
tc.Context.addedExternalDecl(ctor);
tc.Context.addExternalDecl(ctor);
}

return ctor;
Expand Down
10 changes: 8 additions & 2 deletions lib/Sema/DerivedConformanceEquatableHashable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ deriveEquatable_enum_eq(TypeChecker &tc, Decl *parentDecl, EnumDecl *enumDecl) {
eqDecl->setAccessibility(std::max(enumDecl->getFormalAccess(),
Accessibility::Internal));

// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
// normally.
if (enumDecl->hasClangNode())
tc.Context.addedExternalDecl(eqDecl);
tc.Context.addExternalDecl(eqDecl);

// Since it's an operator we insert the decl after the type at global scope.
insertOperatorDecl(C, cast<IterableDeclContext>(parentDecl), eqDecl);
Expand Down Expand Up @@ -398,8 +401,11 @@ deriveHashable_enum_hashValue(TypeChecker &tc, Decl *parentDecl,
getterDecl->setInterfaceType(interfaceType);
getterDecl->setAccessibility(enumDecl->getFormalAccess());

// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
// normally.
if (enumDecl->hasClangNode())
tc.Context.addedExternalDecl(getterDecl);
tc.Context.addExternalDecl(getterDecl);

// Create the property.
VarDecl *hashValueDecl = new (C) VarDecl(/*static*/ false,
Expand Down
5 changes: 4 additions & 1 deletion lib/Sema/DerivedConformanceRawRepresentable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,11 @@ static ConstructorDecl *deriveRawRepresentable_init(TypeChecker &tc,
initDecl->setInitializerInterfaceType(initIfaceType);
initDecl->setAccessibility(enumDecl->getFormalAccess());

// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
// normally.
if (enumDecl->hasClangNode())
tc.Context.addedExternalDecl(initDecl);
tc.Context.addExternalDecl(initDecl);

cast<IterableDeclContext>(parentDecl)->addMember(initDecl);
return initDecl;
Expand Down
5 changes: 4 additions & 1 deletion lib/Sema/DerivedConformances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,11 @@ FuncDecl *DerivedConformance::declareDerivedPropertyGetter(TypeChecker &tc,
getterDecl->setInterfaceType(interfaceType);
getterDecl->setAccessibility(typeDecl->getFormalAccess());

// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
// normally.
if (typeDecl->hasClangNode())
tc.Context.addedExternalDecl(getterDecl);
tc.Context.addExternalDecl(getterDecl);

return getterDecl;
}
Expand Down

0 comments on commit c3dd77a

Please sign in to comment.