[Lldb-commits] [PATCH] bring lldb up to llvm and clang revs 140618

dawn at burble.org dawn at burble.org
Fri Oct 7 14:44:15 PDT 2011


This patch allows lldb (now at rev 141350) to build with rev 140618 of
clang and llvm.  When lldb is ready to move to newer versions of clang
and llvm, I hope this patch will save you some time.

-Dawn
-------------- next part --------------
Index: include/lldb/Core/ClangForward.h
===================================================================
--- include/lldb/Core/ClangForward.h	(revision 141350)
+++ include/lldb/Core/ClangForward.h	(working copy)
@@ -52,7 +52,8 @@
     class DeclStmt;
     class DependencyOutputOptions;
     class Diagnostic;
-    class DiagnosticClient;
+    class DiagnosticsEngine;
+    class DiagnosticConsumer;
     class DiagnosticOptions;
     class EnumDecl;
     class Expr;
Index: include/lldb/Symbol/ClangASTContext.h
===================================================================
--- include/lldb/Symbol/ClangASTContext.h	(revision 141350)
+++ include/lldb/Symbol/ClangASTContext.h	(working copy)
@@ -84,10 +84,10 @@
     clang::SourceManager *
     getSourceManager();
 
-    clang::Diagnostic *
-    getDiagnostic();
+    clang::DiagnosticsEngine *
+    getDiagnostics();
     
-    clang::DiagnosticClient *
+    clang::DiagnosticConsumer *
     getDiagnosticClient();
 
     clang::TargetOptions *
@@ -754,22 +754,22 @@
     //------------------------------------------------------------------
     // Classes that inherit from ClangASTContext can see and modify these
     //------------------------------------------------------------------
-    std::string                             m_target_triple;
-    std::auto_ptr<clang::ASTContext>        m_ast_ap;
-    std::auto_ptr<clang::LangOptions>       m_language_options_ap;
-    std::auto_ptr<clang::FileManager>       m_file_manager_ap;
-    std::auto_ptr<clang::FileSystemOptions> m_file_system_options_ap;
-    std::auto_ptr<clang::SourceManager>     m_source_manager_ap;
-    std::auto_ptr<clang::Diagnostic>        m_diagnostic_ap;
-    std::auto_ptr<clang::DiagnosticClient>  m_diagnostic_client_ap;
-    std::auto_ptr<clang::TargetOptions>     m_target_options_ap;
-    std::auto_ptr<clang::TargetInfo>        m_target_info_ap;
-    std::auto_ptr<clang::IdentifierTable>   m_identifier_table_ap;
-    std::auto_ptr<clang::SelectorTable>     m_selector_table_ap;
-    std::auto_ptr<clang::Builtin::Context>  m_builtins_ap;
-    CompleteTagDeclCallback                 m_callback_tag_decl;
-    CompleteObjCInterfaceDeclCallback       m_callback_objc_decl;
-    void *                                  m_callback_baton;
+    std::string                               m_target_triple;
+    std::auto_ptr<clang::ASTContext>          m_ast_ap;
+    std::auto_ptr<clang::LangOptions>         m_language_options_ap;
+    std::auto_ptr<clang::FileManager>         m_file_manager_ap;
+    std::auto_ptr<clang::FileSystemOptions>   m_file_system_options_ap;
+    std::auto_ptr<clang::SourceManager>       m_source_manager_ap;
+    std::auto_ptr<clang::DiagnosticsEngine>   m_diagnostic_ap;
+    std::auto_ptr<clang::DiagnosticConsumer>  m_diagnostic_client_ap;
+    std::auto_ptr<clang::TargetOptions>       m_target_options_ap;
+    std::auto_ptr<clang::TargetInfo>          m_target_info_ap;
+    std::auto_ptr<clang::IdentifierTable>     m_identifier_table_ap;
+    std::auto_ptr<clang::SelectorTable>       m_selector_table_ap;
+    std::auto_ptr<clang::Builtin::Context>    m_builtins_ap;
+    CompleteTagDeclCallback                   m_callback_tag_decl;
+    CompleteObjCInterfaceDeclCallback         m_callback_objc_decl;
+    void *                                    m_callback_baton;
 private:
     //------------------------------------------------------------------
     // For ClangASTContext only
