Updated to latest LLVM.  Major LLVM changes:

 - Sema is now exported (and there was much rejoicing.)

 - Storage classes are now centrally defined.

Also fixed some bugs that the new LLVM picked up.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114622 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ASTResultSynthesizer.cpp b/source/Expression/ASTResultSynthesizer.cpp
index f03430b..0cdcf2a 100644
--- a/source/Expression/ASTResultSynthesizer.cpp
+++ b/source/Expression/ASTResultSynthesizer.cpp
@@ -14,9 +14,7 @@
 #include "clang/AST/DeclGroup.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Stmt.h"
-#include "clang/Parse/Action.h"
 #include "clang/Parse/Parser.h"
-#include "clang/Parse/Scope.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include "lldb/Core/Log.h"
@@ -30,8 +28,7 @@
     m_ast_context (NULL),
     m_passthrough (passthrough),
     m_passthrough_sema (NULL),
-    m_sema (NULL),
-    m_action (NULL)
+    m_sema (NULL)
 {
     if (!m_passthrough)
         return;
@@ -73,8 +70,7 @@
     
     if (m_ast_context &&
         function_decl &&
-        !strcmp(function_decl->getNameAsCString(),
-                "___clang_expr"))
+        !function_decl->getNameInfo().getAsString().compare("___clang_expr"))
     {
         SynthesizeResult(function_decl);
     }
@@ -176,8 +172,8 @@
                                                   &result_id, 
                                                   expr_qual_type, 
                                                   NULL, 
-                                                  VarDecl::Static, 
-                                                  VarDecl::Static);
+                                                  SC_Static, 
+                                                  SC_Static);
     
     if (!result_decl)
         return false;
@@ -187,27 +183,24 @@
     ///////////////////////////////
     // call AddInitializerToDecl
     //
-    
-    Parser::DeclPtrTy result_decl_ptr;
-    result_decl_ptr.set(result_decl);
-    
-    m_action->AddInitializerToDecl(result_decl_ptr, Parser::ExprArg(*m_action, last_expr));
+        
+    m_sema->AddInitializerToDecl(result_decl, last_expr);
     
     /////////////////////////////////
     // call ConvertDeclToDeclGroup
     //
     
-    Parser::DeclGroupPtrTy result_decl_group_ptr;
+    Sema::DeclGroupPtrTy result_decl_group_ptr;
     
-    result_decl_group_ptr = m_action->ConvertDeclToDeclGroup(result_decl_ptr);
+    result_decl_group_ptr = m_sema->ConvertDeclToDeclGroup(result_decl);
     
     ////////////////////////
     // call ActOnDeclStmt
     //
     
-    Parser::OwningStmtResult result_initialization_stmt_result(m_action->ActOnDeclStmt(result_decl_group_ptr,
-                                                                                       SourceLocation(),
-                                                                                       SourceLocation()));
+    StmtResult result_initialization_stmt_result(m_sema->ActOnDeclStmt(result_decl_group_ptr,
+                                                                       SourceLocation(),
+                                                                       SourceLocation()));
     
     ////////////////////////////////////////////////
     // replace the old statement with the new one
