Update lldb's ExternalASTSources to match Clang r244161.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 6 Aug 2015 05:13:41 +0000 (05:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 6 Aug 2015 05:13:41 +0000 (05:13 +0000)
llvm-svn: 244194

lldb/include/lldb/Expression/ClangASTSource.h
lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
lldb/source/Expression/ClangASTSource.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp

index 46140d2..e47cf6f 100644 (file)
@@ -111,15 +111,15 @@ public:
     ///     The DeclContext being searched.
     ///
     /// @param[in] isKindWeWant
-    ///     If non-NULL, a callback function that returns true given the
+    ///     A callback function that returns true given the
     ///     DeclKinds of desired Decls, and false otherwise.
     ///
     /// @param[in] Decls
     ///     A vector that is filled in with matching Decls.
     //------------------------------------------------------------------
-    clang::ExternalLoadResult FindExternalLexicalDecls(const clang::DeclContext *DC,
-                                                       bool (*isKindWeWant)(clang::Decl::Kind),
-                                                       llvm::SmallVectorImpl<clang::Decl *> &Decls) override;
+    void FindExternalLexicalDecls(
+        const clang::DeclContext *DC, llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+        llvm::SmallVectorImpl<clang::Decl *> &Decls) override;
 
     //------------------------------------------------------------------
     /// Specify the layout of the contents of a RecordDecl.
@@ -249,11 +249,12 @@ public:
             return m_original.FindExternalVisibleDeclsByName(DC, Name);
         }
 
-        clang::ExternalLoadResult
-        FindExternalLexicalDecls(const clang::DeclContext *DC, bool (*isKindWeWant)(clang::Decl::Kind),
+        void
+        FindExternalLexicalDecls(const clang::DeclContext *DC,
+                                 llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
                                  llvm::SmallVectorImpl<clang::Decl *> &Decls) override
         {
-            return m_original.FindExternalLexicalDecls(DC, isKindWeWant, Decls);
+            return m_original.FindExternalLexicalDecls(DC, IsKindWeWant, Decls);
         }
 
         void
index 41bb235..cbc56fe 100644 (file)
@@ -100,15 +100,6 @@ public:
         return;
     }
 
-    clang::ExternalLoadResult
-    FindExternalLexicalDecls(const clang::DeclContext *decl_ctx, bool (*isKindWeWant)(clang::Decl::Kind),
-                             llvm::SmallVectorImpl<clang::Decl *> &decls) override
-    {
-        // This is used to support iterating through an entire lexical context,
-        // which isn't something the debugger should ever need to do.
-        return clang::ELR_Failure;
-    }
-
     bool FindExternalVisibleDeclsByName(const clang::DeclContext *decl_ctx, clang::DeclarationName decl_name) override;
 
     void CompleteType(clang::TagDecl *tag_decl) override;
index 3988cd6..32fbb88 100644 (file)
@@ -419,9 +419,9 @@ ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_de
     return complete_iface_decl;
 }
 
-clang::ExternalLoadResult
+void
 ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
-                                          bool (*predicate)(Decl::Kind),
+                                          llvm::function_ref<bool(Decl::Kind)> predicate,
                                           llvm::SmallVectorImpl<Decl*> &decls)
 {
     ClangASTMetrics::RegisterLexicalQuery();
@@ -431,11 +431,11 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
     const Decl *context_decl = dyn_cast<Decl>(decl_context);
 
     if (!context_decl)
-        return ELR_Failure;
+        return;
 
     auto iter = m_active_lexical_decls.find(context_decl);
     if (iter != m_active_lexical_decls.end())
-        return ELR_Failure;
+        return;
     m_active_lexical_decls.insert(context_decl);
     ScopedLexicalDeclEraser eraser(m_active_lexical_decls, context_decl);
 
@@ -445,29 +445,26 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
     if (log)
     {
         if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
-            log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' (%sDecl*)%p with %s predicate",
+            log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' (%sDecl*)%p",
                         current_id, static_cast<void*>(m_ast_context),
                         context_named_decl->getNameAsString().c_str(),
                         context_decl->getDeclKindName(),
-                        static_cast<const void*>(context_decl),
-                        (predicate ? "non-null" : "null"));
+                        static_cast<const void*>(context_decl));
         else if(context_decl)
-            log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in (%sDecl*)%p with %s predicate",
+            log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in (%sDecl*)%p",
                         current_id, static_cast<void*>(m_ast_context),
                         context_decl->getDeclKindName(),
-                        static_cast<const void*>(context_decl),
-                        (predicate ? "non-null" : "null"));
+                        static_cast<const void*>(context_decl));
         else
-            log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context with %s predicate",
-                        current_id, static_cast<const void*>(m_ast_context),
-                        (predicate ? "non-null" : "null"));
+            log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context",
+                        current_id, static_cast<const void*>(m_ast_context));
     }
 
     Decl *original_decl = NULL;
     ASTContext *original_ctx = NULL;
 
     if (!m_ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx))
-        return ELR_Failure;
+        return;
 
     if (log)
     {
@@ -501,7 +498,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
     const DeclContext *original_decl_context = dyn_cast<DeclContext>(original_decl);
 
     if (!original_decl_context)
-        return ELR_Failure;
+        return;
 
     for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
          iter != original_decl_context->decls_end();
@@ -509,7 +506,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
     {
         Decl *decl = *iter;
 
-        if (!predicate || predicate(decl->getKind()))
+        if (predicate(decl->getKind()))
         {
             if (log)
             {
@@ -532,8 +529,6 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
                 m_ast_importer->RequireCompleteType(copied_field_type);
             }
 
-            decls.push_back(copied_decl);
-
             DeclContext *decl_context_non_const = const_cast<DeclContext *>(decl_context);
 
             if (copied_decl->getDeclContext() != decl_context)
@@ -548,7 +543,7 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
         }
     }
 
-    return ELR_AlreadyLoaded;
+    return;
 }
 
 void
index 9b4fe4f..088df76 100644 (file)
@@ -69,13 +69,6 @@ public:
         return false;
     }
 
-    clang::ExternalLoadResult
-    FindExternalLexicalDecls(const clang::DeclContext *DC, bool (*isKindWeWant)(clang::Decl::Kind),
-                             llvm::SmallVectorImpl<clang::Decl *> &Decls) override
-    {
-        return clang::ELR_Success;
-    }
-
     void
     CompleteType(clang::TagDecl *tag_decl) override
     {