Index: source/Expression/ASTDumper.cpp
===================================================================
--- source/Expression/ASTDumper.cpp	(revision 141350)
+++ source/Expression/ASTDumper.cpp	(working copy)
@@ -416,7 +416,11 @@
         switch (type->getScalarTypeKind())
         {
             default:                                m_stream.Printf("~\n"); break;
-            case clang::Type::STK_Pointer:          m_stream.Printf("STK_Pointer\n"); break;
+            case clang::Type::STK_CPointer:         m_stream.Printf("STK_CPointer\n"); break;
+            case clang::Type::STK_BlockPointer:     m_stream.Printf("STK_BlockPointer\n"); break;
+            case clang::Type::STK_ObjCObjectPointer:
+                                                    m_stream.Printf("STK_ObjCObjectPointer\n");
+                                                    break;
             case clang::Type::STK_MemberPointer:    m_stream.Printf("STK_MemberPointer\n"); break;
             case clang::Type::STK_Bool:             m_stream.Printf("STK_Bool\n"); break;
             case clang::Type::STK_Integral:         m_stream.Printf("STK_Integral\n"); break;
Index: source/Expression/ClangASTSource.cpp
===================================================================
--- source/Expression/ClangASTSource.cpp	(revision 141350)
+++ source/Expression/ClangASTSource.cpp	(working copy)
@@ -197,27 +197,27 @@
         unsigned NumArgs = func_proto_type->getNumArgs();
         unsigned ArgIndex;
         
-        ParmVarDecl **param_var_decls = new ParmVarDecl*[NumArgs];
+        SmallVector<ParmVarDecl *, 16> param_var_decls;
+        param_var_decls.reserve(NumArgs);
         
         for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex)
         {
             QualType arg_qual_type (func_proto_type->getArgType(ArgIndex));
             
-            param_var_decls[ArgIndex] = ParmVarDecl::Create (m_ast_source.m_ast_context,
-                                                             const_cast<DeclContext*>(m_decl_context),
-                                                             SourceLocation(),
-                                                             SourceLocation(),
-                                                             NULL,
-                                                             arg_qual_type,
-                                                             NULL,
-                                                             SC_Static,
-                                                             SC_Static,
-                                                             NULL);
+            ParmVarDecl *NewDecl = ParmVarDecl::Create (m_ast_source.m_ast_context,
+                                                        const_cast<DeclContext*>(m_decl_context),
+                                                        SourceLocation(),
+                                                        SourceLocation(),
+                                                        NULL,
+                                                        arg_qual_type,
+                                                        NULL,
+                                                        SC_Static,
+                                                        SC_Static,
+                                                        NULL);
+            param_var_decls.push_back(NewDecl);
         }
         
-        func_decl->setParams(param_var_decls, NumArgs);
-        
-        delete [] param_var_decls;
+        func_decl->setParams(param_var_decls);
     }
     
     m_decls.push_back(func_decl);
Index: source/Expression/ClangExpressionParser.cpp
===================================================================
--- source/Expression/ClangExpressionParser.cpp	(revision 141350)
+++ source/Expression/ClangExpressionParser.cpp	(working copy)
@@ -41,7 +41,7 @@
 #include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Frontend/VerifyDiagnosticsClient.h"
+#include "clang/Frontend/VerifyDiagnosticConsumer.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Parse/ParseAST.h"
 #include "clang/Rewrite/FrontendActions.h"
@@ -67,8 +67,8 @@
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Signals.h"
-#include "llvm/Target/TargetRegistry.h"
-#include "llvm/Target/TargetSelect.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
 
 using namespace clang;
 using namespace llvm;
@@ -103,7 +103,7 @@
 //===----------------------------------------------------------------------===//
 
 static void LLVMErrorHandler(void *UserData, const std::string &Message) {
-    Diagnostic &Diags = *static_cast<Diagnostic*>(UserData);
+    DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
     
     Diags.Report(diag::err_fe_error_backend) << Message;
     
@@ -132,7 +132,7 @@
         case EmitCodeGenOnly:        return new EmitCodeGenOnlyAction();
         case EmitObj:                return new EmitObjAction();
         case FixIt:                  return new FixItAction();
-        case GeneratePCH:            return new GeneratePCHAction();
+        case GeneratePCH:            return new GeneratePCHAction(false);
         case GeneratePTH:            return new GeneratePTHAction();
         case InitOnly:               return new InitOnlyAction();
         case ParseSyntaxOnly:        return new SyntaxOnlyAction();
@@ -307,16 +307,21 @@
     
     // 6. Most of this we get from the CompilerInstance, but we 
     // also want to give the context an ExternalASTSource.
+
     m_selector_table.reset(new SelectorTable());
-    m_builtin_context.reset(new Builtin::Context(m_compiler->getTarget()));
+
+    Builtin::Context* NewContext = new Builtin::Context();
+    NewContext->InitializeTarget(m_compiler->getTarget());
+    m_builtin_context.reset(NewContext);
     
     std::auto_ptr<clang::ASTContext> ast_context(new ASTContext(m_compiler->getLangOpts(),
                                                                 m_compiler->getSourceManager(),
-                                                                m_compiler->getTarget(),
+                                                                &(m_compiler->getTarget()),
                                                                 m_compiler->getPreprocessor().getIdentifierTable(),
                                                                 *m_selector_table.get(),
                                                                 *m_builtin_context.get(),
-                                                                0));
+                                                                0,
+                                                                false));
     
     ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
     