@@ -269,7 +262,6 @@
 ASTResultSynthesizer::InitializeSema(Sema &S)
 {
     m_sema = &S;
-    m_action = reinterpret_cast<Action*>(m_sema);
     
     if (m_passthrough_sema)
         m_passthrough_sema->InitializeSema(S);
@@ -279,7 +271,6 @@
 ASTResultSynthesizer::ForgetSema() 
 {
     m_sema = NULL;
-    m_action = NULL;
     
     if (m_passthrough_sema)
         m_passthrough_sema->ForgetSema();
diff --git a/source/Expression/ASTStructExtractor.cpp b/source/Expression/ASTStructExtractor.cpp
index 84a97c8..8635ffe 100644
--- a/source/Expression/ASTStructExtractor.cpp
+++ b/source/Expression/ASTStructExtractor.cpp
@@ -15,9 +15,8 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
-#include "clang/Parse/Action.h"
 #include "clang/Parse/Parser.h"
-#include "clang/Parse/Scope.h"
+#include "clang/Sema/Sema.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include "lldb/Core/Log.h"
@@ -111,7 +110,7 @@
     
     if (m_ast_context &&
         function_decl &&
-        !m_function.m_wrapper_function_name.compare(function_decl->getNameAsCString()))
+        !m_function.m_wrapper_function_name.compare(function_decl->getNameAsString().c_str()))
     {
         ExtractFromFunctionDecl(function_decl);
     }
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 423f759..3d71da5 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -74,6 +74,11 @@
     return SetExternalVisibleDeclsForName(DC, Name, Decls);
 }
 
+void ClangASTSource::MaterializeVisibleDecls(const DeclContext *DC)
+{
+    return;
+}
+
 // This is used to support iterating through an entire lexical context,
 // which isn't something the debugger should ever need to do.
 bool ClangASTSource::FindExternalLexicalDecls(const DeclContext *DC, llvm::SmallVectorImpl<Decl*> &Decls) {
@@ -94,8 +99,8 @@
                                              ii, 
                                              QualType::getFromOpaquePtr(type), 
                                              0, 
-                                             VarDecl::Static, 
-                                             VarDecl::Static);
+                                             SC_Static, 
+                                             SC_Static);
     Decls.push_back(Decl);
     
     return Decl;
@@ -108,8 +113,8 @@
                                                      Name.getAsIdentifierInfo(),
                                                      QualType::getFromOpaquePtr(type),
                                                      NULL,
-                                                     FunctionDecl::Static,
-                                                     FunctionDecl::Static,
+                                                     SC_Static,
+                                                     SC_Static,
                                                      false,
                                                      true);
     
@@ -138,8 +143,8 @@
                                                          NULL,
                                                          ArgQT,
                                                          NULL,
-                                                         ParmVarDecl::Static,
-                                                         ParmVarDecl::Static,
+                                                         SC_Static,
+                                                         SC_Static,
                                                          NULL);
         }
         
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index bed2352..189249f 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -13,6 +13,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "clang/AST/DeclarationName.h"
 #include "lldb/lldb-private.h"
 #include "lldb/Core/Address.h"
 #include "lldb/Core/Error.h"
@@ -1205,12 +1206,12 @@
                                                                  false,
                                                                  ClangASTContext::GetTypeQualifiers(copied_type));
         
-        ClangASTContext::AddMethodToCXXRecordType (parser_ast_context,
-                                                   copied_type,
-                                                   "___clang_expr",
-                                                   method_type,
-                                                   lldb::eAccessPublic,
-                                                   false);
+        ClangASTContext::AddMethodToCXXRecordType(parser_ast_context,
+                                                  copied_type,
+                                                  "___clang_expr",
+                                                  method_type,
+                                                  lldb::eAccessPublic,
+                                                  false);
     }
     
     context.AddTypeDecl(copied_type);
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 9059806..ec385a4 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -43,8 +43,8 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Frontend/VerifyDiagnosticsClient.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseAST.h"
 #include "clang/Rewrite/FrontendActions.h"
-#include "clang/Sema/ParseAST.h"
 #include "clang/Sema/SemaConsumer.h"
 
 #include "llvm/ADT/StringRef.h"
@@ -239,8 +239,7 @@
     
     // 4. Set up the diagnostic buffer for reporting errors
     
-    m_diagnostic_buffer.reset(new clang::TextDiagnosticBuffer);
-    m_compiler->getDiagnostics().setClient(m_diagnostic_buffer.get());
+    m_compiler->getDiagnostics().setClient(new clang::TextDiagnosticBuffer);
     
     // 5. Set up the source management objects inside the compiler
     
