mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user