Index: source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp
===================================================================
--- source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp	(revision 141350)
+++ source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp	(working copy)
@@ -112,7 +112,7 @@
     executable = m_process->GetTarget().GetExecutableModule();
     load_offset = ComputeLoadOffset();
 
-    if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS)
+    if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
     {
         ModuleList module_list;
         module_list.Append(executable);
@@ -132,7 +132,7 @@
     executable = m_process->GetTarget().GetExecutableModule();
     load_offset = ComputeLoadOffset();
 
-    if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS)
+    if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
     {
         ModuleList module_list;
         module_list.Append(executable);
@@ -264,7 +264,7 @@
         {
             FileSpec file(I->path.c_str(), true);
             ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
-            if (!module_sp.empty())
+            if (module_sp.get())
                 new_modules.Append(module_sp);
         }
         m_process->GetTarget().ModulesDidLoad(new_modules);
@@ -280,7 +280,7 @@
             FileSpec file(I->path.c_str(), true);
             ModuleSP module_sp = 
                 loaded_modules.FindFirstModuleForFileSpec(file, NULL, NULL);
-            if (!module_sp.empty())
+            if (module_sp.get())
                 old_modules.Append(module_sp);
         }
         m_process->GetTarget().ModulesDidUnload(old_modules);
@@ -355,7 +355,7 @@
     {
         FileSpec file(I->path.c_str(), false);
         ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
-        if (!module_sp.empty())
+        if (module_sp.get())
             module_list.Append(module_sp);
     }
 
Index: source/Plugins/Process/Linux/ProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessLinux.cpp	(revision 141350)
+++ source/Plugins/Process/Linux/ProcessLinux.cpp	(working copy)
@@ -437,6 +437,13 @@
     return m_thread_list.GetSize(false);
 }
 
+uint32_t
+ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
+{
+    // FIXME: Should this be implemented?
+    return 0;
+}
+
 ByteOrder
 ProcessLinux::GetByteOrder() const
 {
Index: source/Plugins/Process/Linux/ProcessLinux.h
===================================================================
--- source/Plugins/Process/Linux/ProcessLinux.h	(revision 141350)
+++ source/Plugins/Process/Linux/ProcessLinux.h	(working copy)
@@ -129,6 +129,10 @@
     virtual uint32_t
     UpdateThreadListIfNeeded();
 
+    uint32_t
+    UpdateThreadList(lldb_private::ThreadList &old_thread_list, 
+                     lldb_private::ThreadList &new_thread_list);
+
     virtual lldb::ByteOrder
     GetByteOrder() const;
 
Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessMonitor.cpp	(revision 141350)
+++ source/Plugins/Process/Linux/ProcessMonitor.cpp	(working copy)
@@ -241,7 +241,7 @@
 
     // Set errno to zero so that we can detect a failed peek.
     errno = 0;
-    unsigned long data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL);
+    uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL);
 
     if (data == -1UL && errno)
         m_result = false;
Index: source/Symbol/ClangASTContext.cpp
===================================================================
--- source/Symbol/ClangASTContext.cpp	(revision 141350)
+++ source/Symbol/ClangASTContext.cpp	(working copy)
@@ -468,11 +468,12 @@
     {
         m_ast_ap.reset(new ASTContext (*getLanguageOptions(),
                                        *getSourceManager(),
-                                       *getTargetInfo(),
+                                       getTargetInfo(),
                                        *getIdentifierTable(),
                                        *getSelectorTable(),
                                        *getBuiltinContext(),
-                                       0));
+                                       0,
+                                       false));
         
         if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton)
         {
@@ -489,7 +490,11 @@
 ClangASTContext::getBuiltinContext()
 {
     if (m_builtins_ap.get() == NULL)
-        m_builtins_ap.reset (new Builtin::Context(*getTargetInfo()));
+    {
+        Builtin::Context* NewContext = new Builtin::Context();
+        NewContext->InitializeTarget(*getTargetInfo());
+        m_builtins_ap.reset(NewContext);
+    }
     return m_builtins_ap.get();
 }
 
@@ -536,22 +541,23 @@
 ClangASTContext::getSourceManager()
 {
     if (m_source_manager_ap.get() == NULL)
-        m_source_manager_ap.reset(new clang::SourceManager(*getDiagnostic(), *getFileManager()));
+        m_source_manager_ap.reset(
+            new clang::SourceManager(*getDiagnostics(), *getFileManager()));
     return m_source_manager_ap.get();
 }
 
-Diagnostic *
-ClangASTContext::getDiagnostic()
+DiagnosticsEngine *
+ClangASTContext::getDiagnostics()
 {
     if (m_diagnostic_ap.get() == NULL)
     {
         llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs());
-        m_diagnostic_ap.reset(new Diagnostic(diag_id_sp));
+        m_diagnostic_ap.reset(new DiagnosticsEngine(diag_id_sp));
     }
     return m_diagnostic_ap.get();
 }
 