@@ -288,12 +287,14 @@
 unsigned
 ClangExpressionParser::Parse (Stream &stream)
 {
-    m_diagnostic_buffer->FlushDiagnostics (m_compiler->getDiagnostics());
+    TextDiagnosticBuffer *diag_buf = static_cast<TextDiagnosticBuffer*>(m_compiler->getDiagnostics().getClient());
+        
+    diag_buf->FlushDiagnostics (m_compiler->getDiagnostics());
     
     MemoryBuffer *memory_buffer = MemoryBuffer::getMemBufferCopy(m_expr.Text(), __FUNCTION__);
     FileID memory_buffer_file_id = m_compiler->getSourceManager().createMainFileIDForMemBuffer (memory_buffer);
     
-    m_diagnostic_buffer->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
+    diag_buf->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
     
     ASTConsumer *ast_transformer = m_expr.ASTTransformer(m_code_generator.get());
     
@@ -302,21 +303,21 @@
     else 
         ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());    
     
-    m_diagnostic_buffer->EndSourceFile();
+    diag_buf->EndSourceFile();
     
     TextDiagnosticBuffer::const_iterator diag_iterator;
     
     int num_errors = 0;
         
-    for (diag_iterator = m_diagnostic_buffer->warn_begin();
-         diag_iterator != m_diagnostic_buffer->warn_end();
+    for (diag_iterator = diag_buf->warn_begin();
+         diag_iterator != diag_buf->warn_end();
          ++diag_iterator)
         stream.Printf("warning: %s\n", (*diag_iterator).second.c_str());
     
     num_errors = 0;
     
-    for (diag_iterator = m_diagnostic_buffer->err_begin();
-         diag_iterator != m_diagnostic_buffer->err_end();
+    for (diag_iterator = diag_buf->err_begin();
+         diag_iterator != diag_buf->err_end();
          ++diag_iterator)
     {
         num_errors++;
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index b5a706d..53cabcb 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -478,7 +478,7 @@
 
 IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
                                  const char *func_name) :
-    ModulePass(&ID),
+    ModulePass(ID),
     m_checker_functions(checker_functions),
     m_func_name(func_name)
 {
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index cec3583..626cd54 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -34,7 +34,7 @@
                          const TargetData *target_data,
                          bool resolve_vars,
                          const char *func_name) :
-    ModulePass(&ID),
+    ModulePass(ID),
     m_decl_map(decl_map),
     m_target_data(target_data),
     m_sel_registerName(NULL),
@@ -728,12 +728,22 @@
 
 static bool isGuardVariableRef(Value *V)
 {
-    ConstantExpr *C = dyn_cast<ConstantExpr>(V);
+    Constant *C;
     
-    if (!C || C->getOpcode() != Instruction::BitCast)
+    if (!(C = dyn_cast<Constant>(V)))
         return false;
     
-    GlobalVariable *GV = dyn_cast<GlobalVariable>(C->getOperand(0));
+    ConstantExpr *CE;
+    
+    if ((CE = dyn_cast<ConstantExpr>(V)))
+    {
+        if (CE->getOpcode() != Instruction::BitCast)
+            return false;
+        
+        C = CE->getOperand(0);
+    }
+    
+    GlobalVariable *GV = dyn_cast<GlobalVariable>(C);
     
     if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV"))
         return false;
diff --git a/source/Expression/IRToDWARF.cpp b/source/Expression/IRToDWARF.cpp
index b158da6..d4a4a3f 100644
--- a/source/Expression/IRToDWARF.cpp
+++ b/source/Expression/IRToDWARF.cpp
@@ -30,7 +30,7 @@
                      lldb_private::ClangExpressionDeclMap *decl_map,
                      lldb_private::StreamString &strm,
                      const char *func_name) :
-    ModulePass(&ID),
+    ModulePass(ID),
     m_local_vars(local_vars),
     m_decl_map(decl_map),
     m_strm(strm),