Split AccessorDecl out from FuncDecl. NFC.

This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
This commit is contained in:
John McCall
2018-01-11 00:20:05 -05:00
parent 7dc6d2ce30
commit 7f0f8830cd
85 changed files with 2025 additions and 1585 deletions

View File

@@ -360,10 +360,10 @@ SILFunction *SILModule::getOrCreateFunction(SILLocation loc,
if (constant.isForeign && decl->hasClangNode())
F->setClangNodeOwner(decl);
if (auto *FDecl = dyn_cast<FuncDecl>(decl)) {
if (auto *StorageDecl = FDecl->getAccessorStorageDecl())
// Add attributes for e.g. computed properties.
addFunctionAttributes(F, StorageDecl->getAttrs(), *this);
if (auto *accessor = dyn_cast<AccessorDecl>(decl)) {
auto *storage = accessor->getStorage();
// Add attributes for e.g. computed properties.
addFunctionAttributes(F, storage->getAttrs(), *this);
}
addFunctionAttributes(F, decl->getAttrs(), *this);
}