-class NullDiagnosticClient : public DiagnosticClient
+class NullDiagnosticClient : public DiagnosticConsumer
 {
 public:
     NullDiagnosticClient ()
@@ -559,7 +565,7 @@
         m_log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
     }
     
-    void HandleDiagnostic (Diagnostic::Level DiagLevel, const DiagnosticInfo &info)
+    void HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &info)
     {
         if (m_log)
         {
@@ -573,7 +579,7 @@
     LogSP m_log;
 };
 
-DiagnosticClient *
+DiagnosticConsumer *
 ClangASTContext::getDiagnosticClient()
 {
     if (m_diagnostic_client_ap.get() == NULL)
@@ -600,7 +606,7 @@
 {
     // target_triple should be something like "x86_64-apple-darwin10"
     if (m_target_info_ap.get() == NULL && !m_target_triple.empty())
-        m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnostic(), *getTargetOptions()));
+        m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnostics(), *getTargetOptions()));
     return m_target_info_ap.get();
 }
 
@@ -1466,7 +1472,8 @@
                                                       NULL, // TypeSourceInfo *
                                                       is_explicit, 
                                                       is_inline,
-                                                      is_implicitly_declared);
+                                                      is_implicitly_declared,
+                                                      false); // isConstexpr
     }
     else
     {   
@@ -1492,6 +1499,7 @@
                                                          is_static,
                                                          SC_None,
                                                          is_inline,
+                                                         false, // isConstexpr
                                                          SourceLocation());
             }
             else if (num_params == 0)
@@ -1505,6 +1513,7 @@
                                                              NULL, // TypeSourceInfo *
                                                              is_inline,
                                                              is_explicit,
+                                                             false, // isConstexpr
                                                              SourceLocation());
             }
         }
@@ -1520,6 +1529,7 @@
                                                      is_static,
                                                      SC_None,
                                                      is_inline,
+                                                     false, // isConstexpr
                                                      SourceLocation());
         }
     }
@@ -1549,7 +1559,7 @@
                                                NULL));
     }
     
-    cxx_method_decl->setParams (params.data(), num_params);
+    cxx_method_decl->setParams (params);
     
     cxx_record_decl->addDecl (cxx_method_decl);
 
@@ -2020,8 +2030,10 @@
                                                                name[0] == '-',
                                                                is_variadic,
                                                                is_synthesized,
+                                                               false, // isImplicitlyDeclared
                                                                is_defined,
                                                                imp_control,
+                                                               false, // HasRelatedResultType
                                                                num_args);
 
 
@@ -4208,7 +4220,17 @@
 ClangASTContext::SetFunctionParameters (FunctionDecl *function_decl, ParmVarDecl **params, unsigned num_params)
 {
     if (function_decl)
-        function_decl->setParams (params, num_params);
+    {
+        llvm::SmallVector<ParmVarDecl *, 12> param_var_decls;
+        param_var_decls.reserve(num_params);
+            
+        for (int param_index = 0; param_index < num_params; ++param_index)
+        {
+            param_var_decls.push_back (params[param_index]);
+        }
+        
+        function_decl->setParams (param_var_decls);
+    }
 }
 
 
Index: source/lldb.cpp
===================================================================
--- source/lldb.cpp	(revision 141350)
+++ source/lldb.cpp	(working copy)
@@ -94,7 +94,9 @@
         UnwindAssemblyInstEmulation::Initialize();
         UnwindAssembly_x86::Initialize();
         EmulateInstructionARM::Initialize ();
+#if !defined (__linux__)
         ObjectFilePECOFF::Initialize ();
+#endif
 #if defined (__APPLE__)
         //----------------------------------------------------------------------
         // Apple/Darwin hosted plugins
@@ -166,7 +168,9 @@
     UnwindAssembly_x86::Terminate();
     UnwindAssemblyInstEmulation::Terminate();
     EmulateInstructionARM::Terminate ();
+#if !defined (__linux__)
     ObjectFilePECOFF::Terminate ();
+#endif
 
 #if defined (__APPLE__)
     DynamicLoaderMacOSXDYLD::Terminate();


More information about the lldb-commits mailing list