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

This commit is contained in:
Joe Groff
2019-12-10 12:46:41 -08:00
642 changed files with 27717 additions and 11572 deletions

View File

@@ -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 "";
}