[Lldb-commits] [lldb] r123614 - in /lldb/trunk: include/lldb/Symbol/ClangExternalASTSourceCallbacks.h source/Symbol/ClangExternalASTSourceCallbacks.cpp

Greg Clayton gclayton at apple.com
Sun Jan 16 20:19:52 PST 2011


Author: gclayton
Date: Sun Jan 16 22:19:51 2011
New Revision: 123614

URL: http://llvm.org/viewvc/llvm-project?rev=123614&view=rev
Log:
Added missing source files.


Added:
    lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
    lldb/trunk/source/Symbol/ClangExternalASTSourceCallbacks.cpp

Added: lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h?rev=123614&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h (added)
+++ lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h Sun Jan 16 22:19:51 2011
@@ -0,0 +1,171 @@
+//===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangExternalASTSourceCallbacks_h_
+#define liblldb_ClangExternalASTSourceCallbacks_h_
+
+// C Includes
+// C++ Includes
+#include <string>
+#include <vector>
+#include <memory>
+#include <stdint.h>
+
+// Other libraries and framework includes
+
+// Clang headers like to use NDEBUG inside of them to enable/disable debug 
+// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
+// or another. This is bad because it means that if clang was built in release
+// mode, it assumes that you are building in release mode which is not always
+// the case. You can end up with functions that are defined as empty in header
+// files when NDEBUG is not defined, and this can cause link errors with the
+// clang .a files that you have since you might be missing functions in the .a
+// file. So we have to define NDEBUG when including clang headers to avoid any
+// mismatches. This is covered by rdar://problem/8691220
+
+#ifndef NDEBUG
+#define LLDB_DEFINED_NDEBUG_FOR_CLANG
+#define NDEBUG
+// Need to include assert.h so it is as clang would expect it to be (disabled)
+#include <assert.h>
+#endif
+
+#include "clang/AST/ExternalASTSource.h"
+
+#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
+#undef NDEBUG
+#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
+// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
+#include <assert.h>
+#endif
+
+// Project includes
+#include "lldb/lldb-enumerations.h"
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Symbol/ClangASTType.h"
+
+namespace lldb_private {
+
+class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource 
+{
+public:
+
+    typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
+    typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
+
+
+    ClangExternalASTSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
+                                     CompleteObjCInterfaceDeclCallback objc_decl_callback,
+                                     void *callback_baton) :
+        m_callback_tag_decl (tag_decl_callback),
+        m_callback_objc_decl (objc_decl_callback),
+        m_callback_baton (callback_baton)
+    {
+    }
+
+    //------------------------------------------------------------------
+    // clang::ExternalASTSource
+    //------------------------------------------------------------------
+
+    virtual clang::Decl *
+    GetExternalDecl (uint32_t ID)
+    {
+        // This method only needs to be implemented if the AST source ever
+        // passes back decl sets as VisibleDeclaration objects.
+        return 0; 
+    }
+    
+    virtual clang::Stmt *
+    GetExternalDeclStmt (uint64_t Offset)
+    {
+        // This operation is meant to be used via a LazyOffsetPtr.  It only
+        // needs to be implemented if the AST source uses methods like
+        // FunctionDecl::setLazyBody when building decls.
+        return 0; 
+    }
+	
+    virtual clang::Selector 
+    GetExternalSelector (uint32_t ID)
+    {
+        // This operation only needs to be implemented if the AST source
+        // returns non-zero for GetNumKnownSelectors().
+        return clang::Selector();
+    }
+
+	virtual uint32_t
+    GetNumExternalSelectors()
+    {
+        return 0;
+    }
+    
+    virtual clang::CXXBaseSpecifier *
+    GetExternalCXXBaseSpecifiers(uint64_t Offset)
+    {
+        return NULL; 
+    }
+	
+    virtual void 
+    MaterializeVisibleDecls (const clang::DeclContext *decl_ctx)
+    {
+        return;
+    }
+	
+	virtual bool 
+    FindExternalLexicalDecls (const clang::DeclContext *decl_ctx,
+                              bool (*isKindWeWant)(clang::Decl::Kind),
+                              llvm::SmallVectorImpl<clang::Decl*> &decls)
+    {
+        // This is used to support iterating through an entire lexical context,
+        // which isn't something the debugger should ever need to do.
+        // true is for error, that's good enough for me
+        return true;
+    }
+    
+    virtual clang::DeclContextLookupResult 
+    FindExternalVisibleDeclsByName (const clang::DeclContext *decl_ctx,
+                                    clang::DeclarationName decl_name);
+    
+    virtual void
+    CompleteType (clang::TagDecl *tag_decl);
+    
+    virtual void
+    CompleteType (clang::ObjCInterfaceDecl *objc_decl);
+
+    void
+    SetExternalSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
+                                CompleteObjCInterfaceDeclCallback objc_decl_callback,
+                                void *callback_baton)
+    {
+        m_callback_tag_decl = tag_decl_callback;
+        m_callback_objc_decl = objc_decl_callback;
+        m_callback_baton = callback_baton;    
+    }
+
+    void
+    RemoveExternalSourceCallbacks (void *callback_baton)
+    {
+        if (callback_baton == m_callback_baton)
+        {
+            m_callback_tag_decl = NULL;
+            m_callback_objc_decl = NULL;
+        }
+    }
+
+protected:
+    //------------------------------------------------------------------
+    // Classes that inherit from ClangExternalASTSourceCallbacks can see and modify these
+    //------------------------------------------------------------------
+    CompleteTagDeclCallback                 m_callback_tag_decl;
+    CompleteObjCInterfaceDeclCallback       m_callback_objc_decl;
+    void *                                  m_callback_baton;
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_ClangExternalASTSourceCallbacks_h_

