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:
@@ -644,6 +644,12 @@ void ModuleDecl::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) const {
|
||||
FORWARD(getTopLevelDecls, (Results));
|
||||
}
|
||||
|
||||
void ModuleDecl::getTopLevelDeclsWhereAttributesMatch(
|
||||
SmallVectorImpl<Decl*> &Results,
|
||||
llvm::function_ref<bool(DeclAttributes)> matchAttributes) const {
|
||||
FORWARD(getTopLevelDeclsWhereAttributesMatch, (Results, matchAttributes));
|
||||
}
|
||||
|
||||
void SourceFile::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) const {
|
||||
Results.append(Decls.begin(), Decls.end());
|
||||
}
|
||||
@@ -1873,6 +1879,22 @@ void *FileUnit::operator new(size_t Bytes, ASTContext &C, unsigned Alignment) {
|
||||
return C.Allocate(Bytes, Alignment);
|
||||
}
|
||||
|
||||
void FileUnit::getTopLevelDeclsWhereAttributesMatch(
|
||||
SmallVectorImpl<Decl*> &Results,
|
||||
llvm::function_ref<bool(DeclAttributes)> matchAttributes) const {
|
||||
auto prevSize = Results.size();
|
||||
getTopLevelDecls(Results);
|
||||
|
||||
// Filter out unwanted decls that were just added to Results.
|
||||
// Note: We could apply this check in all implementations of
|
||||
// getTopLevelDecls instead or in everything that creates a Decl.
|
||||
auto newEnd = std::remove_if(Results.begin() + prevSize, Results.end(),
|
||||
[&matchAttributes](const Decl *D) -> bool {
|
||||
return !matchAttributes(D->getAttrs());
|
||||
});
|
||||
Results.erase(newEnd, Results.end());
|
||||
}
|
||||
|
||||
StringRef LoadedFile::getFilename() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user