Merge remote-tracking branch 'origin/master' into master-next

This commit is contained in:
swift-ci
2019-10-10 13:50:08 -07:00
44 changed files with 1104 additions and 174 deletions

View File

@@ -686,6 +686,32 @@ TypeDecl *SourceFile::lookupLocalType(llvm::StringRef mangledName) const {
return nullptr;
}
Optional<BasicDeclLocs>
SourceFile::getBasicLocsForDecl(const Decl *D) const {
auto *FileCtx = D->getDeclContext()->getModuleScopeContext();
assert(FileCtx == this && "D doesn't belong to this source file");
if (FileCtx != this) {
// D doesn't belong to this file. This shouldn't happen in practice.
return None;
}
if (D->getLoc().isInvalid())
return None;
SourceManager &SM = getASTContext().SourceMgr;
BasicDeclLocs Result;
Result.SourceFilePath = SM.getDisplayNameForLoc(D->getLoc());
auto setLineColumn = [&SM](LineColumn &Home, SourceLoc Loc) {
if (Loc.isValid()) {
std::tie(Home.Line, Home.Column) = SM.getLineAndColumn(Loc);
}
};
#define SET(X) setLineColumn(Result.X, D->get##X());
SET(Loc)
SET(StartLoc)
SET(EndLoc)
#undef SET
return Result;
}
void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
// FIXME: Should this do extra access control filtering?
FORWARD(getDisplayDecls, (Results));