diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-05 22:41:45 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-05 22:41:45 +0000 |
commit | 3cb15729aff241e28c9854bd09609fb74e7bac37 (patch) | |
tree | a51bd54acbb78d140ec33b26f1779ad74c5bdf6e /clang/lib/AST | |
parent | ae0d4365454456203a6f284c5d0e6ed994883c86 (diff) | |
download | bcm5719-llvm-3cb15729aff241e28c9854bd09609fb74e7bac37.tar.gz bcm5719-llvm-3cb15729aff241e28c9854bd09609fb74e7bac37.zip |
function_ref-ize ExternalASTSource::FindExternalLexicalDecl and remove its
useless return value. Switch to using it directly when completing the
redeclaration chain for an anonymous declaration, and reduce the set of
declarations that we load in the process to just those of the right kind.
llvm-svn: 244161
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 18 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 9 | ||||
-rw-r--r-- | clang/lib/AST/ExternalASTSource.cpp | 14 |
3 files changed, 10 insertions, 31 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 9d44a69e91d..ab96094ba82 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3639,10 +3639,6 @@ bool RecordDecl::isMsStruct(const ASTContext &C) const { return hasAttr<MSStructAttr>() || C.getLangOpts().MSBitfields == 1; } -static bool isFieldOrIndirectField(Decl::Kind K) { - return FieldDecl::classofKind(K) || IndirectFieldDecl::classofKind(K); -} - void RecordDecl::LoadFieldsFromExternalStorage() const { ExternalASTSource *Source = getASTContext().getExternalSource(); assert(hasExternalLexicalStorage() && Source && "No external storage?"); @@ -3651,16 +3647,10 @@ void RecordDecl::LoadFieldsFromExternalStorage() const { ExternalASTSource::Deserializing TheFields(Source); SmallVector<Decl*, 64> Decls; - LoadedFieldsFromExternalStorage = true; - switch (Source->FindExternalLexicalDecls(this, isFieldOrIndirectField, - Decls)) { - case ELR_Success: - break; - - case ELR_AlreadyLoaded: - case ELR_Failure: - return; - } + LoadedFieldsFromExternalStorage = true; + Source->FindExternalLexicalDecls(this, [](Decl::Kind K) { + return FieldDecl::classofKind(K) || IndirectFieldDecl::classofKind(K); + }, Decls); #ifndef NDEBUG // Check that all decls we got were FieldDecls. diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index e772f195336..40b135f9202 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1059,14 +1059,7 @@ DeclContext::LoadLexicalDeclsFromExternalStorage() const { // Load the external declarations, if any. SmallVector<Decl*, 64> Decls; ExternalLexicalStorage = false; - switch (Source->FindExternalLexicalDecls(this, Decls)) { - case ELR_Success: - break; - - case ELR_Failure: - case ELR_AlreadyLoaded: - return false; - } + Source->FindExternalLexicalDecls(this, Decls); if (Decls.empty()) return false; diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp index 1c82c355134..8a44c05dbb7 100644 --- a/clang/lib/AST/ExternalASTSource.cpp +++ b/clang/lib/AST/ExternalASTSource.cpp @@ -92,17 +92,13 @@ ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC, return false; } -void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) { -} +void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {} -ExternalLoadResult -ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC, - bool (*isKindWeWant)(Decl::Kind), - SmallVectorImpl<Decl*> &Result) { - return ELR_AlreadyLoaded; -} +void ExternalASTSource::FindExternalLexicalDecls( + const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant, + SmallVectorImpl<Decl *> &Result) {} -void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const { } +void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {} uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) { uint32_t OldGeneration = CurrentGeneration; |