[AST] Introduce DeclContext::getLocalContext(), which returns the first local parent context.

Swift SVN r8775
This commit is contained in:
Argyrios Kyrtzidis
2013-09-30 15:43:08 +00:00
parent ae00d91bb1
commit bded52492e
2 changed files with 15 additions and 0 deletions

View File

@@ -106,6 +106,14 @@ GenericParamList *DeclContext::getGenericParamsOfContext() const {
llvm_unreachable("Unhandled declaration context kind");
}
DeclContext *DeclContext::getLocalContext() {
if (isLocalContext())
return this;
if (isModuleContext() || isExtensionContext())
return nullptr;
return getParent()->getLocalContext();
}
Module *DeclContext::getParentModule() const {
const DeclContext *DC = this;
while (!DC->isModuleContext())