Added: lldb/trunk/source/Symbol/ClangExternalASTSourceCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangExternalASTSourceCallbacks.cpp?rev=123614&view=auto
==============================================================================
--- lldb/trunk/source/Symbol/ClangExternalASTSourceCallbacks.cpp (added)
+++ lldb/trunk/source/Symbol/ClangExternalASTSourceCallbacks.cpp Sun Jan 16 22:19:51 2011
@@ -0,0 +1,125 @@
+//===-- ClangExternalASTSourceCallbacks.cpp ---------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+
+// Clang headers like to use NDEBUG inside of them to enable/disable debug 
+// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
+// or another. This is bad because it means that if clang was built in release
+// mode, it assumes that you are building in release mode which is not always
+// the case. You can end up with functions that are defined as empty in header
+// files when NDEBUG is not defined, and this can cause link errors with the
+// clang .a files that you have since you might be missing functions in the .a
+// file. So we have to define NDEBUG when including clang headers to avoid any
+// mismatches. This is covered by rdar://problem/8691220
+
+#ifndef NDEBUG
+#define LLDB_DEFINED_NDEBUG_FOR_CLANG
+#define NDEBUG
+// Need to include assert.h so it is as clang would expect it to be (disabled)
+#include <assert.h>
+#endif
+
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclarationName.h"
+
+#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
+#undef NDEBUG
+#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
+// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
+#include <assert.h>
+#endif
+
+#include "lldb/Core/Log.h"
+
+using namespace clang;
+using namespace lldb_private;
+
+clang::DeclContextLookupResult 
+ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName 
+(
+    const clang::DeclContext *decl_ctx,
+    clang::DeclarationName clang_decl_name
+)
+{
+    std::string decl_name (clang_decl_name.getAsString());
+
+    switch (clang_decl_name.getNameKind()) {
+    // Normal identifiers.
+    case clang::DeclarationName::Identifier:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"Identifier\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        if (clang_decl_name.getAsIdentifierInfo()->getBuiltinID() != 0)
+            return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+        break;
+
+    case clang::DeclarationName::ObjCZeroArgSelector:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"ObjCZeroArgSelector\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::ObjCOneArgSelector:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"ObjCOneArgSelector\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::ObjCMultiArgSelector:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"ObjCMultiArgSelector\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::CXXConstructorName:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"CXXConstructorName\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::CXXDestructorName:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"CXXDestructorName\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::CXXConversionFunctionName:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"CXXConversionFunctionName\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::CXXOperatorName:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"CXXOperatorName\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::CXXLiteralOperatorName:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"CXXLiteralOperatorName\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return DeclContext::lookup_result();
+        break;
+
+    case clang::DeclarationName::CXXUsingDirective:
+        //printf ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx = %p, decl_name = { kind = \"CXXUsingDirective\", name = \"%s\")\n", decl_ctx, decl_name.c_str());
+        return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+    }
+
+    return DeclContext::lookup_result();
+}
+
+void
+ClangExternalASTSourceCallbacks::CompleteType (TagDecl *tag_decl)
+{
+    if (m_callback_tag_decl)
+        m_callback_tag_decl (m_callback_baton, tag_decl);
+}
+
+void
+ClangExternalASTSourceCallbacks::CompleteType (ObjCInterfaceDecl *objc_decl)
+{
+    if (m_callback_objc_decl)
+        m_callback_objc_decl (m_callback_baton, objc_decl);
+}





More information about the lldb-commits mailing list