[Scope map] Query the declarations introduced by a given AST scope.

Introduce an operation that produces the set of local declarations
that are newly introduced by a given AST scope. This is a building
block of unqualified name lookup, which walks upward in the tree
(e.g., from children to parents) looking for declarations that have
been made visible at each step.
This commit is contained in:
Doug Gregor
2016-09-03 21:52:12 -07:00
parent caa173b27a
commit 311fc55bdb
4 changed files with 114 additions and 2 deletions

View File

@@ -814,6 +814,20 @@ static bool performCompile(CompilerInstance &Instance,
if (auto dc = locScope->getDeclContext()) {
dc->printContext(llvm::errs());
}
// Grab the local bindings introduced by this scope.
auto localBindings = locScope->getLocalBindings();
if (!localBindings.empty()) {
llvm::errs() << "Local bindings: ";
interleave(localBindings.begin(), localBindings.end(),
[&](ValueDecl *value) {
llvm::errs() << value->getFullName();
},
[&]() {
llvm::errs() << " ";
});
llvm::errs() << "\n";
}
}
llvm::errs() << "***Complete scope map***\n";