[Lldb-commits] [lldb] r212411 - remove trailing whitespace + remove some useless comments

Sylvestre Ledru sylvestre at debian.org
Sun Jul 6 10:54:59 PDT 2014


Author: sylvestre
Date: Sun Jul  6 12:54:58 2014
New Revision: 212411

URL: http://llvm.org/viewvc/llvm-project?rev=212411&view=rev
Log:
remove trailing whitespace + remove some useless comments

Modified:
    lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
    lldb/trunk/source/Expression/ASTStructExtractor.cpp
    lldb/trunk/source/Expression/ClangASTSource.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/ClangExpressionParser.cpp
    lldb/trunk/source/Expression/ClangExpressionVariable.cpp
    lldb/trunk/source/Expression/ClangUserExpression.cpp
    lldb/trunk/source/Expression/IRDynamicChecks.cpp
    lldb/trunk/source/Expression/IRExecutionUnit.cpp
    lldb/trunk/source/Expression/IRForTarget.cpp
    lldb/trunk/source/Expression/IRInterpreter.cpp
    lldb/trunk/source/Expression/IRMemoryMap.cpp
    lldb/trunk/source/Expression/Makefile

Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Sun Jul  6 12:54:58 2014
@@ -40,7 +40,7 @@ ASTResultSynthesizer::ASTResultSynthesiz
 {
     if (!m_passthrough)
         return;
-    
+
     m_passthrough_sema = dyn_cast<SemaConsumer>(passthrough);
 }
 
@@ -49,10 +49,10 @@ ASTResultSynthesizer::~ASTResultSynthesi
 }
 
 void
-ASTResultSynthesizer::Initialize(ASTContext &Context) 
+ASTResultSynthesizer::Initialize(ASTContext &Context)
 {
     m_ast_context = &Context;
-    
+
     if (m_passthrough)
         m_passthrough->Initialize(Context);
 }
@@ -75,11 +75,11 @@ ASTResultSynthesizer::TransformTopLevelD
         }
 
     }
-    
+
     if (LinkageSpecDecl *linkage_spec_decl = dyn_cast<LinkageSpecDecl>(D))
     {
         RecordDecl::decl_iterator decl_iterator;
-        
+
         for (decl_iterator = linkage_spec_decl->decls_begin();
              decl_iterator != linkage_spec_decl->decls_end();
              ++decl_iterator)
@@ -107,53 +107,53 @@ ASTResultSynthesizer::TransformTopLevelD
     }
 }
 
-bool 
+bool
 ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D)
 {
     DeclGroupRef::iterator decl_iterator;
-    
+
     for (decl_iterator = D.begin();
          decl_iterator != D.end();
          ++decl_iterator)
     {
         Decl *decl = *decl_iterator;
-        
+
         TransformTopLevelDecl(decl);
     }
-    
+
     if (m_passthrough)
         return m_passthrough->HandleTopLevelDecl(D);
     return true;
 }
 
-bool 
+bool
 ASTResultSynthesizer::SynthesizeFunctionResult (FunctionDecl *FunDecl)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     if (!m_sema)
         return false;
-    
+
     FunctionDecl *function_decl = FunDecl;
-    
+
     if (!function_decl)
         return false;
-    
+
     if (log && log->GetVerbose())
     {
         std::string s;
         raw_string_ostream os(s);
-        
+
         function_decl->print(os);
-        
+
         os.flush();
-        
+
         log->Printf ("Untransformed function AST:\n%s", s.c_str());
     }
-    
+
     Stmt *function_body = function_decl->getBody();
     CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(function_body);
-    
+
     bool ret = SynthesizeBodyResult (compound_stmt,
                                      function_decl);
 
@@ -161,14 +161,14 @@ ASTResultSynthesizer::SynthesizeFunction
     {
         std::string s;
         raw_string_ostream os(s);
-        
+
         function_decl->print(os);
-        
+
         os.flush();
-        
+
         log->Printf ("Transformed function AST:\n%s", s.c_str());
     }
-    
+
     return ret;
 }
 
@@ -176,67 +176,67 @@ bool
 ASTResultSynthesizer::SynthesizeObjCMethodResult (ObjCMethodDecl *MethodDecl)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-        
+
     if (!m_sema)
         return false;
-        
+
     if (!MethodDecl)
         return false;
-    
+
     if (log && log->GetVerbose())
     {
         std::string s;
         raw_string_ostream os(s);
-        
+
         MethodDecl->print(os);
-        
+
         os.flush();
-        
+
         log->Printf ("Untransformed method AST:\n%s", s.c_str());
     }
-    
+
     Stmt *method_body = MethodDecl->getBody();
-    
+
     if (!method_body)
         return false;
-    
+
     CompoundStmt *compound_stmt = dyn_cast<CompoundStmt>(method_body);
-    
+
     bool ret = SynthesizeBodyResult (compound_stmt,
                                      MethodDecl);
-    
+
     if (log && log->GetVerbose())
     {
         std::string s;
         raw_string_ostream os(s);
-        
+
         MethodDecl->print(os);
-        
+
         os.flush();
-        
+
         log->Printf("Transformed method AST:\n%s", s.c_str());
     }
-    
+
     return ret;
 }
 
-bool 
-ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body, 
+bool
+ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body,
                                             DeclContext *DC)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     ASTContext &Ctx(*m_ast_context);
-        
+
     if (!Body)
         return false;
-    
+
     if (Body->body_empty())
         return false;
-    
+
     Stmt **last_stmt_ptr = Body->body_end() - 1;
     Stmt *last_stmt = *last_stmt_ptr;
-    
+
     while (dyn_cast<NullStmt>(last_stmt))
     {
         if (last_stmt_ptr != Body->body_begin())
@@ -249,28 +249,28 @@ ASTResultSynthesizer::SynthesizeBodyResu
             return false;
         }
     }
-    
+
     Expr *last_expr = dyn_cast<Expr>(last_stmt);
-    
+
     if (!last_expr)
         // No auxiliary variable necessary; expression returns void
         return true;
-    
+
     // In C++11, last_expr can be a LValueToRvalue implicit cast.  Strip that off if that's the
     // case.
-    
+
     do {
         ImplicitCastExpr *implicit_cast = dyn_cast<ImplicitCastExpr>(last_expr);
-        
+
         if (!implicit_cast)
             break;
-        
+
         if (implicit_cast->getCastKind() != CK_LValueToRValue)
             break;
-        
+
         last_expr = implicit_cast->getSubExpr();
     } while (0);
-    
+
     // is_lvalue is used to record whether the expression returns an assignable Lvalue or an
     // Rvalue.  This is relevant because they are handled differently.
     //
@@ -302,7 +302,7 @@ ASTResultSynthesizer::SynthesizeBodyResu
     //
     //   - In IR transformations, an instruction is inserted at the beginning of the function to
     //     dereference the pointer resident in the slot.  Reads and writes to $__lldb_expr_result
-    //     are redirected at that dereferenced version.  Guard variables for the static variable 
+    //     are redirected at that dereferenced version.  Guard variables for the static variable
     //     are excised.
     //
     //   - During materialization, $0 (the result persistent variable) is populated with the location
@@ -310,46 +310,46 @@ ASTResultSynthesizer::SynthesizeBodyResu
     //
     //   - During dematerialization, $0 is ignored.
 
-    bool is_lvalue = 
+    bool is_lvalue =
         (last_expr->getValueKind() == VK_LValue || last_expr->getValueKind() == VK_XValue) &&
         (last_expr->getObjectKind() == OK_Ordinary);
-    
+
     QualType expr_qual_type = last_expr->getType();
     const clang::Type *expr_type = expr_qual_type.getTypePtr();
-    
+
     if (!expr_type)
         return false;
-    
+
     if (expr_type->isVoidType())
         return true;
-    
+
     if (log)
     {
         std::string s = expr_qual_type.getAsString();
-        
+
         log->Printf("Last statement is an %s with type: %s", (is_lvalue ? "lvalue" : "rvalue"), s.c_str());
     }
-    
+
     clang::VarDecl *result_decl = NULL;
-    
+
     if (is_lvalue)
     {
         IdentifierInfo *result_ptr_id;
-        
+
         if (expr_type->isFunctionType())
             result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result"); // functions actually should be treated like function pointers
         else
             result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result_ptr");
-        
+
         m_sema->RequireCompleteType(SourceLocation(), expr_qual_type, clang::diag::err_incomplete_type);
-        
+
         QualType ptr_qual_type;
 
         if (expr_qual_type->getAs<ObjCObjectType>() != NULL)
             ptr_qual_type = Ctx.getObjCObjectPointerType(expr_qual_type);
         else
             ptr_qual_type = Ctx.getPointerType(expr_qual_type);
-        
+
         result_decl = VarDecl::Create(Ctx,
                                       DC,
                                       SourceLocation(),
@@ -358,61 +358,61 @@ ASTResultSynthesizer::SynthesizeBodyResu
                                       ptr_qual_type,
                                       NULL,
                                       SC_Static);
-        
+
         if (!result_decl)
             return false;
-                
+
         ExprResult address_of_expr = m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr);
-        
+
         m_sema->AddInitializerToDecl(result_decl, address_of_expr.get(), true, false);
     }
     else
     {
         IdentifierInfo &result_id = Ctx.Idents.get("$__lldb_expr_result");
-        
-        result_decl = VarDecl::Create(Ctx, 
-                                      DC, 
+
+        result_decl = VarDecl::Create(Ctx,
+                                      DC,
                                       SourceLocation(),
                                       SourceLocation(),
-                                      &result_id, 
-                                      expr_qual_type, 
-                                      NULL, 
+                                      &result_id,
+                                      expr_qual_type,
+                                      NULL,
                                       SC_Static);
-        
+
         if (!result_decl)
             return false;
-        
+
         m_sema->AddInitializerToDecl(result_decl, last_expr, true, false);
     }
-    
+
     DC->addDecl(result_decl);
-    
+
     ///////////////////////////////
     // call AddInitializerToDecl
     //
-        
+
     //m_sema->AddInitializerToDecl(result_decl, last_expr);
-    
+
     /////////////////////////////////
     // call ConvertDeclToDeclGroup
     //
-    
+
     Sema::DeclGroupPtrTy result_decl_group_ptr;
-    
+
     result_decl_group_ptr = m_sema->ConvertDeclToDeclGroup(result_decl);
-    
+
     ////////////////////////
     // call ActOnDeclStmt
     //
-    
+
     StmtResult result_initialization_stmt_result(m_sema->ActOnDeclStmt(result_decl_group_ptr,
                                                                        SourceLocation(),
                                                                        SourceLocation()));
-    
+
     ////////////////////////////////////////////////
     // replace the old statement with the new one
     //
-    
+
     *last_stmt_ptr = reinterpret_cast<Stmt*>(result_initialization_stmt_result.get());
 
     return true;
@@ -420,7 +420,7 @@ ASTResultSynthesizer::SynthesizeBodyResu
 
 void
 ASTResultSynthesizer::HandleTranslationUnit(ASTContext &Ctx)
-{    
+{
     if (m_passthrough)
         m_passthrough->HandleTranslationUnit(Ctx);
 }
@@ -429,8 +429,8 @@ void
 ASTResultSynthesizer::RecordPersistentTypes(DeclContext *FunDeclCtx)
 {
     typedef DeclContext::specific_decl_iterator<TypeDecl> TypeDeclIterator;
-    
-    for (TypeDeclIterator i = TypeDeclIterator(FunDeclCtx->decls_begin()), 
+
+    for (TypeDeclIterator i = TypeDeclIterator(FunDeclCtx->decls_begin()),
          e = TypeDeclIterator(FunDeclCtx->decls_end());
          i != e;
          ++i)
@@ -439,35 +439,35 @@ ASTResultSynthesizer::RecordPersistentTy
     }
 }
 
-void 
+void
 ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D)
 {
     if (!D->getIdentifier())
         return;
-    
+
     StringRef name = D->getName();
-    
+
     if (name.size() == 0 || name[0] != '$')
         return;
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     ConstString name_cs(name.str().c_str());
-    
+
     if (log)
         log->Printf ("Recording persistent type %s\n", name_cs.GetCString());
-    
-    Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(m_target.GetScratchClangASTContext()->getASTContext(), 
+
+    Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(m_target.GetScratchClangASTContext()->getASTContext(),
                                                                  m_ast_context,
                                                                  D);
-    
+
     if (TypeDecl *TypeDecl_scratch = dyn_cast<TypeDecl>(D_scratch))
         m_target.GetPersistentVariables().RegisterPersistentType(name_cs, TypeDecl_scratch);
 }
 
-void 
+void
 ASTResultSynthesizer::HandleTagDeclDefinition(TagDecl *D)
-{    
+{
     if (m_passthrough)
         m_passthrough->HandleTagDeclDefinition(D);
 }
@@ -479,15 +479,15 @@ ASTResultSynthesizer::CompleteTentativeD
         m_passthrough->CompleteTentativeDefinition(D);
 }
 
-void 
-ASTResultSynthesizer::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) 
+void
+ASTResultSynthesizer::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired)
 {
     if (m_passthrough)
         m_passthrough->HandleVTable(RD, DefinitionRequired);
 }
 
 void
-ASTResultSynthesizer::PrintStats() 
+ASTResultSynthesizer::PrintStats()
 {
     if (m_passthrough)
         m_passthrough->PrintStats();
@@ -497,16 +497,16 @@ void
 ASTResultSynthesizer::InitializeSema(Sema &S)
 {
     m_sema = &S;
-    
+
     if (m_passthrough_sema)
         m_passthrough_sema->InitializeSema(S);
 }
 
-void 
-ASTResultSynthesizer::ForgetSema() 
+void
+ASTResultSynthesizer::ForgetSema()
 {
     m_sema = NULL;
-    
+
     if (m_passthrough_sema)
         m_passthrough_sema->ForgetSema();
 }

Modified: lldb/trunk/source/Expression/ASTStructExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTStructExtractor.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTStructExtractor.cpp (original)
+++ lldb/trunk/source/Expression/ASTStructExtractor.cpp Sun Jul  6 12:54:58 2014
@@ -39,7 +39,7 @@ ASTStructExtractor::ASTStructExtractor(A
 {
     if (!m_passthrough)
         return;
-    
+
     m_passthrough_sema = dyn_cast<SemaConsumer>(passthrough);
 }
 
@@ -48,10 +48,10 @@ ASTStructExtractor::~ASTStructExtractor(
 }
 
 void
-ASTStructExtractor::Initialize(ASTContext &Context) 
+ASTStructExtractor::Initialize(ASTContext &Context)
 {
     m_ast_context = &Context;
-    
+
     if (m_passthrough)
         m_passthrough->Initialize(Context);
 }
@@ -61,17 +61,17 @@ ASTStructExtractor::ExtractFromFunctionD
 {
     if (!F->hasBody())
         return;
-    
+
     Stmt *body_stmt = F->getBody();
     CompoundStmt *body_compound_stmt = dyn_cast<CompoundStmt>(body_stmt);
-    
+
     if (!body_compound_stmt)
         return; // do we have to handle this?
-    
+
     RecordDecl *struct_decl = NULL;
-    
+
     StringRef desired_name(m_struct_name.c_str());
-    
+
     for (CompoundStmt::const_body_iterator bi = body_compound_stmt->body_begin(), be = body_compound_stmt->body_end();
          bi != be;
          ++bi)
@@ -95,26 +95,26 @@ ASTStructExtractor::ExtractFromFunctionD
         if (struct_decl)
             break;
     }
-    
+
     if (!struct_decl)
         return;
-    
+
     const ASTRecordLayout* struct_layout(&m_ast_context->getASTRecordLayout (struct_decl));
-    
+
     if (!struct_layout)
         return;
-    
-    m_function.m_struct_size = struct_layout->getSize().getQuantity(); // TODO Store m_struct_size as CharUnits   
+
+    m_function.m_struct_size = struct_layout->getSize().getQuantity(); // TODO Store m_struct_size as CharUnits
     m_function.m_return_offset = struct_layout->getFieldOffset(struct_layout->getFieldCount() - 1) / 8;
     m_function.m_return_size = struct_layout->getDataSize().getQuantity() - m_function.m_return_offset;
-    
+
     for (unsigned field_index = 0, num_fields = struct_layout->getFieldCount();
          field_index < num_fields;
          ++field_index)
     {
         m_function.m_member_offsets.push_back(struct_layout->getFieldOffset(field_index) / 8);
     }
-    
+
     m_function.m_struct_valid = true;
 }
 
@@ -122,11 +122,11 @@ void
 ASTStructExtractor::ExtractFromTopLevelDecl(Decl* D)
 {
     LinkageSpecDecl *linkage_spec_decl = dyn_cast<LinkageSpecDecl>(D);
-    
+
     if (linkage_spec_decl)
     {
         RecordDecl::decl_iterator decl_iterator;
-        
+
         for (decl_iterator = linkage_spec_decl->decls_begin();
              decl_iterator != linkage_spec_decl->decls_end();
              ++decl_iterator)
@@ -134,9 +134,9 @@ ASTStructExtractor::ExtractFromTopLevelD
             ExtractFromTopLevelDecl(*decl_iterator);
         }
     }
-    
+
     FunctionDecl *function_decl = dyn_cast<FunctionDecl>(D);
-    
+
     if (m_ast_context &&
         function_decl &&
         !m_function.m_wrapper_function_name.compare(function_decl->getNameAsString().c_str()))
@@ -145,20 +145,20 @@ ASTStructExtractor::ExtractFromTopLevelD
     }
 }
 
-bool 
+bool
 ASTStructExtractor::HandleTopLevelDecl(DeclGroupRef D)
 {
     DeclGroupRef::iterator decl_iterator;
-    
+
     for (decl_iterator = D.begin();
          decl_iterator != D.end();
          ++decl_iterator)
     {
         Decl *decl = *decl_iterator;
-        
+
         ExtractFromTopLevelDecl(decl);
     }
-    
+
     if (m_passthrough)
         return m_passthrough->HandleTopLevelDecl(D);
     return true;
@@ -166,12 +166,12 @@ ASTStructExtractor::HandleTopLevelDecl(D
 
 void
 ASTStructExtractor::HandleTranslationUnit(ASTContext &Ctx)
-{    
+{
     if (m_passthrough)
         m_passthrough->HandleTranslationUnit(Ctx);
 }
 
-void 
+void
 ASTStructExtractor::HandleTagDeclDefinition(TagDecl *D)
 {
     if (m_passthrough)
@@ -185,15 +185,15 @@ ASTStructExtractor::CompleteTentativeDef
         m_passthrough->CompleteTentativeDefinition(D);
 }
 
-void 
-ASTStructExtractor::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) 
+void
+ASTStructExtractor::HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired)
 {
     if (m_passthrough)
         m_passthrough->HandleVTable(RD, DefinitionRequired);
 }
 
 void
-ASTStructExtractor::PrintStats() 
+ASTStructExtractor::PrintStats()
 {
     if (m_passthrough)
         m_passthrough->PrintStats();
@@ -204,17 +204,17 @@ ASTStructExtractor::InitializeSema(Sema
 {
     m_sema = &S;
     m_action = reinterpret_cast<Action*>(m_sema);
-    
+
     if (m_passthrough_sema)
         m_passthrough_sema->InitializeSema(S);
 }
 
-void 
-ASTStructExtractor::ForgetSema() 
+void
+ASTStructExtractor::ForgetSema()
 {
     m_sema = NULL;
     m_action = NULL;
-    
+
     if (m_passthrough_sema)
         m_passthrough_sema->ForgetSema();
 }

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Sun Jul  6 12:54:58 2014
@@ -25,32 +25,32 @@
 using namespace clang;
 using namespace lldb_private;
 
-ClangASTSource::~ClangASTSource() 
+ClangASTSource::~ClangASTSource()
 {
     m_ast_importer->ForgetDestination(m_ast_context);
-    
+
     // We are in the process of destruction, don't create clang ast context on demand
     // by passing false to Target::GetScratchClangASTContext(create_on_demand).
     ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(false);
-    
+
     if (!scratch_clang_ast_context)
         return;
-    
+
     clang::ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
-    
+
     if (!scratch_ast_context)
         return;
-    
+
     if (m_ast_context != scratch_ast_context)
         m_ast_importer->ForgetSource(scratch_ast_context, m_ast_context);
 }
 
 void
-ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) 
+ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer)
 {
     if (!m_ast_context)
         return;
-    
+
     m_ast_context->getTranslationUnitDecl()->setHasExternalVisibleStorage();
     m_ast_context->getTranslationUnitDecl()->setHasExternalLexicalStorage();
 }
@@ -59,33 +59,33 @@ ClangASTSource::StartTranslationUnit(AST
 bool
 ClangASTSource::FindExternalVisibleDeclsByName
 (
-    const DeclContext *decl_ctx, 
+    const DeclContext *decl_ctx,
     DeclarationName clang_decl_name
-) 
+)
 {
     if (!m_ast_context)
     {
         SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
         return false;
     }
-    
+
     if (GetImportInProgress())
     {
         SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
         return false;
     }
-    
+
     std::string decl_name (clang_decl_name.getAsString());
 
 //    if (m_decl_map.DoingASTImport ())
 //      return DeclContext::lookup_result();
-//        
+//
     switch (clang_decl_name.getNameKind()) {
     // Normal identifiers.
     case DeclarationName::Identifier:
         {
             clang::IdentifierInfo *identifier_info = clang_decl_name.getAsIdentifierInfo();
-        
+
             if (!identifier_info ||
                 identifier_info->getBuiltinID() != 0)
             {
@@ -94,27 +94,27 @@ ClangASTSource::FindExternalVisibleDecls
             }
         }
         break;
-            
+
     // Operator names.  Not important for now.
     case DeclarationName::CXXOperatorName:
     case DeclarationName::CXXLiteralOperatorName:
       SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
       return false;
-            
+
     // Using directives found in this context.
     // Tell Sema we didn't find any or we'll end up getting asked a *lot*.
     case DeclarationName::CXXUsingDirective:
       SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
       return false;
-            
+
     case DeclarationName::ObjCZeroArgSelector:
     case DeclarationName::ObjCOneArgSelector:
     case DeclarationName::ObjCMultiArgSelector:
     {
-      llvm::SmallVector<NamedDecl*, 1> method_decls;    
+      llvm::SmallVector<NamedDecl*, 1> method_decls;
 
       NameSearchContext method_search_context (*this, method_decls, clang_decl_name, decl_ctx);
-     
+
       FindObjCMethodDecls(method_search_context);
 
       SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
@@ -131,21 +131,21 @@ ClangASTSource::FindExternalVisibleDecls
 
     if (!GetLookupsEnabled())
     {
-        // Wait until we see a '$' at the start of a name before we start doing 
+        // Wait until we see a '$' at the start of a name before we start doing
         // any lookups so we can avoid lookup up all of the builtin types.
         if (!decl_name.empty() && decl_name[0] == '$')
         {
             SetLookupsEnabled (true);
         }
         else
-        {               
+        {
             SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
             return false;
         }
     }
 
     ConstString const_decl_name(decl_name.c_str());
-    
+
     const char *uniqued_const_decl_name = const_decl_name.GetCString();
     if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end())
     {
@@ -157,7 +157,7 @@ ClangASTSource::FindExternalVisibleDecls
 //  static uint32_t g_depth = 0;
 //  ++g_depth;
 //  printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth, uniqued_const_decl_name);
-    llvm::SmallVector<NamedDecl*, 4> name_decls;    
+    llvm::SmallVector<NamedDecl*, 4> name_decls;
     NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx);
     FindExternalVisibleDecls(name_search_context);
     SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls);
@@ -253,7 +253,7 @@ ClangASTSource::CompleteType (TagDecl *t
                 }
             }
         }
-        else 
+        else
         {
             TypeList types;
 
@@ -313,7 +313,7 @@ ClangASTSource::CompleteType (clang::Obj
                     interface_decl->getName().str().c_str());
         log->Printf("      [COID] Before:");
         ASTDumper dumper((Decl*)interface_decl);
-        dumper.ToLog(log, "      [COID] ");    
+        dumper.ToLog(log, "      [COID] ");
     }
 
     Decl *original_decl = NULL;
@@ -342,7 +342,7 @@ ClangASTSource::CompleteType (clang::Obj
     {
         log->Printf("      [COID] After:");
         ASTDumper dumper((Decl*)interface_decl);
-        dumper.ToLog(log, "      [COID] ");    
+        dumper.ToLog(log, "      [COID] ");
     }
 }
 
@@ -350,36 +350,36 @@ clang::ObjCInterfaceDecl *
 ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_decl)
 {
     lldb::ProcessSP process(m_target->GetProcessSP());
-    
+
     if (!process)
         return NULL;
-    
+
     ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
-    
+
     if (!language_runtime)
         return NULL;
-        
+
     ConstString class_name(interface_decl->getNameAsString().c_str());
-    
+
     lldb::TypeSP complete_type_sp(language_runtime->LookupInCompleteClassCache(class_name));
-    
+
     if (!complete_type_sp)
         return NULL;
-    
+
     TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType());
     lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType();
-    
+
     if (!complete_opaque_type)
         return NULL;
-    
+
     const clang::Type *complete_clang_type = QualType::getFromOpaquePtr(complete_opaque_type).getTypePtr();
     const ObjCInterfaceType *complete_interface_type = dyn_cast<ObjCInterfaceType>(complete_clang_type);
-    
+
     if (!complete_interface_type)
         return NULL;
-    
+
     ObjCInterfaceDecl *complete_iface_decl(complete_interface_type->getDecl());
-    
+
     return complete_iface_decl;
 }
 
@@ -608,133 +608,133 @@ ClangASTSource::FindExternalVisibleDecls
     }
 }
 
-void 
-ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context, 
+void
+ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
                                           lldb::ModuleSP module_sp,
                                           ClangNamespaceDecl &namespace_decl,
                                           unsigned int current_id)
 {
     assert (m_ast_context);
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     SymbolContextList sc_list;
-    
+
     const ConstString name(context.m_decl_name.getAsString().c_str());
-    
+
     const char *name_unique_cstr = name.GetCString();
-    
+
     static ConstString id_name("id");
     static ConstString Class_name("Class");
-    
+
     if (name == id_name || name == Class_name)
         return;
-    
+
     if (name_unique_cstr == NULL)
         return;
-    
+
     // The ClangASTSource is not responsible for finding $-names.
     if (name_unique_cstr[0] == '$')
         return;
-    
+
     if (module_sp && namespace_decl)
     {
         ClangNamespaceDecl found_namespace_decl;
-        
+
         SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
-        
+
         if (symbol_vendor)
         {
             SymbolContext null_sc;
-            
+
             found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
-            
+
             if (found_namespace_decl)
             {
                 context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl));
-                
+
                 if (log)
                     log->Printf("  CAS::FEVD[%u] Found namespace %s in module %s",
                                 current_id,
-                                name.GetCString(), 
+                                name.GetCString(),
                                 module_sp->GetFileSpec().GetFilename().GetCString());
             }
         }
     }
-    else 
+    else
     {
         const ModuleList &target_images = m_target->GetImages();
         Mutex::Locker modules_locker (target_images.GetMutex());
-        
+
         for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
         {
             lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
-            
+
             if (!image)
                 continue;
-            
+
             ClangNamespaceDecl found_namespace_decl;
-            
+
             SymbolVendor *symbol_vendor = image->GetSymbolVendor();
-            
+
             if (!symbol_vendor)
                 continue;
-            
+
             SymbolContext null_sc;
-            
+
             found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
-            
+
             if (found_namespace_decl)
             {
                 context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl));
-                
+
                 if (log)
                     log->Printf("  CAS::FEVD[%u] Found namespace %s in module %s",
                                 current_id,
-                                name.GetCString(), 
+                                name.GetCString(),
                                 image->GetFileSpec().GetFilename().GetCString());
             }
         }
     }
-    
-    do 
+
+    do
     {
         TypeList types;
         SymbolContext null_sc;
         const bool exact_match = false;
-      
+
         if (module_sp && namespace_decl)
             module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types);
-        else 
+        else
             m_target->GetImages().FindTypes(null_sc, name, exact_match, 1, types);
-        
+
         if (types.GetSize())
         {
             lldb::TypeSP type_sp = types.GetTypeAtIndex(0);
-            
+
             if (log)
             {
                 const char *name_string = type_sp->GetName().GetCString();
-                
-                log->Printf("  CAS::FEVD[%u] Matching type found for \"%s\": %s", 
-                            current_id, 
-                            name.GetCString(), 
+
+                log->Printf("  CAS::FEVD[%u] Matching type found for \"%s\": %s",
+                            current_id,
+                            name.GetCString(),
                             (name_string ? name_string : "<anonymous>"));
             }
-                        
+
             ClangASTType full_type = type_sp->GetClangFullType();
 
             ClangASTType copied_clang_type (GuardedCopyType(full_type));
-                
+
             if (!copied_clang_type)
-            {                
+            {
                 if (log)
                     log->Printf("  CAS::FEVD[%u] - Couldn't export a type",
                                 current_id);
-                    
+
                 break;
             }
-                
+
             context.AddTypeDecl(copied_clang_type);
         }
         else
@@ -742,55 +742,55 @@ ClangASTSource::FindExternalVisibleDecls
             do
             {
                 // Couldn't find any types elsewhere.  Try the Objective-C runtime if one exists.
-                
+
                 lldb::ProcessSP process(m_target->GetProcessSP());
-                
+
                 if (!process)
                     break;
-                
+
                 ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
-                
+
                 if (!language_runtime)
                     break;
-                
+
                 TypeVendor *type_vendor = language_runtime->GetTypeVendor();
-                
+
                 if (!type_vendor)
                     break;
-                
+
                 bool append = false;
                 uint32_t max_matches = 1;
                 std::vector <ClangASTType> types;
-                
+
                 if (!type_vendor->FindTypes(name,
                                             append,
                                             max_matches,
                                             types))
                     break;
-                
+
                 if (log)
-                {                    
+                {
                     log->Printf("  CAS::FEVD[%u] Matching type found for \"%s\" in the runtime",
                                 current_id,
                                 name.GetCString());
                 }
-                
+
                 ClangASTType copied_clang_type (GuardedCopyType(types[0]));
-                
+
                 if (!copied_clang_type)
                 {
                     if (log)
                         log->Printf("  CAS::FEVD[%u] - Couldn't export a type from the runtime",
                                     current_id);
-                    
+
                     break;
                 }
-                
+
                 context.AddTypeDecl(copied_clang_type);
             }
             while(0);
         }
-        
+
     } while(0);
 }
 
@@ -804,7 +804,7 @@ public:
     D *decl;
 };
 
-template <class D2, template <class D> class TD, class D1> 
+template <class D2, template <class D> class TD, class D1>
 TD<D2>
 DynCast(TD<D1> source)
 {
@@ -814,19 +814,19 @@ DynCast(TD<D1> source)
 template <class D = Decl> class DeclFromParser;
 template <class D = Decl> class DeclFromUser;
 
-template <class D> class DeclFromParser : public TaggedASTDecl<D> { 
+template <class D> class DeclFromParser : public TaggedASTDecl<D> {
 public:
     DeclFromParser() : TaggedASTDecl<D>() { }
     DeclFromParser(D *_decl) : TaggedASTDecl<D>(_decl) { }
-    
+
     DeclFromUser<D> GetOrigin(ClangASTImporter *importer);
 };
 
-template <class D> class DeclFromUser : public TaggedASTDecl<D> { 
+template <class D> class DeclFromUser : public TaggedASTDecl<D> {
 public:
     DeclFromUser() : TaggedASTDecl<D>() { }
     DeclFromUser(D *_decl) : TaggedASTDecl<D>(_decl) { }
-    
+
     DeclFromParser<D> Import(ClangASTImporter *importer, ASTContext &dest_ctx);
 };
 
@@ -863,7 +863,7 @@ FindObjCMethodDeclsWithOrigin (unsigned
     clang::ASTContext *original_ctx = &original_interface_decl->getASTContext();
 
     Selector original_selector;
-    
+
     if (decl_name.isObjCZeroArgSelector())
     {
         IdentifierInfo *ident = &original_ctx->Idents.get(decl_name.getAsString());
@@ -879,59 +879,59 @@ FindObjCMethodDeclsWithOrigin (unsigned
     else
     {
         SmallVector<IdentifierInfo *, 4> idents;
-        
+
         clang::Selector sel = decl_name.getObjCSelector();
-        
+
         unsigned num_args = sel.getNumArgs();
-        
+
         for (unsigned i = 0;
              i != num_args;
              ++i)
         {
             idents.push_back(&original_ctx->Idents.get(sel.getNameForSlot(i)));
         }
-        
+
         original_selector = original_ctx->Selectors.getSelector(num_args, idents.data());
     }
-    
+
     DeclarationName original_decl_name(original_selector);
-    
+
     ObjCInterfaceDecl::lookup_result result = original_interface_decl->lookup(original_decl_name);
-    
+
     if (result.empty())
         return false;
-    
+
     if (!result[0])
         return false;
-    
+
     for (NamedDecl *named_decl : result)
     {
         ObjCMethodDecl *result_method = dyn_cast<ObjCMethodDecl>(named_decl);
-        
+
         if (!result_method)
             return false;
-        
+
         Decl *copied_decl = ast_importer->CopyDecl(ast_context, &result_method->getASTContext(), result_method);
-        
+
         if (!copied_decl)
             return false;
-        
+
         ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
-        
+
         if (!copied_method_decl)
             return false;
-        
+
         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-        
+
         if (log)
         {
             ASTDumper dumper((Decl*)copied_method_decl);
             log->Printf("  CAS::FOMD[%d] found (%s) %s", current_id, log_info, dumper.GetCString());
         }
-        
+
         context.AddNamedDecl(copied_method_decl);
     }
-    
+
     return true;
 }
 
@@ -991,7 +991,7 @@ ClangASTSource::FindObjCMethodDecls (Nam
              ++i)
         {
             llvm::StringRef r = sel.getNameForSlot(i);
-            ss.Printf("%s:", r.str().c_str()); 
+            ss.Printf("%s:", r.str().c_str());
         }
     }
     ss.Flush();
@@ -1004,7 +1004,7 @@ ClangASTSource::FindObjCMethodDecls (Nam
     if (log)
         log->Printf("ClangASTSource::FindObjCMethodDecls[%d] on (ASTContext*)%p for selector [%s %s]",
                     current_id, static_cast<void*>(m_ast_context),
-                    interface_decl->getNameAsString().c_str(), 
+                    interface_decl->getNameAsString().c_str(),
                     selector_name.AsCString());
     SymbolContextList sc_list;
 
@@ -1220,7 +1220,7 @@ ClangASTSource::FindObjCMethodDecls (Nam
 }
 
 static bool
-FindObjCPropertyAndIvarDeclsWithOrigin (unsigned int current_id, 
+FindObjCPropertyAndIvarDeclsWithOrigin (unsigned int current_id,
                                         NameSearchContext &context,
                                         clang::ASTContext &ast_context,
                                         ClangASTImporter *ast_importer,
@@ -1230,15 +1230,15 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
 
     if (origin_iface_decl.IsInvalid())
         return false;
-    
+
     std::string name_str = context.m_decl_name.getAsString();
     StringRef name(name_str.c_str());
     IdentifierInfo &name_identifier(origin_iface_decl->getASTContext().Idents.get(name));
-    
+
     DeclFromUser<ObjCPropertyDecl> origin_property_decl(origin_iface_decl->FindPropertyDeclaration(&name_identifier));
-    
+
     bool found = false;
-    
+
     if (origin_property_decl.IsValid())
     {
         DeclFromParser<ObjCPropertyDecl> parser_property_decl(origin_property_decl.Import(ast_importer, ast_context));
@@ -1249,14 +1249,14 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
                 ASTDumper dumper((Decl*)parser_property_decl.decl);
                 log->Printf("  CAS::FOPD[%d] found %s", current_id, dumper.GetCString());
             }
-            
+
             context.AddNamedDecl(parser_property_decl.decl);
             found = true;
         }
     }
-    
+
     DeclFromUser<ObjCIvarDecl> origin_ivar_decl(origin_iface_decl->getIvarDecl(&name_identifier));
-    
+
     if (origin_ivar_decl.IsValid())
     {
         DeclFromParser<ObjCIvarDecl> parser_ivar_decl(origin_ivar_decl.Import(ast_importer, ast_context));
@@ -1267,12 +1267,12 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
                 ASTDumper dumper((Decl*)parser_ivar_decl.decl);
                 log->Printf("  CAS::FOPD[%d] found %s", current_id, dumper.GetCString());
             }
-            
+
             context.AddNamedDecl(parser_ivar_decl.decl);
             found = true;
         }
     }
-    
+
     return found;
 }
 
@@ -1292,13 +1292,13 @@ ClangASTSource::FindObjCPropertyAndIvarD
     if (log)
         log->Printf("ClangASTSource::FindObjCPropertyAndIvarDecls[%d] on (ASTContext*)%p for '%s.%s'",
                     current_id, static_cast<void*>(m_ast_context),
-                    parser_iface_decl->getNameAsString().c_str(), 
+                    parser_iface_decl->getNameAsString().c_str(),
                     context.m_decl_name.getAsString().c_str());
 
-    if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id, 
-                                               context, 
-                                               *m_ast_context, 
-                                               m_ast_importer, 
+    if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
+                                               context,
+                                               *m_ast_context,
+                                               m_ast_importer,
                                                origin_iface_decl))
         return;
 
@@ -1330,10 +1330,10 @@ ClangASTSource::FindObjCPropertyAndIvarD
                         static_cast<const void*>(complete_iface_decl.decl),
                         static_cast<void*>(&complete_iface_decl->getASTContext()));
 
-        FindObjCPropertyAndIvarDeclsWithOrigin(current_id, 
-                                               context, 
-                                               *m_ast_context, 
-                                               m_ast_importer, 
+        FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
+                                               context,
+                                               *m_ast_context,
+                                               m_ast_importer,
                                                complete_iface_decl);
 
         return;
@@ -1399,13 +1399,13 @@ typedef llvm::DenseMap <const CXXRecordD
 
 template <class D, class O>
 static bool
-ImportOffsetMap (llvm::DenseMap <const D*, O> &destination_map, 
+ImportOffsetMap (llvm::DenseMap <const D*, O> &destination_map,
                  llvm::DenseMap <const D*, O> &source_map,
                  ClangASTImporter *importer,
                  ASTContext &dest_ctx)
 {
     typedef llvm::DenseMap <const D*, O> MapType;
-    
+
     for (typename MapType::iterator fi = source_map.begin(), fe = source_map.end();
          fi != fe;
          ++fi)
@@ -1416,7 +1416,7 @@ ImportOffsetMap (llvm::DenseMap <const D
             return false;
         destination_map.insert(std::pair<const D *, O>(parser_decl.decl, fi->second));
     }
-    
+
     return true;
 }
 
@@ -1424,47 +1424,47 @@ template <bool IsVirtual> bool ExtractBa
                                                    DeclFromUser<const CXXRecordDecl> &record,
                                                    BaseOffsetMap &base_offsets)
 {
-    for (CXXRecordDecl::base_class_const_iterator 
-            bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()), 
+    for (CXXRecordDecl::base_class_const_iterator
+            bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()),
             be = (IsVirtual ? record->vbases_end() : record->bases_end());
          bi != be;
          ++bi)
     {
         if (!IsVirtual && bi->isVirtual())
             continue;
-        
+
         const clang::Type *origin_base_type = bi->getType().getTypePtr();
         const clang::RecordType *origin_base_record_type = origin_base_type->getAs<RecordType>();
-        
+
         if (!origin_base_record_type)
             return false;
-        
+
         DeclFromUser <RecordDecl> origin_base_record(origin_base_record_type->getDecl());
-        
+
         if (origin_base_record.IsInvalid())
             return false;
-        
+
         DeclFromUser <CXXRecordDecl> origin_base_cxx_record(DynCast<CXXRecordDecl>(origin_base_record));
-        
+
         if (origin_base_cxx_record.IsInvalid())
             return false;
-        
+
         CharUnits base_offset;
-        
+
         if (IsVirtual)
             base_offset = record_layout.getVBaseClassOffset(origin_base_cxx_record.decl);
         else
             base_offset = record_layout.getBaseClassOffset(origin_base_cxx_record.decl);
-        
+
         base_offsets.insert(std::pair<const CXXRecordDecl *, CharUnits>(origin_base_cxx_record.decl, base_offset));
     }
-    
+
     return true;
 }
-                         
-bool 
+
+bool
 ClangASTSource::layoutRecordType(const RecordDecl *record,
-                                 uint64_t &size, 
+                                 uint64_t &size,
                                  uint64_t &alignment,
                                  FieldOffsetMap &field_offsets,
                                  BaseOffsetMap &base_offsets,
@@ -1584,7 +1584,7 @@ ClangASTSource::layoutRecordType(const R
     return true;
 }
 
-void 
+void
 ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map,
                                       const ConstString &name,
                                       ClangASTImporter::NamespaceMapSP &parent_map) const
@@ -1635,7 +1635,7 @@ ClangASTSource::CompleteNamespaceMap (Cl
             if (log)
                 log->Printf("  CMN[%u] Found namespace %s in module %s",
                             current_id,
-                            name.GetCString(), 
+                            name.GetCString(),
                             module_sp->GetFileSpec().GetFilename().GetCString());
         }
     }
@@ -1672,7 +1672,7 @@ ClangASTSource::CompleteNamespaceMap (Cl
             if (log)
                 log->Printf("  CMN[%u] Found namespace %s in module %s",
                             current_id,
-                            name.GetCString(), 
+                            name.GetCString(),
                             image->GetFileSpec().GetFilename().GetCString());
         }
     }
@@ -1683,23 +1683,23 @@ ClangASTSource::AddNamespace (NameSearch
 {
     if (!namespace_decls)
         return NULL;
-    
+
     const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
-    
+
     Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
-    
+
     if (!copied_decl)
         return NULL;
-        
+
     NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
-    
+
     if (!copied_namespace_decl)
         return NULL;
-    
+
     context.m_decls.push_back(copied_namespace_decl);
-    
+
     m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
-    
+
     return dyn_cast<NamespaceDecl>(copied_decl);
 }
 
@@ -1707,18 +1707,18 @@ ClangASTType
 ClangASTSource::GuardedCopyType (const ClangASTType &src_type)
 {
     ClangASTMetrics::RegisterLLDBImport();
-    
+
     SetImportInProgress(true);
-    
+
     QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_type.GetASTContext(), src_type.GetQualType());
-    
+
     SetImportInProgress(false);
-    
+
     if (copied_qual_type.getAsOpaquePtr() && copied_qual_type->getCanonicalTypeInternal().isNull())
         // this shouldn't happen, but we're hardening because the AST importer seems to be generating bad types
         // on occasion.
         return ClangASTType();
-    
+
     return ClangASTType(m_ast_context, copied_qual_type);
 }
 
@@ -1729,39 +1729,39 @@ NameSearchContext::AddVarDecl(const Clan
 
     if (!type.IsValid())
         return NULL;
-    
+
     IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
-    
+
     clang::ASTContext *ast = type.GetASTContext();
 
     clang::NamedDecl *Decl = VarDecl::Create(*ast,
-                                             const_cast<DeclContext*>(m_decl_context), 
-                                             SourceLocation(), 
+                                             const_cast<DeclContext*>(m_decl_context),
                                              SourceLocation(),
-                                             ii, 
+                                             SourceLocation(),
+                                             ii,
                                              type.GetQualType(),
-                                             0, 
+                                             0,
                                              SC_Static);
     m_decls.push_back(Decl);
-    
+
     return Decl;
 }
 
 clang::NamedDecl *
-NameSearchContext::AddFunDecl (const ClangASTType &type) 
+NameSearchContext::AddFunDecl (const ClangASTType &type)
 {
     assert (type && "Type for variable must be valid!");
-    
+
     if (!type.IsValid())
         return NULL;
 
     if (m_function_types.count(type))
         return NULL;
-    
+
     m_function_types.insert(type);
-    
+
     QualType qual_type (type.GetQualType());
-    
+
     clang::ASTContext *ast = type.GetASTContext();
 
     const bool isInlineSpecified = false;
@@ -1783,20 +1783,20 @@ NameSearchContext::AddFunDecl (const Cla
     // We have to do more than just synthesize the FunctionDecl.  We have to
     // synthesize ParmVarDecls for all of the FunctionDecl's arguments.  To do
     // this, we raid the function's FunctionProtoType for types.
-    
+
     const FunctionProtoType *func_proto_type = qual_type.getTypePtr()->getAs<FunctionProtoType>();
-    
+
     if (func_proto_type)
-    {        
+    {
         unsigned NumArgs = func_proto_type->getNumParams();
         unsigned ArgIndex;
-        
+
         SmallVector<ParmVarDecl *, 5> parm_var_decls;
-                
+
         for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex)
         {
             QualType arg_qual_type (func_proto_type->getParamType(ArgIndex));
-            
+
             parm_var_decls.push_back(ParmVarDecl::Create (*ast,
                                                           const_cast<DeclContext*>(m_decl_context),
                                                           SourceLocation(),
@@ -1807,7 +1807,7 @@ NameSearchContext::AddFunDecl (const Cla
                                                           SC_Static,
                                                           NULL));
         }
-        
+
         func_decl->setParams(ArrayRef<ParmVarDecl*>(parm_var_decls));
     }
     else
@@ -1817,9 +1817,9 @@ NameSearchContext::AddFunDecl (const Cla
         if (log)
             log->Printf("Function type wasn't a FunctionProtoType");
     }
-    
+
     m_decls.push_back(func_decl);
-    
+
     return func_decl;
 }
 
@@ -1827,13 +1827,13 @@ clang::NamedDecl *
 NameSearchContext::AddGenericFunDecl()
 {
     FunctionProtoType::ExtProtoInfo proto_info;
-    
+
     proto_info.Variadic = true;
-    
+
     QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType (m_ast_source.m_ast_context->UnknownAnyTy,    // result
                                                                                 ArrayRef<QualType>(),                                        // argument types
                                                                                 proto_info));
-    
+
     return AddFunDecl(ClangASTType (m_ast_source.m_ast_context, generic_function_type));
 }
 
@@ -1847,32 +1847,32 @@ NameSearchContext::AddTypeDecl(const Cla
         if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type))
         {
             TypedefNameDecl *typedef_name_decl = typedef_type->getDecl();
-            
+
             m_decls.push_back(typedef_name_decl);
-            
+
             return (NamedDecl*)typedef_name_decl;
         }
         else if (const TagType *tag_type = qual_type->getAs<TagType>())
         {
             TagDecl *tag_decl = tag_type->getDecl();
-            
+
             m_decls.push_back(tag_decl);
-            
+
             return tag_decl;
         }
         else if (const ObjCObjectType *objc_object_type = qual_type->getAs<ObjCObjectType>())
         {
             ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface();
-            
+
             m_decls.push_back((NamedDecl*)interface_decl);
-            
+
             return (NamedDecl*)interface_decl;
         }
     }
     return NULL;
 }
 
-void 
+void
 NameSearchContext::AddLookupResult (clang::DeclContextLookupConstResult result)
 {
     for (clang::NamedDecl *decl : result)

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Sun Jul  6 12:54:58 2014
@@ -8,11 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Expression/ClangExpressionDeclMap.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Decl.h"
@@ -68,21 +63,21 @@ ClangExpressionDeclMap::~ClangExpression
 {
     // Note: The model is now that the parser's AST context and all associated
     //   data does not vanish until the expression has been executed.  This means
-    //   that valuable lookup data (like namespaces) doesn't vanish, but 
-    
+    //   that valuable lookup data (like namespaces) doesn't vanish, but
+
     DidParse();
     DisableStructVars();
 }
 
-bool 
+bool
 ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
                                   Materializer *materializer)
 {
     ClangASTMetrics::ClearLocalCounters();
-    
+
     EnableParserVars();
     m_parser_vars->m_exe_ctx = exe_ctx;
-    
+
     Target *target = exe_ctx.GetTargetPtr();
     if (exe_ctx.GetFramePtr())
         m_parser_vars->m_sym_ctx = exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
@@ -98,18 +93,18 @@ ClangExpressionDeclMap::WillParse(Execut
         m_parser_vars->m_sym_ctx.Clear(true);
         m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
     }
-    
+
     if (target)
     {
         m_parser_vars->m_persistent_vars = &target->GetPersistentVariables();
-    
+
         if (!target->GetScratchClangASTContext())
             return false;
     }
-    
+
     m_parser_vars->m_target_info = GetTargetInfo();
     m_parser_vars->m_materializer = materializer;
-    
+
     return true;
 }
 
@@ -120,7 +115,7 @@ ClangExpressionDeclMap::DidParse()
 
     if (log)
         ClangASTMetrics::DumpCounters(log);
-    
+
     if (m_parser_vars.get())
     {
         for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
@@ -131,7 +126,7 @@ ClangExpressionDeclMap::DidParse()
             if (var_sp)
                 var_sp->DisableParserVars(GetParserID());
         }
-        
+
         for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize();
              pvar_index < num_pvars;
              ++pvar_index)
@@ -140,20 +135,20 @@ ClangExpressionDeclMap::DidParse()
             if (pvar_sp)
                 pvar_sp->DisableParserVars(GetParserID());
         }
-        
+
         DisableParserVars();
     }
 }
 
 // Interface for IRForTarget
 
-ClangExpressionDeclMap::TargetInfo 
+ClangExpressionDeclMap::TargetInfo
 ClangExpressionDeclMap::GetTargetInfo()
 {
     assert (m_parser_vars.get());
-    
+
     TargetInfo ret;
-    
+
     ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
 
     Process *process = exe_ctx.GetProcessPtr();
@@ -162,7 +157,7 @@ ClangExpressionDeclMap::GetTargetInfo()
         ret.byte_order = process->GetByteOrder();
         ret.address_byte_size = process->GetAddressByteSize();
     }
-    else 
+    else
     {
         Target *target = exe_ctx.GetTargetPtr();
         if (target)
@@ -175,61 +170,61 @@ ClangExpressionDeclMap::GetTargetInfo()
     return ret;
 }
 
-bool 
-ClangExpressionDeclMap::AddPersistentVariable 
+bool
+ClangExpressionDeclMap::AddPersistentVariable
 (
-    const NamedDecl *decl, 
-    const ConstString &name, 
+    const NamedDecl *decl,
+    const ConstString &name,
     TypeFromParser parser_type,
     bool is_result,
     bool is_lvalue
 )
 {
     assert (m_parser_vars.get());
-    
+
     if (m_parser_vars->m_materializer && is_result)
     {
         Error err;
-        
+
         ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
         Target *target = exe_ctx.GetTargetPtr();
         if (target == NULL)
             return false;
-        
+
         ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
-        
+
         TypeFromUser user_type(m_ast_importer->DeportType(context,
                                                           parser_type.GetASTContext(),
                                                           parser_type.GetOpaqueQualType()),
                                context);
-        
+
         uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(user_type, is_lvalue, m_keep_result_in_memory, err);
-        
+
         ClangExpressionVariableSP var_sp = m_found_entities.CreateVariable(exe_ctx.GetBestExecutionContextScope(),
                                                                            name,
                                                                            user_type,
                                                                            m_parser_vars->m_target_info.byte_order,
                                                                            m_parser_vars->m_target_info.address_byte_size);
-        
+
         if (!var_sp)
             return false;
-        
+
         var_sp->EnableParserVars(GetParserID());
-        
+
         ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
 
         parser_vars->m_named_decl = decl;
         parser_vars->m_parser_type = parser_type;
-        
+
         var_sp->EnableJITVars(GetParserID());
-        
+
         ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
-        
+
         jit_vars->m_offset = offset;
-        
+
         return true;
     }
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
     Target *target = exe_ctx.GetTargetPtr();
@@ -237,38 +232,38 @@ ClangExpressionDeclMap::AddPersistentVar
         return false;
 
     ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
-    
-    TypeFromUser user_type(m_ast_importer->DeportType(context, 
+
+    TypeFromUser user_type(m_ast_importer->DeportType(context,
                                                       parser_type.GetASTContext(),
                                                       parser_type.GetOpaqueQualType()),
                            context);
-    
+
     if (!user_type.GetOpaqueQualType())
     {
         if (log)
             log->Printf("Persistent variable's type wasn't copied successfully");
         return false;
     }
-        
+
     if (!m_parser_vars->m_target_info.IsValid())
         return false;
-    
+
     ClangExpressionVariableSP var_sp = m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx.GetBestExecutionContextScope (),
                                                                                                    name,
                                                                                                    user_type,
                                                                                                    m_parser_vars->m_target_info.byte_order,
                                                                                                    m_parser_vars->m_target_info.address_byte_size);
-    
+
     if (!var_sp)
         return false;
-    
+
     var_sp->m_frozen_sp->SetHasCompleteType();
-    
+
     if (is_result)
         var_sp->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
     else
         var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget; // explicitly-declared persistent variables should persist
-    
+
     if (is_lvalue)
     {
         var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
@@ -278,27 +273,27 @@ ClangExpressionDeclMap::AddPersistentVar
         var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
         var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
     }
-    
+
     if (m_keep_result_in_memory)
     {
         var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
     }
-    
+
     if (log)
         log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
-    
+
     var_sp->EnableParserVars(GetParserID());
-    
+
     ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
-    
+
     parser_vars->m_named_decl = decl;
     parser_vars->m_parser_type = parser_type;
-    
+
     return true;
 }
 
-bool 
-ClangExpressionDeclMap::AddValueToStruct 
+bool
+ClangExpressionDeclMap::AddValueToStruct
 (
     const NamedDecl *decl,
     const ConstString &name,
@@ -395,20 +390,20 @@ bool
 ClangExpressionDeclMap::DoStructLayout ()
 {
     assert (m_struct_vars.get());
-    
+
     if (m_struct_vars->m_struct_laid_out)
         return true;
-    
+
     if (!m_parser_vars->m_materializer)
         return false;
-    
+
     m_struct_vars->m_struct_alignment = m_parser_vars->m_materializer->GetStructAlignment();
     m_struct_vars->m_struct_size = m_parser_vars->m_materializer->GetStructByteSize();
     m_struct_vars->m_struct_laid_out = true;
     return true;
 }
 
-bool ClangExpressionDeclMap::GetStructInfo 
+bool ClangExpressionDeclMap::GetStructInfo
 (
     uint32_t &num_elements,
     size_t &size,
@@ -416,19 +411,19 @@ bool ClangExpressionDeclMap::GetStructIn
 )
 {
     assert (m_struct_vars.get());
-    
+
     if (!m_struct_vars->m_struct_laid_out)
         return false;
-    
+
     num_elements = m_struct_members.GetSize();
     size = m_struct_vars->m_struct_size;
     alignment = m_struct_vars->m_struct_alignment;
-    
+
     return true;
 }
 
-bool 
-ClangExpressionDeclMap::GetStructElement 
+bool
+ClangExpressionDeclMap::GetStructElement
 (
     const NamedDecl *&decl,
     llvm::Value *&value,
@@ -438,38 +433,38 @@ ClangExpressionDeclMap::GetStructElement
 )
 {
     assert (m_struct_vars.get());
-    
+
     if (!m_struct_vars->m_struct_laid_out)
         return false;
-    
+
     if (index >= m_struct_members.GetSize())
         return false;
-    
+
     ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
-    
+
     if (!member_sp)
         return false;
-    
+
     ClangExpressionVariable::ParserVars *parser_vars = member_sp->GetParserVars(GetParserID());
     ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
-    
+
     if (!parser_vars ||
         !jit_vars ||
         !member_sp->GetValueObject())
         return false;
-    
+
     decl = parser_vars->m_named_decl;
     value = parser_vars->m_llvm_value;
     offset = jit_vars->m_offset;
     name = member_sp->GetName();
-        
+
     return true;
 }
 
 bool
-ClangExpressionDeclMap::GetFunctionInfo 
+ClangExpressionDeclMap::GetFunctionInfo
 (
-    const NamedDecl *decl, 
+    const NamedDecl *decl,
     uint64_t &ptr
 )
 {
@@ -477,14 +472,14 @@ ClangExpressionDeclMap::GetFunctionInfo
 
     if (!entity_sp)
         return false;
-    
+
     // We know m_parser_vars is valid since we searched for the variable by
     // its NamedDecl
-    
+
     ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
 
     ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
-    
+
     return true;
 }
 
@@ -499,7 +494,7 @@ FindCodeSymbolInContext
     SymbolContextList temp_sc_list;
     if (sym_ctx.module_sp)
         sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list);
-    
+
     if (!sc_list.GetSize() && sym_ctx.target_sp)
         sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list);
 
@@ -526,14 +521,14 @@ FindCodeSymbolInContext
 }
 
 bool
-ClangExpressionDeclMap::GetFunctionAddress 
+ClangExpressionDeclMap::GetFunctionAddress
 (
     const ConstString &name,
     uint64_t &func_addr
 )
 {
     assert (m_parser_vars.get());
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
     Target *target = exe_ctx.GetTargetPtr();
@@ -544,25 +539,25 @@ ClangExpressionDeclMap::GetFunctionAddre
         return false;
 
     SymbolContextList sc_list;
-    
+
     FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
 
     uint32_t sc_list_size = sc_list.GetSize();
     if (sc_list_size == 0)
     {
-        // We occasionally get debug information in which a const function is reported 
+        // We occasionally get debug information in which a const function is reported
         // as non-const, so the mangled name is wrong.  This is a hack to compensate.
-        
+
         if (!strncmp(name.GetCString(), "_ZN", 3) &&
             strncmp(name.GetCString(), "_ZNK", 4))
         {
             std::string fixed_scratch("_ZNK");
             fixed_scratch.append(name.GetCString() + 3);
             ConstString fixed_name(fixed_scratch.c_str());
-            
+
             if (log)
                 log->Printf("Failed to find symbols given non-const name %s; trying %s", name.GetCString(), fixed_name.GetCString());
-            
+
             FindCodeSymbolInContext(fixed_name, m_parser_vars->m_sym_ctx, sc_list);
             sc_list_size = sc_list.GetSize();
         }
@@ -574,7 +569,7 @@ ClangExpressionDeclMap::GetFunctionAddre
         sc_list.GetContextAtIndex(i, sym_ctx);
 
         lldb::addr_t callable_load_addr = LLDB_INVALID_ADDRESS;
-        
+
         if (sym_ctx.function)
         {
             const Address func_so_addr = sym_ctx.function->GetAddressRange().GetBaseAddress();
@@ -605,12 +600,12 @@ ClangExpressionDeclMap::GetSymbolAddress
                                           lldb_private::Module *module)
 {
     SymbolContextList sc_list;
-    
+
     if (module)
         module->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
     else
         target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
-    
+
     const uint32_t num_matches = sc_list.GetSize();
     addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
 
@@ -618,12 +613,12 @@ ClangExpressionDeclMap::GetSymbolAddress
     {
         SymbolContext sym_ctx;
         sc_list.GetContextAtIndex(i, sym_ctx);
-    
+
         const Address *sym_address = &sym_ctx.symbol->GetAddress();
-        
+
         if (!sym_address || !sym_address->IsValid())
             continue;
-        
+
         if (sym_address)
         {
             switch (sym_ctx.symbol->GetType())
@@ -689,17 +684,17 @@ ClangExpressionDeclMap::GetSymbolAddress
             }
         }
     }
-    
+
     if (symbol_load_addr == LLDB_INVALID_ADDRESS && process)
     {
         ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
-        
+
         if (runtime)
         {
             symbol_load_addr = runtime->LookupRuntimeSymbol(name);
         }
     }
-    
+
     return symbol_load_addr;
 }
 
@@ -707,10 +702,10 @@ addr_t
 ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name, lldb::SymbolType symbol_type)
 {
     assert (m_parser_vars.get());
-    
+
     if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
         return false;
-    
+
     return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(), m_parser_vars->m_exe_ctx.GetProcessPtr(), name, symbol_type);
 }
 
@@ -720,12 +715,12 @@ ClangExpressionDeclMap::FindGlobalDataSy
                                               lldb_private::Module *module)
 {
     SymbolContextList sc_list;
-    
+
     if (module)
         module->FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
     else
         target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
-    
+
     const uint32_t matches = sc_list.GetSize();
     for (uint32_t i=0; i<matches; ++i)
     {
@@ -735,7 +730,7 @@ ClangExpressionDeclMap::FindGlobalDataSy
         {
             const Symbol *symbol = sym_ctx.symbol;
             const Address *sym_address = &symbol->GetAddress();
-            
+
             if (sym_address && sym_address->IsValid())
             {
                 switch (symbol->GetType())
@@ -777,7 +772,7 @@ ClangExpressionDeclMap::FindGlobalDataSy
                             }
                         }
                         break;
-                        
+
                     case eSymbolTypeCode: // We already lookup functions elsewhere
                     case eSymbolTypeVariable:
                     case eSymbolTypeLocal:
@@ -805,7 +800,7 @@ ClangExpressionDeclMap::FindGlobalDataSy
             }
         }
     }
-    
+
     return NULL;
 }
 
@@ -820,12 +815,12 @@ ClangExpressionDeclMap::FindGlobalVariab
 )
 {
     VariableList vars;
-    
+
     if (module && namespace_decl)
         module->FindGlobalVariables (name, namespace_decl, true, -1, vars);
     else
         target.GetImages().FindGlobalVariables(name, true, -1, vars);
-    
+
     if (vars.GetSize())
     {
         if (type)
@@ -833,7 +828,7 @@ ClangExpressionDeclMap::FindGlobalVariab
             for (size_t i = 0; i < vars.GetSize(); ++i)
             {
                 VariableSP var_sp = vars.GetVariableAtIndex(i);
-                
+
                 if (ClangASTContext::AreTypesSame(*type, var_sp->GetType()->GetClangFullType()))
                     return var_sp;
             }
@@ -843,7 +838,7 @@ ClangExpressionDeclMap::FindGlobalVariab
             return vars.GetVariableAtIndex(0);
         }
     }
-    
+
     return VariableSP();
 }
 
@@ -885,7 +880,7 @@ ClangExpressionDeclMap::FindExternalVisi
         ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context);
 
         if (log && log->GetVerbose())
-            log->Printf("  CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)", 
+            log->Printf("  CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
                         current_id, static_cast<void*>(namespace_map.get()),
                         (int)namespace_map->size());
 
@@ -925,51 +920,51 @@ ClangExpressionDeclMap::FindExternalVisi
         ClangASTSource::FindExternalVisibleDecls(context);
 }
 
-void 
-ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, 
+void
+ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
                                                   lldb::ModuleSP module_sp,
                                                   ClangNamespaceDecl &namespace_decl,
                                                   unsigned int current_id)
 {
     assert (m_ast_context);
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     SymbolContextList sc_list;
-    
+
     const ConstString name(context.m_decl_name.getAsString().c_str());
-    
+
     const char *name_unique_cstr = name.GetCString();
-    
+
     if (name_unique_cstr == NULL)
         return;
-    
+
     static ConstString id_name("id");
     static ConstString Class_name("Class");
-    
+
     if (name == id_name || name == Class_name)
         return;
-    
-    // Only look for functions by name out in our symbols if the function 
+
+    // Only look for functions by name out in our symbols if the function
     // doesn't start with our phony prefix of '$'
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
     StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
     if (name_unique_cstr[0] == '$' && !namespace_decl)
     {
         static ConstString g_lldb_class_name ("$__lldb_class");
-        
+
         if (name == g_lldb_class_name)
         {
             // Clang is looking for the type of "this"
-                        
+
             if (frame == NULL)
                 return;
-            
+
             SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction);
-            
+
             if (!sym_ctx.function)
                 return;
-            
+
             // Get the block that defines the function
             Block *function_block = sym_ctx.GetFunctionBlock();
 
@@ -977,59 +972,59 @@ ClangExpressionDeclMap::FindExternalVisi
                 return;
 
             clang::DeclContext *decl_context = function_block->GetClangDeclContext();
-            
+
             if (!decl_context)
                 return;
-            
+
             clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context);
-            
+
             if (method_decl)
             {
                 clang::CXXRecordDecl *class_decl = method_decl->getParent();
-                
+
                 QualType class_qual_type(class_decl->getTypeForDecl(), 0);
-                
+
                 TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(),
                                               &class_decl->getASTContext());
-                
+
                 if (log)
                 {
                     ASTDumper ast_dumper(class_qual_type);
                     log->Printf("  CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
                 }
-                
+
                 TypeFromParser class_type = CopyClassType(class_user_type, current_id);
-                
+
                 if (!class_type.IsValid())
                     return;
-                
+
                 TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(class_type.GetOpaqueQualType()));
-                
+
                 if (!type_source_info)
                     return;
-                
+
                 TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
                                                                 m_ast_context->getTranslationUnitDecl(),
                                                                 SourceLocation(),
                                                                 SourceLocation(),
                                                                 context.m_decl_name.getAsIdentifierInfo(),
                                                                 type_source_info);
-                
-                
+
+
                 if (!typedef_decl)
                     return;
-                
+
                 context.AddNamedDecl(typedef_decl);
-                
+
                 if (method_decl->isInstance())
                 {
                     // self is a pointer to the object
-                    
+
                     QualType class_pointer_type = method_decl->getASTContext().getPointerType(class_qual_type);
-                    
+
                     TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
                                                 &method_decl->getASTContext());
-                    
+
                     m_struct_vars->m_object_pointer_type = self_user_type;
                 }
             }
@@ -1041,22 +1036,22 @@ ClangExpressionDeclMap::FindExternalVisi
                 // scope and use its type.
                 // FIXME: This code is formally correct, but clang doesn't currently emit DW_AT_object_pointer
                 // for C++ so it hasn't actually been tested.
-                
+
                 VariableList *vars = frame->GetVariableList(false);
-                
+
                 lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
-                
+
                 if (this_var &&
                     this_var->IsInScope(frame) &&
                     this_var->LocationIsValidForFrame (frame))
                 {
                     Type *this_type = this_var->GetType();
-                    
+
                     if (!this_type)
                         return;
-                    
+
                     ClangASTType pointee_type = this_type->GetClangForwardType().GetPointeeType();
-                    
+
                     if (pointee_type.IsValid())
                     {
                         if (log)
@@ -1064,89 +1059,89 @@ ClangExpressionDeclMap::FindExternalVisi
                             ASTDumper ast_dumper(this_type->GetClangFullType());
                             log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
                         }
-                        
+
                         TypeFromUser class_user_type(pointee_type);
                         AddOneType(context, class_user_type, current_id);
-                                    
-                                    
+
+
                         TypeFromUser this_user_type(this_type->GetClangFullType());
                         m_struct_vars->m_object_pointer_type = this_user_type;
                         return;
                     }
                 }
             }
-            
+
             return;
         }
-        
+
         static ConstString g_lldb_objc_class_name ("$__lldb_objc_class");
         if (name == g_lldb_objc_class_name)
         {
             // Clang is looking for the type of "*self"
-            
+
             if (!frame)
                 return;
-         
+
             SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction);
-            
+
             if (!sym_ctx.function)
                 return;
-            
+
             // Get the block that defines the function
             Block *function_block = sym_ctx.GetFunctionBlock();
-            
+
             if (!function_block)
                 return;
-            
+
             clang::DeclContext *decl_context = function_block->GetClangDeclContext();
-            
+
             if (!decl_context)
                 return;
-            
+
             clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_context);
-            
+
             if (method_decl)
             {
                 ObjCInterfaceDecl* self_interface = method_decl->getClassInterface();
-                
+
                 if (!self_interface)
                     return;
-                
+
                 const clang::Type *interface_type = self_interface->getTypeForDecl();
-                
+
                 if (!interface_type)
                     return; // This is unlikely, but we have seen crashes where this occurred
-                        
+
                 TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
                                              &method_decl->getASTContext());
-                
+
                 if (log)
                 {
                     ASTDumper ast_dumper(interface_type);
                     log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
                 }
-                    
+
                 AddOneType(context, class_user_type, current_id);
-                                
+
                 if (method_decl->isInstanceMethod())
                 {
                     // self is a pointer to the object
-                    
+
                     QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0));
-                
+
                     TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
                                                 &method_decl->getASTContext());
-                
+
                     m_struct_vars->m_object_pointer_type = self_user_type;
                 }
                 else
                 {
                     // self is a Class pointer
                     QualType class_type = method_decl->getASTContext().getObjCClassType();
-                    
+
                     TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
                                                 &method_decl->getASTContext());
-                    
+
                     m_struct_vars->m_object_pointer_type = self_user_type;
                 }
 
@@ -1158,22 +1153,22 @@ ClangExpressionDeclMap::FindExternalVisi
                 // claims to have an object pointer (through DW_AT_object_pointer?) but is not formally a
                 // method of the class.  In that case, just look up the "self" variable in the the current
                 // scope and use its type.
-                
+
                 VariableList *vars = frame->GetVariableList(false);
-                
+
                 lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
-                
+
                 if (self_var &&
-                    self_var->IsInScope(frame) && 
+                    self_var->IsInScope(frame) &&
                     self_var->LocationIsValidForFrame (frame))
                 {
                     Type *self_type = self_var->GetType();
-                    
+
                     if (!self_type)
                         return;
-                    
+
                     ClangASTType self_clang_type = self_type->GetClangFullType();
-                    
+
                     if (self_clang_type.IsObjCClassType())
                     {
                         return;
@@ -1184,19 +1179,19 @@ ClangExpressionDeclMap::FindExternalVisi
 
                         if (!self_clang_type)
                             return;
-                        
+
                         if (log)
                         {
                             ASTDumper ast_dumper(self_type->GetClangFullType());
                             log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
                         }
-                        
+
                         TypeFromUser class_user_type (self_clang_type);
-                        
+
                         AddOneType(context, class_user_type, current_id);
-                                    
+
                         TypeFromUser self_user_type(self_type->GetClangFullType());
-                        
+
                         m_struct_vars->m_object_pointer_type = self_user_type;
                         return;
                     }
@@ -1205,66 +1200,66 @@ ClangExpressionDeclMap::FindExternalVisi
 
             return;
         }
-        
+
         // any other $__lldb names should be weeded out now
         if (!::strncmp(name_unique_cstr, "$__lldb", sizeof("$__lldb") - 1))
             return;
-        
+
         do
         {
             if (!target)
                 break;
-            
+
             ClangASTContext *scratch_clang_ast_context = target->GetScratchClangASTContext();
-            
+
             if (!scratch_clang_ast_context)
                 break;
-            
+
             ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
-            
+
             if (!scratch_ast_context)
                 break;
-            
+
             TypeDecl *ptype_type_decl = m_parser_vars->m_persistent_vars->GetPersistentType(name);
-            
+
             if (!ptype_type_decl)
                 break;
-            
+
             Decl *parser_ptype_decl = m_ast_importer->CopyDecl(m_ast_context, scratch_ast_context, ptype_type_decl);
-            
+
             if (!parser_ptype_decl)
                 break;
-            
+
             TypeDecl *parser_ptype_type_decl = dyn_cast<TypeDecl>(parser_ptype_decl);
-            
+
             if (!parser_ptype_type_decl)
                 break;
-            
+
             if (log)
                 log->Printf("  CEDM::FEVD[%u] Found persistent type %s", current_id, name.GetCString());
-            
+
             context.AddNamedDecl(parser_ptype_type_decl);
         } while (0);
-        
+
         ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
-        
+
         if (pvar_sp)
         {
             AddOneVariable(context, pvar_sp, current_id);
             return;
         }
-        
+
         const char *reg_name(&name.GetCString()[1]);
-        
+
         if (m_parser_vars->m_exe_ctx.GetRegisterContext())
         {
             const RegisterInfo *reg_info(m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(reg_name));
-            
+
             if (reg_info)
             {
                 if (log)
                     log->Printf("  CEDM::FEVD[%u] Found register %s", current_id, reg_info->name);
-                
+
                 AddOneRegister(context, reg_info, current_id);
             }
         }
@@ -1274,11 +1269,11 @@ ClangExpressionDeclMap::FindExternalVisi
         ValueObjectSP valobj;
         VariableSP var;
         Error err;
-        
+
         if (frame && !namespace_decl)
         {
-            valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr, 
-                                                              eNoDynamicValues, 
+            valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
+                                                              eNoDynamicValues,
                                                               StackFrame::eExpressionPathOptionCheckPtrVsMember ||
                                                               StackFrame::eExpressionPathOptionsAllowDirectIVarAccess ||
                                                               StackFrame::eExpressionPathOptionsNoFragileObjcIvar ||
@@ -1286,7 +1281,7 @@ ClangExpressionDeclMap::FindExternalVisi
                                                               StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
                                                               var,
                                                               err);
-            
+
             // If we found a variable in scope, no need to pull up function names
             if (err.Success() && var)
             {
@@ -1295,7 +1290,7 @@ ClangExpressionDeclMap::FindExternalVisi
                 return;
             }
         }
-        
+
         if (target)
         {
             var = FindGlobalVariable (*target,
@@ -1303,7 +1298,7 @@ ClangExpressionDeclMap::FindExternalVisi
                                       name,
                                       &namespace_decl,
                                       NULL);
-            
+
             if (var)
             {
                 valobj = ValueObjectVariable::Create(target, var);
@@ -1312,19 +1307,19 @@ ClangExpressionDeclMap::FindExternalVisi
                 return;
             }
         }
-        
+
         if (!context.m_found.variable)
         {
             const bool include_inlines = false;
             const bool append = false;
-            
+
             if (namespace_decl && module_sp)
             {
                 const bool include_symbols = false;
 
                 module_sp->FindFunctions(name,
                                          &namespace_decl,
-                                         eFunctionNameTypeBase, 
+                                         eFunctionNameTypeBase,
                                          include_symbols,
                                          include_inlines,
                                          append,
@@ -1333,43 +1328,43 @@ ClangExpressionDeclMap::FindExternalVisi
             else if (target && !namespace_decl)
             {
                 const bool include_symbols = true;
-                
+
                 // TODO Fix FindFunctions so that it doesn't return
                 //   instance methods for eFunctionNameTypeBase.
-                
+
                 target->GetImages().FindFunctions(name,
                                                   eFunctionNameTypeFull,
                                                   include_symbols,
                                                   include_inlines,
-                                                  append, 
+                                                  append,
                                                   sc_list);
             }
-            
+
             if (sc_list.GetSize())
             {
                 Symbol *extern_symbol = NULL;
                 Symbol *non_extern_symbol = NULL;
-                
+
                 for (uint32_t index = 0, num_indices = sc_list.GetSize();
                      index < num_indices;
                      ++index)
                 {
                     SymbolContext sym_ctx;
                     sc_list.GetContextAtIndex(index, sym_ctx);
-                    
+
                     if (sym_ctx.function)
                     {
                         clang::DeclContext *decl_ctx = sym_ctx.function->GetClangDeclContext();
-                        
+
                         if (!decl_ctx)
                             continue;
-                        
+
                         // Filter out class/instance methods.
                         if (dyn_cast<clang::ObjCMethodDecl>(decl_ctx))
                             continue;
                         if (dyn_cast<clang::CXXMethodDecl>(decl_ctx))
                             continue;
-                        
+
                         AddOneFunction(context, sym_ctx.function, NULL, current_id);
                         context.m_found.function_with_type_info = true;
                         context.m_found.function = true;
@@ -1382,14 +1377,14 @@ ClangExpressionDeclMap::FindExternalVisi
                             if (sym_ctx.symbol == NULL)
                                 continue;
                         }
-                        
+
                         if (sym_ctx.symbol->IsExternal())
                             extern_symbol = sym_ctx.symbol;
                         else
                             non_extern_symbol = sym_ctx.symbol;
                     }
                 }
-                
+
                 if (!context.m_found.function_with_type_info)
                 {
                     if (extern_symbol)
@@ -1404,14 +1399,14 @@ ClangExpressionDeclMap::FindExternalVisi
                     }
                 }
             }
-            
+
             if (target && !context.m_found.variable && !namespace_decl)
             {
-                // We couldn't find a non-symbol variable for this.  Now we'll hunt for a generic 
+                // We couldn't find a non-symbol variable for this.  Now we'll hunt for a generic
                 // data symbol, and -- if it is found -- treat it as a variable.
-                
+
                 const Symbol *data_symbol = FindGlobalDataSymbol(*target, name);
-                
+
                 if (data_symbol)
                 {
                     std::string warning("got name from symbols: ");
@@ -1471,25 +1466,25 @@ ClangExpressionDeclMap::GetVariableValue
                                           TypeFromParser *parser_type)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     Type *var_type = var->GetType();
-    
-    if (!var_type) 
+
+    if (!var_type)
     {
         if (log)
             log->PutCString("Skipped a definition because it has no type");
         return false;
     }
-    
+
     ClangASTType var_clang_type = var_type->GetClangFullType();
-    
+
     if (!var_clang_type)
     {
         if (log)
             log->PutCString("Skipped a definition because it has no Clang type");
         return false;
     }
-    
+
     ASTContext *ast = var_type->GetClangASTContext().getASTContext();
 
     if (!ast)
@@ -1499,16 +1494,16 @@ ClangExpressionDeclMap::GetVariableValue
         return false;
     }
     //var_clang_type = MaybePromoteToBlockPointerType (ast, var_clang_type);
-    
+
     DWARFExpression &var_location_expr = var->LocationExpression();
-    
+
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
     Error err;
-    
+
     if (var->GetLocationIsConstantValueData())
     {
         DataExtractor const_value_extractor;
-        
+
         if (var_location_expr.GetExpressionData(const_value_extractor))
         {
             var_location = Value(const_value_extractor.GetDataStart(), const_value_extractor.GetByteSize());
@@ -1521,45 +1516,45 @@ ClangExpressionDeclMap::GetVariableValue
             return false;
         }
     }
-    
+
     ClangASTType type_to_use = GuardedCopyType(var_clang_type);
-    
+
     if (!type_to_use)
     {
         if (log)
             log->Printf("Couldn't copy a variable's type into the parser's AST context");
-        
+
         return false;
     }
-    
+
     if (parser_type)
         *parser_type = TypeFromParser(type_to_use);
-    
+
     if (var_location.GetContextType() == Value::eContextTypeInvalid)
         var_location.SetClangType(type_to_use);
-    
+
     if (var_location.GetValueType() == Value::eValueTypeFileAddress)
     {
         SymbolContext var_sc;
         var->CalculateSymbolContext(&var_sc);
-        
+
         if (!var_sc.module_sp)
             return false;
 
         Address so_addr(var_location.GetScalar().ULongLong(), var_sc.module_sp->GetSectionList());
-        
+
         lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
-        
+
         if (load_addr != LLDB_INVALID_ADDRESS)
         {
             var_location.GetScalar() = load_addr;
             var_location.SetValueType(Value::eValueTypeLoadAddress);
         }
     }
-    
+
     if (user_type)
         *user_type = TypeFromUser(var_clang_type);
-    
+
     return true;
 }
 
@@ -1567,21 +1562,21 @@ void
 ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP var, ValueObjectSP valobj, unsigned int current_id)
 {
     assert (m_parser_vars.get());
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-        
+
     TypeFromUser ut;
     TypeFromParser pt;
     Value var_location;
-    
+
     if (!GetVariableValue (var, var_location, &ut, &pt))
         return;
-    
+
     clang::QualType parser_opaque_type = QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
-    
+
     if (parser_opaque_type.isNull())
         return;
-    
+
     if (const clang::Type *parser_type = parser_opaque_type.getTypePtr())
     {
         if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
@@ -1589,8 +1584,8 @@ ClangExpressionDeclMap::AddOneVariable (
         if (const ObjCObjectPointerType *objc_object_ptr_type = dyn_cast<ObjCObjectPointerType>(parser_type))
             CompleteType(objc_object_ptr_type->getInterfaceDecl());
     }
-    
-    
+
+
     bool is_reference = pt.IsReferenceType();
 
     NamedDecl *var_decl = NULL;
@@ -1598,11 +1593,11 @@ ClangExpressionDeclMap::AddOneVariable (
         var_decl = context.AddVarDecl(pt);
     else
         var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
-        
+
     std::string decl_name(context.m_decl_name.getAsString());
     ConstString entity_name(decl_name.c_str());
     ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj));
-    
+
     assert (entity.get());
     entity->EnableParserVars(GetParserID());
     ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
@@ -1611,45 +1606,45 @@ ClangExpressionDeclMap::AddOneVariable (
     parser_vars->m_llvm_value  = NULL;
     parser_vars->m_lldb_value  = var_location;
     parser_vars->m_lldb_var    = var;
-    
+
     if (is_reference)
         entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
-    
+
     if (log)
     {
         ASTDumper orig_dumper(ut.GetOpaqueQualType());
-        ASTDumper ast_dumper(var_decl);        
+        ASTDumper ast_dumper(var_decl);
         log->Printf("  CEDM::FEVD[%u] Found variable %s, returned %s (original %s)", current_id, decl_name.c_str(), ast_dumper.GetCString(), orig_dumper.GetCString());
     }
 }
 
 void
 ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
-                                       ClangExpressionVariableSP &pvar_sp, 
+                                       ClangExpressionVariableSP &pvar_sp,
                                        unsigned int current_id)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     TypeFromUser user_type (pvar_sp->GetTypeFromUser());
-    
+
     TypeFromParser parser_type (GuardedCopyType(user_type));
-    
+
     if (!parser_type.GetOpaqueQualType())
     {
         if (log)
             log->Printf("  CEDM::FEVD[%u] Couldn't import type for pvar %s", current_id, pvar_sp->GetName().GetCString());
         return;
     }
-    
+
     NamedDecl *var_decl = context.AddVarDecl(parser_type.GetLValueReferenceType());
-    
+
     pvar_sp->EnableParserVars(GetParserID());
     ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
     parser_vars->m_parser_type = parser_type;
     parser_vars->m_named_decl = var_decl;
     parser_vars->m_llvm_value = NULL;
     parser_vars->m_lldb_value.Clear();
-    
+
     if (log)
     {
         ASTDumper ast_dumper(var_decl);
@@ -1658,59 +1653,59 @@ ClangExpressionDeclMap::AddOneVariable(N
 }
 
 void
-ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context, 
+ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
                                               const Symbol &symbol,
                                               unsigned int current_id)
 {
     assert(m_parser_vars.get());
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
 
     if (target == NULL)
         return;
 
     ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
-    
+
     TypeFromUser user_type (ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
     TypeFromParser parser_type (ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
     NamedDecl *var_decl = context.AddVarDecl(parser_type);
-    
+
     std::string decl_name(context.m_decl_name.getAsString());
     ConstString entity_name(decl_name.c_str());
     ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
-                                                                      entity_name, 
+                                                                      entity_name,
                                                                       user_type,
                                                                       m_parser_vars->m_target_info.byte_order,
                                                                       m_parser_vars->m_target_info.address_byte_size));
     assert (entity.get());
-    
+
     entity->EnableParserVars(GetParserID());
     ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
 
     const Address &symbol_address = symbol.GetAddress();
     lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
-    
+
     //parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
     parser_vars->m_lldb_value.SetClangType(user_type);
     parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
     parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
-    
+
     parser_vars->m_parser_type = parser_type;
     parser_vars->m_named_decl  = var_decl;
     parser_vars->m_llvm_value  = NULL;
     parser_vars->m_lldb_sym    = &symbol;
-    
+
     if (log)
     {
         ASTDumper ast_dumper(var_decl);
-        
+
         log->Printf("  CEDM::FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString());
     }
 }
 
-bool 
+bool
 ClangExpressionDeclMap::ResolveUnknownTypes()
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -1723,82 +1718,82 @@ ClangExpressionDeclMap::ResolveUnknownTy
          ++index)
     {
         ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
-        
+
         ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
-        
+
         if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
         {
             const NamedDecl *named_decl = parser_vars->m_named_decl;
             const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
-            
+
             if (!var_decl)
             {
                 if (log)
                     log->Printf("Entity of unknown type does not have a VarDecl");
                 return false;
             }
-            
+
             if (log)
             {
                 ASTDumper ast_dumper(const_cast<VarDecl*>(var_decl));
                 log->Printf("Variable of unknown type now has Decl %s", ast_dumper.GetCString());
             }
-                
+
             QualType var_type = var_decl->getType();
             TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext());
-            
+
             lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
-            
+
             if (!copied_type)
-            {                
+            {
                 if (log)
                     log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't import the type for a variable");
-                
+
                 return (bool) lldb::ClangExpressionVariableSP();
             }
-            
+
             TypeFromUser user_type(copied_type, scratch_ast_context);
-                        
+
 //            parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
             parser_vars->m_lldb_value.SetClangType(user_type);
             parser_vars->m_parser_type = parser_type;
-            
+
             entity->SetClangType(user_type);
-            
+
             entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType);
         }
     }
-            
+
     return true;
 }
 
 void
 ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
-                                        const RegisterInfo *reg_info, 
+                                        const RegisterInfo *reg_info,
                                         unsigned int current_id)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     ClangASTType clang_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (m_ast_context,
                                                                                     reg_info->encoding,
                                                                                     reg_info->byte_size * 8);
-    
+
     if (!clang_type)
     {
         if (log)
             log->Printf("  Tried to add a type for %s, but couldn't get one", context.m_decl_name.getAsString().c_str());
         return;
     }
-    
+
     TypeFromParser parser_clang_type (clang_type);
-    
+
     NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
-    
+
     ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
                                                                       m_parser_vars->m_target_info.byte_order,
                                                                       m_parser_vars->m_target_info.address_byte_size));
     assert (entity.get());
-    
+
     std::string decl_name(context.m_decl_name.getAsString());
     entity->SetName (ConstString (decl_name.c_str()));
     entity->SetRegisterInfo (reg_info);
@@ -1809,7 +1804,7 @@ ClangExpressionDeclMap::AddOneRegister (
     parser_vars->m_llvm_value = NULL;
     parser_vars->m_lldb_value.Clear();
     entity->m_flags |= ClangExpressionVariable::EVBareRegister;
-    
+
     if (log)
     {
         ASTDumper ast_dumper(var_decl);
@@ -1824,9 +1819,9 @@ ClangExpressionDeclMap::AddOneFunction (
                                         unsigned int current_id)
 {
     assert (m_parser_vars.get());
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     NamedDecl *function_decl = NULL;
     const Address *fun_address = NULL;
     ClangASTType function_clang_type;
@@ -1836,30 +1831,30 @@ ClangExpressionDeclMap::AddOneFunction (
     if (function)
     {
         Type *function_type = function->GetType();
-        
+
         if (!function_type)
         {
             if (log)
                 log->PutCString("  Skipped a function because it has no type");
             return;
         }
-        
+
         function_clang_type = function_type->GetClangFullType();
-        
+
         if (!function_clang_type)
         {
             if (log)
                 log->PutCString("  Skipped a function because it has no Clang type");
             return;
         }
-        
+
         fun_address = &function->GetAddressRange().GetBaseAddress();
-        
+
         ClangASTType copied_function_type = GuardedCopyType(function_clang_type);
         if (copied_function_type)
         {
             function_decl = context.AddFunDecl(copied_function_type);
-            
+
             if (!function_decl)
             {
                 if (log)
@@ -1868,7 +1863,7 @@ ClangExpressionDeclMap::AddOneFunction (
                                  function_type->GetName().GetCString(),
                                  function_type->GetID());
                 }
-                
+
                 return;
             }
         }
@@ -1881,7 +1876,7 @@ ClangExpressionDeclMap::AddOneFunction (
                              function_type->GetName().GetCString(),
                              function_type->GetID());
             }
-            
+
             return;
         }
     }
@@ -1897,11 +1892,11 @@ ClangExpressionDeclMap::AddOneFunction (
             log->PutCString("  AddOneFunction called with no function and no symbol");
         return;
     }
-    
+
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
 
     lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target, is_indirect_function);
-    
+
     ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
                                                                       m_parser_vars->m_target_info.byte_order,
                                                                       m_parser_vars->m_target_info.address_byte_size));
@@ -1913,7 +1908,7 @@ ClangExpressionDeclMap::AddOneFunction (
     entity->EnableParserVars(GetParserID());
 
     ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
-    
+
     if (load_addr != LLDB_INVALID_ADDRESS)
     {
         parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
@@ -1922,25 +1917,25 @@ ClangExpressionDeclMap::AddOneFunction (
     else
     {
         // We have to try finding a file address.
-        
+
         lldb::addr_t file_addr = fun_address->GetFileAddress();
-        
+
         parser_vars->m_lldb_value.SetValueType(Value::eValueTypeFileAddress);
         parser_vars->m_lldb_value.GetScalar() = file_addr;
     }
-    
+
 
     parser_vars->m_named_decl  = function_decl;
     parser_vars->m_llvm_value  = NULL;
-    
+
     if (log)
     {
         ASTDumper ast_dumper(function_decl);
-        
+
         StreamString ss;
-        
+
         fun_address->Dump(&ss, m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), Address::DumpStyleResolvedDescription);
-        
+
         log->Printf("  CEDM::FEVD[%u] Found %s function %s (description %s), returned %s",
                     current_id,
                     (function ? "specific" : "generic"),
@@ -1955,14 +1950,14 @@ ClangExpressionDeclMap::CopyClassType(Ty
                                       unsigned int current_id)
 {
     ClangASTType copied_clang_type = GuardedCopyType(ut);
-    
+
     if (!copied_clang_type)
     {
         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-        
+
         if (log)
             log->Printf("ClangExpressionDeclMap::CopyClassType - Couldn't import the type");
-        
+
         return TypeFromParser();
     }
 
@@ -1970,21 +1965,21 @@ ClangExpressionDeclMap::CopyClassType(Ty
     {
         ClangASTType void_clang_type = ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid);
         ClangASTType void_ptr_clang_type = void_clang_type.GetPointerType();
-        
+
         ClangASTType method_type = ClangASTContext::CreateFunctionType (m_ast_context,
                                                                         void_clang_type,
                                                                         &void_ptr_clang_type,
                                                                         1,
                                                                         false,
                                                                         copied_clang_type.GetTypeQualifiers());
-        
+
         const bool is_virtual = false;
         const bool is_static = false;
         const bool is_inline = false;
         const bool is_explicit = false;
         const bool is_attr_used = true;
         const bool is_artificial = false;
-        
+
         copied_clang_type.AddMethodToCXXRecordType ("$__lldb_expr",
                                                     method_type,
                                                     lldb::eAccessPublic,
@@ -1995,26 +1990,26 @@ ClangExpressionDeclMap::CopyClassType(Ty
                                                     is_attr_used,
                                                     is_artificial);
     }
-    
+
     return TypeFromParser(copied_clang_type);
 }
 
-void 
-ClangExpressionDeclMap::AddOneType(NameSearchContext &context, 
+void
+ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
                                    TypeFromUser &ut,
                                    unsigned int current_id)
 {
     ClangASTType copied_clang_type = GuardedCopyType(ut);
-    
+
     if (!copied_clang_type)
     {
         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
         if (log)
             log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type");
-        
+
         return;
     }
-    
+
     context.AddTypeDecl(copied_clang_type);
 }

Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Sun Jul  6 12:54:58 2014
@@ -87,7 +87,7 @@ std::string GetBuiltinIncludePath(const
         llvm::sys::path::append(P, "lib", "clang", CLANG_VERSION_STRING,
                                 "include");
     }
-    
+
     return P.str();
 }
 
@@ -111,16 +111,16 @@ ClangExpressionParser::ClangExpressionPa
             llvm::InitializeAllDisassemblers();
         }
     } InitializeLLVM;
-    
+
     // 1. Create a new compiler instance.
-    m_compiler.reset(new CompilerInstance());    
-    
+    m_compiler.reset(new CompilerInstance());
+
     // 2. Install the target.
 
     lldb::TargetSP target_sp;
     if (exe_scope)
         target_sp = exe_scope->CalculateTarget();
-    
+
     // TODO: figure out what to really do when we don't have a valid target.
     // Sometimes this will be ok to just use the host target triple (when we
     // evaluate say "2+3", but other expressions like breakpoint conditions
@@ -135,14 +135,14 @@ ClangExpressionParser::ClangExpressionPa
     {
         m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
     }
-    
+
     if (target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86 ||
         target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64)
     {
         m_compiler->getTargetOpts().Features.push_back("+sse");
         m_compiler->getTargetOpts().Features.push_back("+sse2");
     }
-    
+
     // Any arm32 iOS environment, but not on arm64
     if (m_compiler->getTargetOpts().Triple.find("arm64") == std::string::npos &&
         m_compiler->getTargetOpts().Triple.find("arm") != std::string::npos &&
@@ -158,11 +158,11 @@ ClangExpressionParser::ClangExpressionPa
         m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts));
 
     assert (m_compiler->hasTarget());
-    
+
     // 3. Set options.
-    
+
     lldb::LanguageType language = expr.Language();
-    
+
     switch (language)
     {
     case lldb::eLanguageTypeC:
@@ -183,20 +183,20 @@ ClangExpressionParser::ClangExpressionPa
         m_compiler->getLangOpts().CPlusPlus11 = true;
         break;
     }
-    
+
     m_compiler->getLangOpts().Bool = true;
     m_compiler->getLangOpts().WChar = true;
     m_compiler->getLangOpts().Blocks = true;
     m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
     if (expr.DesiredResultType() == ClangExpression::eResultTypeId)
         m_compiler->getLangOpts().DebuggerCastResultToId = true;
-    
+
     // Spell checking is a nice feature, but it ends up completing a
     // lot of types that we didn't strictly speaking need to complete.
     // As a result, we spend a long time parsing and importing debug
     // information.
-    m_compiler->getLangOpts().SpellChecking = false; 
-    
+    m_compiler->getLangOpts().SpellChecking = false;
+
     lldb::ProcessSP process_sp;
     if (exe_scope)
         process_sp = exe_scope->CalculateProcess();
@@ -209,7 +209,7 @@ ClangExpressionParser::ClangExpressionPa
                 m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7));
             else
                 m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX, VersionTuple(10, 7));
-            
+
             if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
                 m_compiler->getLangOpts().DebuggerObjCLiteral = true;
         }
@@ -218,7 +218,7 @@ ClangExpressionParser::ClangExpressionPa
     m_compiler->getLangOpts().ThreadsafeStatics = false;
     m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access
     m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name
-    
+
     // Set CodeGen options
     m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
     m_compiler->getCodeGenOpts().InstrumentFunctions = false;
@@ -228,7 +228,7 @@ ClangExpressionParser::ClangExpressionPa
         m_compiler->getCodeGenOpts().setDebugInfo(CodeGenOptions::FullDebugInfo);
     else
         m_compiler->getCodeGenOpts().setDebugInfo(CodeGenOptions::NoDebugInfo);
-    
+
     // Disable some warnings.
     m_compiler->getDiagnostics().setSeverityForGroup(
         "unused-value", clang::diag::Severity::Ignored, SourceLocation());
@@ -240,45 +240,45 @@ ClangExpressionParser::ClangExpressionPa
     // FIXME: We shouldn't need to do this, the target should be immutable once
     // created. This complexity should be lifted elsewhere.
     m_compiler->getTarget().adjust(m_compiler->getLangOpts());
-    
+
     // 4. Set up the diagnostic buffer for reporting errors
-    
+
     m_compiler->getDiagnostics().setClient(new clang::TextDiagnosticBuffer);
-    
+
     // 5. Set up the source management objects inside the compiler
-    
+
     clang::FileSystemOptions file_system_options;
     m_file_manager.reset(new clang::FileManager(file_system_options));
-    
+
     if (!m_compiler->hasSourceManager())
         m_compiler->createSourceManager(*m_file_manager.get());
-    
+
     m_compiler->createFileManager();
     m_compiler->createPreprocessor(TU_Complete);
-    
-    // 6. Most of this we get from the CompilerInstance, but we 
+
+    // 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());
-    
+
     std::unique_ptr<clang::ASTContext> ast_context(new ASTContext(m_compiler->getLangOpts(),
                                                                  m_compiler->getSourceManager(),
                                                                  m_compiler->getPreprocessor().getIdentifierTable(),
                                                                  *m_selector_table.get(),
                                                                  *m_builtin_context.get()));
     ast_context->InitBuiltinTypes(m_compiler->getTarget());
-    
+
     ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
-    
+
     if (decl_map)
     {
         llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source(decl_map->CreateProxy());
         decl_map->InstallASTContext(ast_context.get());
         ast_context->setExternalSource(ast_source);
     }
-    
+
     m_compiler->setASTContext(ast_context.release());
-    
+
     std::string module_name("$__lldb_module");
 
     m_llvm_context.reset(new LLVMContext());
@@ -297,9 +297,9 @@ unsigned
 ClangExpressionParser::Parse (Stream &stream)
 {
     TextDiagnosticBuffer *diag_buf = static_cast<TextDiagnosticBuffer*>(m_compiler->getDiagnostics().getClient());
-        
+
     diag_buf->FlushDiagnostics (m_compiler->getDiagnostics());
-    
+
     const char *expr_text = m_expr.Text();
 
     clang::SourceManager &SourceMgr = m_compiler->getSourceManager();
@@ -307,7 +307,7 @@ ClangExpressionParser::Parse (Stream &st
     if (m_compiler->getCodeGenOpts().getDebugInfo() == CodeGenOptions::FullDebugInfo)
     {
         std::string temp_source_path;
-        
+
         FileSpec tmpdir_file_spec;
         if (Host::GetLLDBPath (ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
         {
@@ -318,7 +318,7 @@ ClangExpressionParser::Parse (Stream &st
         {
             temp_source_path = "/tmp/expr.XXXXXX";
         }
-        
+
         if (mktemp(&temp_source_path[0]))
         {
             lldb_private::File file (temp_source_path.c_str(),
@@ -339,35 +339,35 @@ ClangExpressionParser::Parse (Stream &st
             }
         }
     }
-    
+
     if (!created_main_file)
     {
         MemoryBuffer *memory_buffer = MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
         SourceMgr.setMainFileID(SourceMgr.createFileID(memory_buffer));
     }
-    
+
     diag_buf->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
-    
+
     ASTConsumer *ast_transformer = m_expr.ASTTransformer(m_code_generator.get());
-    
+
     if (ast_transformer)
         ParseAST(m_compiler->getPreprocessor(), ast_transformer, m_compiler->getASTContext());
-    else 
-        ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());    
-    
+    else
+        ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());
+
     diag_buf->EndSourceFile();
-        
+
     TextDiagnosticBuffer::const_iterator diag_iterator;
-    
+
     int num_errors = 0;
-    
+
     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 = diag_buf->err_begin();
          diag_iterator != diag_buf->err_end();
          ++diag_iterator)
@@ -375,12 +375,12 @@ ClangExpressionParser::Parse (Stream &st
         num_errors++;
         stream.Printf("error: %s\n", (*diag_iterator).second.c_str());
     }
-    
+
     for (diag_iterator = diag_buf->note_begin();
          diag_iterator != diag_buf->note_end();
          ++diag_iterator)
         stream.Printf("note: %s\n", (*diag_iterator).second.c_str());
-    
+
     if (!num_errors)
     {
         if (m_expr.DeclMap() && !m_expr.DeclMap()->ResolveUnknownTypes())
@@ -389,7 +389,7 @@ ClangExpressionParser::Parse (Stream &st
             num_errors++;
         }
     }
-    
+
     return num_errors;
 }
 
@@ -400,19 +400,19 @@ static bool FindFunctionInModule (ConstS
     for (llvm::Module::iterator fi = module->getFunctionList().begin(), fe = module->getFunctionList().end();
          fi != fe;
          ++fi)
-    {        
+    {
         if (fi->getName().str().find(orig_name) != std::string::npos)
         {
             mangled_name.SetCString(fi->getName().str().c_str());
             return true;
         }
     }
-    
+
     return false;
 }
 
 Error
-ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr, 
+ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr,
                                             lldb::addr_t &func_end,
                                             std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
                                             ExecutionContext &exe_ctx,
@@ -424,7 +424,7 @@ ClangExpressionParser::PrepareForExecuti
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     Error err;
-    
+
     std::unique_ptr<llvm::Module> llvm_module_ap (m_code_generator->ReleaseModule());
 
     if (!llvm_module_ap.get())
@@ -433,11 +433,11 @@ ClangExpressionParser::PrepareForExecuti
         err.SetErrorString("IR doesn't contain a module");
         return err;
     }
-    
+
     // Find the actual name of the function (it's often mangled somehow)
-    
+
     ConstString function_name;
-    
+
     if (!FindFunctionInModule(function_name, llvm_module_ap.get(), m_expr.FunctionName()))
     {
         err.SetErrorToGenericError();
@@ -449,54 +449,54 @@ ClangExpressionParser::PrepareForExecuti
         if (log)
             log->Printf("Found function %s for %s", function_name.AsCString(), m_expr.FunctionName());
     }
-    
+
     execution_unit_sp.reset(new IRExecutionUnit (m_llvm_context, // handed off here
                                                  llvm_module_ap, // handed off here
                                                  function_name,
                                                  exe_ctx.GetTargetSP(),
                                                  m_compiler->getTargetOpts().Features));
-    
+
     ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL
-    
+
     if (decl_map)
     {
         Stream *error_stream = NULL;
         Target *target = exe_ctx.GetTargetPtr();
         if (target)
             error_stream = target->GetDebugger().GetErrorFile().get();
-    
+
         IRForTarget ir_for_target(decl_map,
                                   m_expr.NeedsVariableResolution(),
                                   *execution_unit_sp,
                                   error_stream,
                                   function_name.AsCString());
-        
+
         bool ir_can_run = ir_for_target.runOnModule(*execution_unit_sp->GetModule());
-        
+
         Error interpret_error;
-        
+
         can_interpret = IRInterpreter::CanInterpret(*execution_unit_sp->GetModule(), *execution_unit_sp->GetFunction(), interpret_error);
-        
+
         Process *process = exe_ctx.GetProcessPtr();
-        
+
         if (!ir_can_run)
         {
             err.SetErrorString("The expression could not be prepared to run in the target");
             return err;
         }
-        
+
         if (!can_interpret && execution_policy == eExecutionPolicyNever)
         {
             err.SetErrorStringWithFormat("Can't run the expression locally: %s", interpret_error.AsCString());
             return err;
         }
-        
+
         if (!process && execution_policy == eExecutionPolicyAlways)
         {
             err.SetErrorString("Expression needed to run in the target, but the target can't be run");
             return err;
         }
-        
+
         if (execution_policy == eExecutionPolicyAlways || !can_interpret)
         {
             if (m_expr.NeedsValidation() && process)
@@ -504,27 +504,27 @@ ClangExpressionParser::PrepareForExecuti
                 if (!process->GetDynamicCheckers())
                 {
                     DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
-                    
+
                     StreamString install_errors;
-                    
+
                     if (!dynamic_checkers->Install(install_errors, exe_ctx))
                     {
                         if (install_errors.GetString().empty())
                             err.SetErrorString ("couldn't install checkers, unknown error");
                         else
                             err.SetErrorString (install_errors.GetString().c_str());
-                        
+
                         return err;
                     }
-                    
+
                     process->SetDynamicCheckers(dynamic_checkers);
-                    
+
                     if (log)
                         log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
                 }
-                
+
                 IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.AsCString());
-                
+
                 if (!ir_dynamic_checks.runOnModule(*execution_unit_sp->GetModule()))
                 {
                     err.SetErrorToGenericError();
@@ -532,7 +532,7 @@ ClangExpressionParser::PrepareForExecuti
                     return err;
                 }
             }
-            
+
             execution_unit_sp->GetRunnableInfo(err, func_addr, func_end);
         }
     }
@@ -540,7 +540,7 @@ ClangExpressionParser::PrepareForExecuti
     {
         execution_unit_sp->GetRunnableInfo(err, func_addr, func_end);
     }
-    
+
     return err;
 }
 

Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Sun Jul  6 12:54:58 2014
@@ -8,11 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Expression/ClangExpressionVariable.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
 #include "clang/AST/ASTContext.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/DataExtractor.h"
@@ -44,17 +39,17 @@ ClangExpressionVariable::ClangExpression
 //----------------------------------------------------------------------
 /// Return the variable's size in bytes
 //----------------------------------------------------------------------
-size_t 
+size_t
 ClangExpressionVariable::GetByteSize ()
 {
     return m_frozen_sp->GetByteSize();
-}    
+}
 
 const ConstString &
 ClangExpressionVariable::GetName ()
 {
     return m_frozen_sp->GetName();
-}    
+}
 
 lldb::ValueObjectSP
 ClangExpressionVariable::GetValueObject()
@@ -78,13 +73,13 @@ ClangASTType
 ClangExpressionVariable::GetClangType()
 {
     return m_frozen_sp->GetClangType();
-}    
+}
 
 void
 ClangExpressionVariable::SetClangType(const ClangASTType &clang_type)
 {
     m_frozen_sp->GetValue().SetClangType(clang_type);
-}    
+}
 
 
 TypeFromUser
@@ -92,7 +87,7 @@ ClangExpressionVariable::GetTypeFromUser
 {
     TypeFromUser tfu (m_frozen_sp->GetClangType());
     return tfu;
-}    
+}
 
 uint8_t *
 ClangExpressionVariable::GetValueBytes()
@@ -130,7 +125,7 @@ ClangExpressionVariable::TransferAddress
 
     if (m_frozen_sp.get() == NULL)
         return;
-    
+
     if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
         m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
 }

Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Sun Jul  6 12:54:58 2014
@@ -7,13 +7,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-// C Includes
 #include <stdio.h>
 #if HAVE_SYS_TYPES_H
 #  include <sys/types.h>
 #endif
 
-// C++ Includes
 #include <cstdlib>
 #include <string>
 #include <map>
@@ -112,7 +110,7 @@ ClangUserExpression::ASTTransformer (cla
 {
     m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
                                                         *m_target));
-    
+
     return m_result_synthesizer.get();
 }
 
@@ -123,16 +121,16 @@ ClangUserExpression::ScanContext(Executi
 
     if (log)
         log->Printf("ClangUserExpression::ScanContext()");
-    
+
     m_target = exe_ctx.GetTargetPtr();
-    
+
     if (!(m_allow_cxx || m_allow_objc))
     {
         if (log)
             log->Printf("  [CUE::SC] Settings inhibit C++ and Objective-C");
         return;
     }
-    
+
     StackFrame *frame = exe_ctx.GetFramePtr();
     if (frame == NULL)
     {
@@ -140,19 +138,19 @@ ClangUserExpression::ScanContext(Executi
             log->Printf("  [CUE::SC] Null stack frame");
         return;
     }
-    
+
     SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
-    
+
     if (!sym_ctx.function)
     {
         if (log)
             log->Printf("  [CUE::SC] Null function");
         return;
     }
-    
+
     // Find the block that defines the function represented by "sym_ctx"
     Block *function_block = sym_ctx.GetFunctionBlock();
-    
+
     if (!function_block)
     {
         if (log)
@@ -168,7 +166,7 @@ ClangUserExpression::ScanContext(Executi
             log->Printf("  [CUE::SC] Null decl context");
         return;
     }
-    
+
     if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context))
     {
         if (m_allow_cxx && method_decl->isInstance())
@@ -176,60 +174,60 @@ ClangUserExpression::ScanContext(Executi
             if (m_enforce_valid_object)
             {
                 lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-                
+
                 const char *thisErrorString = "Stopped in a C++ method, but 'this' isn't available; pretending we are in a generic context";
-                
+
                 if (!variable_list_sp)
                 {
                     err.SetErrorString(thisErrorString);
                     return;
                 }
-                
+
                 lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
-                
+
                 if (!this_var_sp ||
-                    !this_var_sp->IsInScope(frame) || 
+                    !this_var_sp->IsInScope(frame) ||
                     !this_var_sp->LocationIsValidForFrame (frame))
                 {
                     err.SetErrorString(thisErrorString);
                     return;
                 }
             }
-            
+
             m_cplusplus = true;
             m_needs_object_ptr = true;
         }
     }
     else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_context))
-    {        
+    {
         if (m_allow_objc)
         {
             if (m_enforce_valid_object)
             {
                 lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-                
+
                 const char *selfErrorString = "Stopped in an Objective-C method, but 'self' isn't available; pretending we are in a generic context";
-                
+
                 if (!variable_list_sp)
                 {
                     err.SetErrorString(selfErrorString);
                     return;
                 }
-                
+
                 lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
-                
-                if (!self_variable_sp || 
-                    !self_variable_sp->IsInScope(frame) || 
+
+                if (!self_variable_sp ||
+                    !self_variable_sp->IsInScope(frame) ||
                     !self_variable_sp->LocationIsValidForFrame (frame))
                 {
                     err.SetErrorString(selfErrorString);
                     return;
                 }
             }
-            
+
             m_objectivec = true;
             m_needs_object_ptr = true;
-            
+
             if (!method_decl->isInstanceMethod())
                 m_static_method = true;
         }
@@ -240,7 +238,7 @@ ClangUserExpression::ScanContext(Executi
         // object pointer.  The best way to deal with getting to the ivars at present it by pretending
         // that this is a method of a class in whatever runtime the debug info says the object pointer
         // belongs to.  Do that here.
-        
+
         ClangASTMetadata *metadata = ClangASTContext::GetMetadata (&decl_context->getParentASTContext(), function_decl);
         if (metadata && metadata->HasObjectPtr())
         {
@@ -250,17 +248,17 @@ ClangUserExpression::ScanContext(Executi
                 if (m_enforce_valid_object)
                 {
                     lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-                    
+
                     const char *thisErrorString = "Stopped in a context claiming to capture a C++ object pointer, but 'this' isn't available; pretending we are in a generic context";
-                    
+
                     if (!variable_list_sp)
                     {
                         err.SetErrorString(thisErrorString);
                         return;
                     }
-                    
+
                     lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
-                    
+
                     if (!this_var_sp ||
                         !this_var_sp->IsInScope(frame) ||
                         !this_var_sp->LocationIsValidForFrame (frame))
@@ -269,7 +267,7 @@ ClangUserExpression::ScanContext(Executi
                         return;
                     }
                 }
-                
+
                 m_cplusplus = true;
                 m_needs_object_ptr = true;
             }
@@ -278,17 +276,17 @@ ClangUserExpression::ScanContext(Executi
                 if (m_enforce_valid_object)
                 {
                     lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
-                    
+
                     const char *selfErrorString = "Stopped in a context claiming to capture an Objective-C object pointer, but 'self' isn't available; pretending we are in a generic context";
-                    
+
                     if (!variable_list_sp)
                     {
                         err.SetErrorString(selfErrorString);
                         return;
                     }
-                    
+
                     lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
-                    
+
                     if (!self_variable_sp ||
                         !self_variable_sp->IsInScope(frame) ||
                         !self_variable_sp->LocationIsValidForFrame (frame))
@@ -296,23 +294,23 @@ ClangUserExpression::ScanContext(Executi
                         err.SetErrorString(selfErrorString);
                         return;
                     }
-                    
+
                     Type *self_type = self_variable_sp->GetType();
-                    
+
                     if (!self_type)
                     {
                         err.SetErrorString(selfErrorString);
                         return;
                     }
-                    
+
                     ClangASTType self_clang_type = self_type->GetClangForwardType();
-                    
+
                     if (!self_clang_type)
                     {
                         err.SetErrorString(selfErrorString);
                         return;
                     }
-                                        
+
                     if (self_clang_type.IsObjCClassType())
                     {
                         return;
@@ -342,9 +340,9 @@ void
 ClangUserExpression::InstallContext (ExecutionContext &exe_ctx)
 {
     m_process_wp = exe_ctx.GetProcessSP();
-    
+
     lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP();
-    
+
     if (frame_sp)
         m_address = frame_sp->GetFrameCodeAddress();
 }
@@ -360,11 +358,11 @@ ClangUserExpression::LockAndCheckContext
 
     if (process_sp != expected_process_sp)
         return false;
-    
+
     process_sp = exe_ctx.GetProcessSP();
     target_sp = exe_ctx.GetTargetSP();
     frame_sp = exe_ctx.GetFrameSP();
-    
+
     if (m_address.IsValid())
     {
         if (!frame_sp)
@@ -372,7 +370,7 @@ ClangUserExpression::LockAndCheckContext
         else
             return (0 == Address::CompareLoadAddress(m_address, frame_sp->GetFrameCodeAddress(), target_sp.get()));
     }
-    
+
     return true;
 }
 
@@ -382,7 +380,7 @@ ClangUserExpression::MatchesContext (Exe
     lldb::TargetSP target_sp;
     lldb::ProcessSP process_sp;
     lldb::StackFrameSP frame_sp;
-    
+
     return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp);
 }
 
@@ -397,7 +395,7 @@ ApplyObjcCastHack(std::string &expr)
 #define OBJC_CAST_HACK_TO   "(int)(long long)["
 
     size_t from_offset;
-    
+
     while ((from_offset = expr.find(OBJC_CAST_HACK_FROM)) != expr.npos)
         expr.replace(from_offset, sizeof(OBJC_CAST_HACK_FROM) - 1, OBJC_CAST_HACK_TO);
 
@@ -426,84 +424,84 @@ ApplyObjcCastHack(std::string &expr)
 //}
 
 bool
-ClangUserExpression::Parse (Stream &error_stream, 
+ClangUserExpression::Parse (Stream &error_stream,
                             ExecutionContext &exe_ctx,
                             lldb_private::ExecutionPolicy execution_policy,
                             bool keep_result_in_memory,
                             bool generate_debug_info)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     Error err;
- 
+
     InstallContext(exe_ctx);
-    
+
     ScanContext(exe_ctx, err);
-    
+
     if (!err.Success())
     {
         error_stream.Printf("warning: %s\n", err.AsCString());
     }
-    
+
     StreamString m_transformed_stream;
-    
+
     ////////////////////////////////////
     // Generate the expression
     //
-    
+
     ApplyObjcCastHack(m_expr_text);
     //ApplyUnicharHack(m_expr_text);
 
     std::unique_ptr<ExpressionSourceCode> source_code (ExpressionSourceCode::CreateWrapped(m_expr_prefix.c_str(), m_expr_text.c_str()));
-    
+
     lldb::LanguageType lang_type;
-    
+
     if (m_cplusplus)
         lang_type = lldb::eLanguageTypeC_plus_plus;
     else if(m_objectivec)
         lang_type = lldb::eLanguageTypeObjC;
     else
         lang_type = lldb::eLanguageTypeC;
-    
+
     if (!source_code->GetText(m_transformed_text, lang_type, m_const_object, m_static_method, exe_ctx))
     {
         error_stream.PutCString ("error: couldn't construct expression body");
         return false;
     }
-    
+
     if (log)
         log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str());
-    
+
     ////////////////////////////////////
     // Set up the target and compiler
     //
-    
+
     Target *target = exe_ctx.GetTargetPtr();
-    
+
     if (!target)
     {
         error_stream.PutCString ("error: invalid target\n");
         return false;
     }
-    
+
     //////////////////////////
     // Parse the expression
     //
-        
+
     m_materializer_ap.reset(new Materializer());
-        
+
     m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory, exe_ctx));
-    
+
     class OnExit
     {
     public:
         typedef std::function <void (void)> Callback;
-        
+
         OnExit (Callback const &callback) :
             m_callback(callback)
         {
         }
-        
+
         ~OnExit ()
         {
             m_callback();
@@ -511,52 +509,52 @@ ClangUserExpression::Parse (Stream &erro
     private:
         Callback m_callback;
     };
-    
+
     OnExit on_exit([this]() { m_expr_decl_map.reset(); });
-    
+
     if (!m_expr_decl_map->WillParse(exe_ctx, m_materializer_ap.get()))
     {
         error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
-        
+
         m_expr_decl_map.reset(); // We are being careful here in the case of breakpoint conditions.
-        
+
         return false;
     }
-    
+
     Process *process = exe_ctx.GetProcessPtr();
     ExecutionContextScope *exe_scope = process;
-    
+
     if (!exe_scope)
         exe_scope = exe_ctx.GetTargetPtr();
-    
+
     ClangExpressionParser parser(exe_scope, *this, generate_debug_info);
-    
+
     unsigned num_errors = parser.Parse (error_stream);
-    
+
     if (num_errors)
     {
         error_stream.Printf ("error: %d errors parsing expression\n", num_errors);
-        
+
         m_expr_decl_map.reset(); // We are being careful here in the case of breakpoint conditions.
-        
+
         return false;
     }
-    
+
     //////////////////////////////////////////////////////////////////////////////////////////
     // Prepare the output of the parser for execution, evaluating it statically if possible
     //
-            
+
     Error jit_error = parser.PrepareForExecution (m_jit_start_addr,
                                                   m_jit_end_addr,
                                                   m_execution_unit_sp,
                                                   exe_ctx,
                                                   m_can_interpret,
                                                   execution_policy);
-    
+
     if (generate_debug_info)
     {
         lldb::ModuleSP jit_module_sp ( m_execution_unit_sp->GetJITModule());
-    
+
         if (jit_module_sp)
         {
             ConstString const_func_name(FunctionName());
@@ -583,9 +581,9 @@ ClangUserExpression::Parse (Stream &erro
 //            jit_sym_vendor->Dump(&strm);
 //        }
     }
-    
+
     m_expr_decl_map.reset(); // Make this go away since we don't need any of its state after parsing.  This also gets rid of any ClangASTImporter::Minions.
-        
+
     if (jit_error.Success())
     {
         if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
@@ -609,16 +607,16 @@ GetObjectPointer (lldb::StackFrameSP fra
                   Error &err)
 {
     err.Clear();
-    
+
     if (!frame_sp)
     {
         err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString());
         return LLDB_INVALID_ADDRESS;
     }
-    
+
     lldb::VariableSP var_sp;
     lldb::ValueObjectSP valobj_sp;
-    
+
     valobj_sp = frame_sp->GetValueForVariableExpressionPath(object_name.AsCString(),
                                                             lldb::eNoDynamicValues,
                                                             StackFrame::eExpressionPathOptionCheckPtrVsMember ||
@@ -628,18 +626,18 @@ GetObjectPointer (lldb::StackFrameSP fra
                                                             StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
                                                             var_sp,
                                                             err);
-    
+
     if (!err.Success())
         return LLDB_INVALID_ADDRESS;
-    
+
     lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
-    
+
     if (ret == LLDB_INVALID_ADDRESS)
     {
         err.SetErrorStringWithFormat("Couldn't load '%s' because its value couldn't be evaluated", object_name.AsCString());
         return LLDB_INVALID_ADDRESS;
     }
-    
+
     return ret;
 }
 
@@ -653,22 +651,22 @@ ClangUserExpression::PrepareToExecuteJIT
     lldb::TargetSP target;
     lldb::ProcessSP process;
     lldb::StackFrameSP frame;
-    
+
     if (!LockAndCheckContext(exe_ctx,
                              target,
-                             process, 
+                             process,
                              frame))
     {
         error_stream.Printf("The context has changed before we could JIT the expression!\n");
         return false;
     }
-    
+
     if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
-    {        
+    {
         if (m_needs_object_ptr)
         {
             ConstString object_name;
-            
+
             if (m_cplusplus)
             {
                 object_name.SetCString("this");
@@ -682,23 +680,23 @@ ClangUserExpression::PrepareToExecuteJIT
                 error_stream.Printf("Need object pointer but don't know the language\n");
                 return false;
             }
-            
+
             Error object_ptr_error;
-            
+
             object_ptr = GetObjectPointer(frame, object_name, object_ptr_error);
-            
+
             if (!object_ptr_error.Success())
             {
                 error_stream.Printf("warning: couldn't get required object pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
                 object_ptr = 0;
             }
-            
+
             if (m_objectivec)
             {
                 ConstString cmd_name("_cmd");
-                
+
                 cmd_ptr = GetObjectPointer(frame, cmd_name, object_ptr_error);
-                
+
                 if (!object_ptr_error.Success())
                 {
                     error_stream.Printf("warning: couldn't get cmd pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
@@ -706,53 +704,53 @@ ClangUserExpression::PrepareToExecuteJIT
                 }
             }
         }
-        
+
         if (m_materialized_address == LLDB_INVALID_ADDRESS)
         {
             Error alloc_error;
-            
+
             IRMemoryMap::AllocationPolicy policy = m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly : IRMemoryMap::eAllocationPolicyMirror;
-            
+
             m_materialized_address = m_execution_unit_sp->Malloc(m_materializer_ap->GetStructByteSize(),
                                                                  m_materializer_ap->GetStructAlignment(),
                                                                  lldb::ePermissionsReadable | lldb::ePermissionsWritable,
                                                                  policy,
                                                                  alloc_error);
-            
+
             if (!alloc_error.Success())
             {
                 error_stream.Printf("Couldn't allocate space for materialized struct: %s\n", alloc_error.AsCString());
                 return false;
             }
         }
-        
+
         struct_address = m_materialized_address;
-        
+
         if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS)
         {
             Error alloc_error;
 
             const size_t stack_frame_size = 512 * 1024;
-            
+
             m_stack_frame_bottom = m_execution_unit_sp->Malloc(stack_frame_size,
                                                                8,
                                                                lldb::ePermissionsReadable | lldb::ePermissionsWritable,
                                                                IRMemoryMap::eAllocationPolicyHostOnly,
                                                                alloc_error);
-            
+
             m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;
-            
+
             if (!alloc_error.Success())
             {
                 error_stream.Printf("Couldn't allocate space for the stack frame: %s\n", alloc_error.AsCString());
                 return false;
             }
         }
-                
+
         Error materialize_error;
-        
+
         m_dematerializer_sp = m_materializer_ap->Materialize(frame, *m_execution_unit_sp, struct_address, materialize_error);
-        
+
         if (!materialize_error.Success())
         {
             error_stream.Printf("Couldn't materialize: %s\n", materialize_error.AsCString());
@@ -770,18 +768,18 @@ ClangUserExpression::FinalizeJITExecutio
                                            lldb::addr_t function_stack_top)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     if (log)
         log->Printf("-- [ClangUserExpression::FinalizeJITExecution] Dematerializing after execution --");
-        
+
     if (!m_dematerializer_sp)
     {
         error_stream.Printf ("Couldn't apply expression side effects : no dematerializer is present");
         return false;
     }
-    
+
     Error dematerialize_error;
-    
+
     m_dematerializer_sp->Dematerialize(dematerialize_error, result, function_stack_bottom, function_stack_top);
 
     if (!dematerialize_error.Success())
@@ -789,14 +787,14 @@ ClangUserExpression::FinalizeJITExecutio
         error_stream.Printf ("Couldn't apply expression side effects : %s\n", dematerialize_error.AsCString("unknown error"));
         return false;
     }
-        
+
     if (result)
         result->TransferAddress();
-    
+
     m_dematerializer_sp.reset();
-    
+
     return true;
-}        
+}
 
 lldb::ExpressionResults
 ClangUserExpression::Execute (Stream &error_stream,
@@ -812,24 +810,24 @@ ClangUserExpression::Execute (Stream &er
     if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
     {
         lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;
-                
+
         lldb::addr_t object_ptr = 0;
         lldb::addr_t cmd_ptr = 0;
-        
+
         if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr))
         {
             error_stream.Printf("Errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__);
             return lldb::eExpressionSetupError;
         }
-        
+
         lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;
         lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;
-        
+
         if (m_can_interpret)
-        {            
+        {
             llvm::Module *module = m_execution_unit_sp->GetModule();
             llvm::Function *function = m_execution_unit_sp->GetFunction();
-            
+
             if (!module || !function)
             {
                 error_stream.Printf("Supposed to interpret, but nothing is there");
@@ -837,22 +835,22 @@ ClangUserExpression::Execute (Stream &er
             }
 
             Error interpreter_error;
-            
+
             llvm::SmallVector <lldb::addr_t, 3> args;
-            
+
             if (m_needs_object_ptr)
             {
                 args.push_back(object_ptr);
-                
+
                 if (m_objectivec)
                     args.push_back(cmd_ptr);
             }
-            
+
             args.push_back(struct_address);
-            
+
             function_stack_bottom = m_stack_frame_bottom;
             function_stack_top = m_stack_frame_top;
-            
+
             IRInterpreter::Interpret (*module,
                                       *function,
                                       args,
@@ -860,7 +858,7 @@ ClangUserExpression::Execute (Stream &er
                                       interpreter_error,
                                       function_stack_bottom,
                                       function_stack_top);
-            
+
             if (!interpreter_error.Success())
             {
                 error_stream.Printf("Supposed to interpret, but failed: %s", interpreter_error.AsCString());
@@ -874,54 +872,54 @@ ClangUserExpression::Execute (Stream &er
                 error_stream.Printf("ClangUserExpression::Execute called with no thread selected.");
                 return lldb::eExpressionSetupError;
             }
-                
+
             Address wrapper_address (m_jit_start_addr);
-            
+
             llvm::SmallVector <lldb::addr_t, 3> args;
-            
+
             if (m_needs_object_ptr) {
                 args.push_back(object_ptr);
                 if (m_objectivec)
                     args.push_back(cmd_ptr);
             }
-            
+
             args.push_back(struct_address);
-            
-            lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), 
-                                                                              wrapper_address, 
+
+            lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(),
+                                                                              wrapper_address,
                                                                               args,
                                                                               options,
                                                                               shared_ptr_to_me));
-            
+
             if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream))
                 return lldb::eExpressionSetupError;
-            
+
             lldb::addr_t function_stack_pointer = static_cast<ThreadPlanCallFunction *>(call_plan_sp.get())->GetFunctionStackPointer();
 
             function_stack_bottom = function_stack_pointer - Host::GetPageSize();
             function_stack_top = function_stack_pointer;
-            
+
             if (log)
                 log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --");
-            
+
             if (exe_ctx.GetProcessPtr())
                 exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
-                
+
             lldb::ExpressionResults execution_result = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx,
                                                                                        call_plan_sp,
                                                                                        options,
                                                                                        error_stream);
-            
+
             if (exe_ctx.GetProcessPtr())
                 exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
-                
+
             if (log)
                 log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --");
 
             if (execution_result == lldb::eExpressionInterrupted || execution_result == lldb::eExpressionHitBreakpoint)
             {
                 const char *error_desc = NULL;
-                
+
                 if (call_plan_sp)
                 {
                     lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
@@ -932,7 +930,7 @@ ClangUserExpression::Execute (Stream &er
                     error_stream.Printf ("Execution was interrupted, reason: %s.", error_desc);
                 else
                     error_stream.PutCString ("Execution was interrupted.");
-                    
+
                 if ((execution_result == lldb::eExpressionInterrupted && options.DoesUnwindOnError())
                     || (execution_result == lldb::eExpressionHitBreakpoint && options.DoesIgnoreBreakpoints()))
                     error_stream.PutCString ("\nThe process has been returned to the state before expression evaluation.");
@@ -955,7 +953,7 @@ ClangUserExpression::Execute (Stream &er
                 return execution_result;
             }
         }
-        
+
         if  (FinalizeJITExecution (error_stream, exe_ctx, result, function_stack_bottom, function_stack_top))
         {
             return lldb::eExpressionCompleted;
@@ -986,7 +984,7 @@ ClangUserExpression::Evaluate (Execution
     const lldb::LanguageType language = options.GetLanguage();
     const ResultType desired_type = options.DoesCoerceToId() ? ClangUserExpression::eResultTypeId : ClangUserExpression::eResultTypeAny;
     lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
-    
+
     Process *process = exe_ctx.GetProcessPtr();
 
     if (process == NULL || process->GetState() != lldb::eStateStopped)
@@ -995,33 +993,33 @@ ClangUserExpression::Evaluate (Execution
         {
             if (log)
                 log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
-            
+
             error.SetErrorString ("expression needed to run but couldn't");
-            
+
             return execution_results;
         }
     }
-    
+
     if (process == NULL || !process->CanJIT())
         execution_policy = eExecutionPolicyNever;
-    
+
     ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix, language, desired_type));
 
     StreamString error_stream;
-        
+
     if (log)
         log->Printf("== [ClangUserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
-    
+
     const bool keep_expression_in_memory = true;
     const bool generate_debug_info = options.GetGenerateDebugInfo();
-    
+
     if (options.InvokeCancelCallback (lldb::eExpressionEvaluationParse))
     {
         error.SetErrorString ("expression interrupted by callback before parse");
         result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
         return lldb::eExpressionInterrupted;
     }
-    
+
     if (!user_expression_sp->Parse (error_stream,
                                     exe_ctx,
                                     execution_policy,
@@ -1042,7 +1040,7 @@ ClangUserExpression::Evaluate (Execution
         {
             if (log)
                 log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
-            
+
             if (error_stream.GetString().empty())
                 error.SetExpressionError (lldb::eExpressionSetupError, "expression needed to run but couldn't");
         }
@@ -1054,34 +1052,34 @@ ClangUserExpression::Evaluate (Execution
                 result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
                 return lldb::eExpressionInterrupted;
             }
-            
+
             error_stream.GetString().clear();
-            
+
             if (log)
                 log->Printf("== [ClangUserExpression::Evaluate] Executing expression ==");
 
-            execution_results = user_expression_sp->Execute (error_stream, 
+            execution_results = user_expression_sp->Execute (error_stream,
                                                              exe_ctx,
                                                              options,
                                                              user_expression_sp,
                                                              expr_result);
-            
+
             if (execution_results != lldb::eExpressionCompleted)
             {
                 if (log)
                     log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally ==");
-                
+
                 if (error_stream.GetString().empty())
                     error.SetExpressionError (execution_results, "expression failed to execute, unknown error");
                 else
                     error.SetExpressionError (execution_results, error_stream.GetString().c_str());
             }
-            else 
+            else
             {
                 if (expr_result)
                 {
                     result_valobj_sp = expr_result->GetValueObject();
-                    
+
                     if (log)
                         log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==",
                                     result_valobj_sp->GetValueAsCString());
@@ -1090,19 +1088,19 @@ ClangUserExpression::Evaluate (Execution
                 {
                     if (log)
                         log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with no result ==");
-                    
+
                     error.SetError(ClangUserExpression::kNoResult, lldb::eErrorTypeGeneric);
                 }
             }
         }
     }
-    
+
     if (options.InvokeCancelCallback(lldb::eExpressionEvaluationComplete))
     {
         error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback after complete");
         return lldb::eExpressionInterrupted;
     }
-    
+
     if (result_valobj_sp.get() == NULL)
     {
         result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);

Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original)
+++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Sun Jul  6 12:54:58 2014
@@ -33,7 +33,7 @@ static char ID;
 #define VALID_POINTER_CHECK_NAME "$__lldb_valid_pointer_check"
 #define VALID_OBJC_OBJECT_CHECK_NAME "$__lldb_objc_object_check"
 
-static const char g_valid_pointer_check_text[] = 
+static const char g_valid_pointer_check_text[] =
 "extern \"C\" void\n"
 "$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n"
 "{\n"
@@ -56,22 +56,22 @@ DynamicCheckerFunctions::Install(Stream
                                                          VALID_POINTER_CHECK_NAME));
     if (!m_valid_pointer_check->Install(error_stream, exe_ctx))
         return false;
-    
+
     Process *process = exe_ctx.GetProcessPtr();
 
     if (process)
     {
         ObjCLanguageRuntime *objc_language_runtime = process->GetObjCLanguageRuntime();
-        
+
         if (objc_language_runtime)
         {
             m_objc_object_check.reset(objc_language_runtime->CreateObjectChecker(VALID_OBJC_OBJECT_CHECK_NAME));
-            
+
             if (!m_objc_object_check->Install(error_stream, exe_ctx))
                 return false;
         }
     }
-        
+
     return true;
 }
 
@@ -94,7 +94,7 @@ DynamicCheckerFunctions::DoCheckersExpla
 }
 
 
-static std::string 
+static std::string
 PrintValue(llvm::Value *V, bool truncate = false)
 {
     std::string s;
@@ -128,10 +128,10 @@ PrintValue(llvm::Value *V, bool truncate
 ///
 /// - InspectInstruction [default: does nothing]
 ///
-/// - InspectBasicBlock [default: iterates through the instructions in a 
+/// - InspectBasicBlock [default: iterates through the instructions in a
 ///   basic block calling InspectInstruction]
 ///
-/// - InspectFunction [default: iterates through the basic blocks in a 
+/// - InspectFunction [default: iterates through the basic blocks in a
 ///   function calling InspectBasicBlock]
 //----------------------------------------------------------------------
 class Instrumenter {
@@ -150,7 +150,7 @@ public:
         m_intptr_ty(NULL)
     {
     }
-    
+
     virtual~Instrumenter ()
     {
     }
@@ -168,7 +168,7 @@ public:
     {
         return InspectFunction(function);
     }
-    
+
     //------------------------------------------------------------------
     /// Instrument all the instructions found by Inspect()
     ///
@@ -184,7 +184,7 @@ public:
             if (!InstrumentInstruction(*ii))
                 return false;
         }
-        
+
         return true;
     }
 protected:
@@ -192,13 +192,13 @@ protected:
     /// Add instrumentation to a single instruction
     ///
     /// @param[in] inst
-    ///     The instruction to be instrumented. 
+    ///     The instruction to be instrumented.
     ///
     /// @return
     ///     True on success; false otherwise.
     //------------------------------------------------------------------
     virtual bool InstrumentInstruction(llvm::Instruction *inst) = 0;
-    
+
     //------------------------------------------------------------------
     /// Register a single instruction to be instrumented
     ///
@@ -209,7 +209,7 @@ protected:
     {
         m_to_instrument.push_back(&i);
     }
-    
+
     //------------------------------------------------------------------
     /// Determine whether a single instruction is interesting to
     /// instrument, and, if so, call RegisterInstruction
@@ -224,7 +224,7 @@ protected:
     {
         return true;
     }
-    
+
     //------------------------------------------------------------------
     /// Scan a basic block to see if any instructions are interesting
     ///
@@ -243,15 +243,15 @@ protected:
             if (!InspectInstruction(*ii))
                 return false;
         }
-        
+
         return true;
     }
-    
+
     //------------------------------------------------------------------
     /// Scan a function to see if any instructions are interesting
     ///
     /// @param[in] f
-    ///     The function to be inspected. 
+    ///     The function to be inspected.
     ///
     /// @return
     ///     False if there was an error scanning; true otherwise.
@@ -265,12 +265,12 @@ protected:
             if (!InspectBasicBlock(*bbi))
                 return false;
         }
-        
+
         return true;
     }
-    
+
     //------------------------------------------------------------------
-    /// Build a function pointer for a function with signature 
+    /// Build a function pointer for a function with signature
     /// void (*)(uint8_t*) with a given address
     ///
     /// @param[in] start_address
@@ -282,19 +282,19 @@ protected:
     llvm::Value *BuildPointerValidatorFunc(lldb::addr_t start_address)
     {
         llvm::Type *param_array[1];
-        
+
         param_array[0] = const_cast<llvm::PointerType*>(GetI8PtrTy());
-        
+
         ArrayRef<llvm::Type*> params(param_array, 1);
-        
+
         FunctionType *fun_ty = FunctionType::get(llvm::Type::getVoidTy(m_module.getContext()), params, true);
         PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
         Constant *fun_addr_int = ConstantInt::get(GetIntptrTy(), start_address, false);
         return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
     }
-    
+
     //------------------------------------------------------------------
-    /// Build a function pointer for a function with signature 
+    /// Build a function pointer for a function with signature
     /// void (*)(uint8_t*, uint8_t*) with a given address
     ///
     /// @param[in] start_address
@@ -306,41 +306,41 @@ protected:
     llvm::Value *BuildObjectCheckerFunc(lldb::addr_t start_address)
     {
         llvm::Type *param_array[2];
-        
+
         param_array[0] = const_cast<llvm::PointerType*>(GetI8PtrTy());
         param_array[1] = const_cast<llvm::PointerType*>(GetI8PtrTy());
-        
+
         ArrayRef<llvm::Type*> params(param_array, 2);
-        
+
         FunctionType *fun_ty = FunctionType::get(llvm::Type::getVoidTy(m_module.getContext()), params, true);
         PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
         Constant *fun_addr_int = ConstantInt::get(GetIntptrTy(), start_address, false);
         return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
     }
-    
+
     PointerType *GetI8PtrTy()
     {
         if (!m_i8ptr_ty)
             m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext());
-            
+
         return m_i8ptr_ty;
     }
-    
+
     IntegerType *GetIntptrTy()
     {
         if (!m_intptr_ty)
         {
             llvm::DataLayout data_layout(&m_module);
-            
+
             m_intptr_ty = llvm::Type::getIntNTy(m_module.getContext(), data_layout.getPointerSizeInBits());
         }
-        
+
         return m_intptr_ty;
     }
-    
+
     typedef std::vector <llvm::Instruction *>   InstVector;
     typedef InstVector::iterator                InstIterator;
-    
+
     InstVector                  m_to_instrument;        ///< List of instructions the inspector found
     llvm::Module               &m_module;               ///< The module which is being instrumented
     DynamicCheckerFunctions    &m_checker_functions;    ///< The dynamic checker functions for the process
@@ -358,7 +358,7 @@ public:
         m_valid_pointer_check_func(NULL)
     {
     }
-    
+
     virtual ~ValidPointerChecker ()
     {
     }
@@ -368,53 +368,53 @@ private:
         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
         if (log)
-            log->Printf("Instrumenting load/store instruction: %s\n", 
+            log->Printf("Instrumenting load/store instruction: %s\n",
                         PrintValue(inst).c_str());
-        
+
         if (!m_valid_pointer_check_func)
             m_valid_pointer_check_func = BuildPointerValidatorFunc(m_checker_functions.m_valid_pointer_check->StartAddress());
-        
+
         llvm::Value *dereferenced_ptr = NULL;
-        
+
         if (llvm::LoadInst *li = dyn_cast<llvm::LoadInst> (inst))
             dereferenced_ptr = li->getPointerOperand();
         else if (llvm::StoreInst *si = dyn_cast<llvm::StoreInst> (inst))
             dereferenced_ptr = si->getPointerOperand();
         else
             return false;
-        
+
         // Insert an instruction to cast the loaded value to int8_t*
-        
+
         BitCastInst *bit_cast = new BitCastInst(dereferenced_ptr,
                                                 GetI8PtrTy(),
                                                 "",
                                                 inst);
-        
+
         // Insert an instruction to call the helper with the result
-        
+
         llvm::Value *arg_array[1];
-        
+
         arg_array[0] = bit_cast;
-        
+
         llvm::ArrayRef<llvm::Value *> args(arg_array, 1);
-        
-        CallInst::Create(m_valid_pointer_check_func, 
+
+        CallInst::Create(m_valid_pointer_check_func,
                          args,
                          "",
                          inst);
-            
+
         return true;
     }
-    
+
     bool InspectInstruction(llvm::Instruction &i)
     {
         if (dyn_cast<llvm::LoadInst> (&i) ||
             dyn_cast<llvm::StoreInst> (&i))
             RegisterInstruction(i);
-        
+
         return true;
     }
-    
+
     llvm::Value         *m_valid_pointer_check_func;
 };
 
@@ -496,7 +496,7 @@ private:
 
         ArrayRef<llvm::Value*> args(arg_array, 2);
 
-        CallInst::Create(m_objc_object_check_func, 
+        CallInst::Create(m_objc_object_check_func,
                          args,
                          "",
                          inst);
@@ -612,52 +612,52 @@ bool
 IRDynamicChecks::runOnModule(llvm::Module &M)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     llvm::Function* function = M.getFunction(StringRef(m_func_name.c_str()));
-    
+
     if (!function)
     {
         if (log)
             log->Printf("Couldn't find %s() in the module", m_func_name.c_str());
-        
+
         return false;
     }
 
     if (m_checker_functions.m_valid_pointer_check.get())
     {
         ValidPointerChecker vpc(M, m_checker_functions);
-        
+
         if (!vpc.Inspect(*function))
             return false;
-        
+
         if (!vpc.Instrument())
             return false;
     }
-    
+
     if (m_checker_functions.m_objc_object_check.get())
     {
         ObjcObjectChecker ooc(M, m_checker_functions);
-        
+
         if (!ooc.Inspect(*function))
             return false;
-        
+
         if (!ooc.Instrument())
             return false;
     }
-        
+
     if (log && log->GetVerbose())
     {
         std::string s;
         raw_string_ostream oss(s);
-        
+
         M.print(oss, NULL);
-        
+
         oss.flush();
-        
+
         log->Printf ("Module after dynamic checks: \n%s", s.c_str());
     }
-    
-    return true;    
+
+    return true;
 }
 
 void

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Sun Jul  6 12:54:58 2014
@@ -7,14 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/SourceMgr.h"
-// Project includes
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Disassembler.h"
@@ -48,39 +44,39 @@ lldb::addr_t
 IRExecutionUnit::WriteNow (const uint8_t *bytes,
                            size_t size,
                            Error &error)
-{    
+{
     lldb::addr_t allocation_process_addr = Malloc (size,
                                                    8,
                                                    lldb::ePermissionsWritable | lldb::ePermissionsReadable,
                                                    eAllocationPolicyMirror,
                                                    error);
-    
+
     if (!error.Success())
         return LLDB_INVALID_ADDRESS;
-    
+
     WriteMemory(allocation_process_addr, bytes, size, error);
-    
+
     if (!error.Success())
     {
         Error err;
         Free (allocation_process_addr, err);
-        
+
         return LLDB_INVALID_ADDRESS;
     }
-    
+
     if (Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS))
     {
         DataBufferHeap my_buffer(size, 0);
         Error err;
         ReadMemory(my_buffer.GetBytes(), allocation_process_addr, size, err);
-        
+
         if (err.Success())
         {
             DataExtractor my_extractor(my_buffer.GetBytes(), my_buffer.GetByteSize(), lldb::eByteOrderBig, 8);
             my_extractor.PutToLog(log, 0, my_buffer.GetByteSize(), allocation_process_addr, 16, DataExtractor::TypeUInt8);
         }
     }
-    
+
     return allocation_process_addr;
 }
 
@@ -89,9 +85,9 @@ IRExecutionUnit::FreeNow (lldb::addr_t a
 {
     if (allocation == LLDB_INVALID_ADDRESS)
         return;
-    
+
     Error err;
-    
+
     Free(allocation, err);
 }
 
@@ -100,16 +96,16 @@ IRExecutionUnit::DisassembleFunction (St
                                       lldb::ProcessSP &process_wp)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     ExecutionContext exe_ctx(process_wp);
-        
+
     Error ret;
-    
+
     ret.Clear();
-    
+
     lldb::addr_t func_local_addr = LLDB_INVALID_ADDRESS;
     lldb::addr_t func_remote_addr = LLDB_INVALID_ADDRESS;
-        
+
     for (JittedFunction &function : m_jitted_functions)
     {
         if (strstr(function.m_name.c_str(), m_name.AsCString()))
@@ -118,31 +114,31 @@ IRExecutionUnit::DisassembleFunction (St
             func_remote_addr = function.m_remote_addr;
         }
     }
-    
+
     if (func_local_addr == LLDB_INVALID_ADDRESS)
     {
         ret.SetErrorToGenericError();
         ret.SetErrorStringWithFormat("Couldn't find function %s for disassembly", m_name.AsCString());
         return ret;
     }
-    
+
     if (log)
         log->Printf("Found function, has local address 0x%" PRIx64 " and remote address 0x%" PRIx64, (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
-    
+
     std::pair <lldb::addr_t, lldb::addr_t> func_range;
-    
+
     func_range = GetRemoteRangeForLocal(func_local_addr);
-    
+
     if (func_range.first == 0 && func_range.second == 0)
     {
         ret.SetErrorToGenericError();
         ret.SetErrorStringWithFormat("Couldn't find code range for function %s", m_name.AsCString());
         return ret;
     }
-    
+
     if (log)
         log->Printf("Function's code range is [0x%" PRIx64 "+0x%" PRIx64 "]", func_range.first, func_range.second);
-    
+
     Target *target = exe_ctx.GetTargetPtr();
     if (!target)
     {
@@ -150,44 +146,44 @@ IRExecutionUnit::DisassembleFunction (St
         ret.SetErrorString("Couldn't find the target");
         return ret;
     }
-    
+
     lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second, 0));
-    
+
     Process *process = exe_ctx.GetProcessPtr();
     Error err;
     process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
-    
+
     if (!err.Success())
     {
         ret.SetErrorToGenericError();
         ret.SetErrorStringWithFormat("Couldn't read from process: %s", err.AsCString("unknown error"));
         return ret;
     }
-    
+
     ArchSpec arch(target->GetArchitecture());
-    
+
     const char *plugin_name = NULL;
     const char *flavor_string = NULL;
     lldb::DisassemblerSP disassembler_sp = Disassembler::FindPlugin(arch, flavor_string, plugin_name);
-    
+
     if (!disassembler_sp)
     {
         ret.SetErrorToGenericError();
         ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName());
         return ret;
     }
-    
+
     if (!process)
     {
         ret.SetErrorToGenericError();
         ret.SetErrorString("Couldn't find the process");
         return ret;
     }
-    
+
     DataExtractor extractor(buffer_sp,
                             process->GetByteOrder(),
                             target->GetArchitecture().GetAddressByteSize());
-    
+
     if (log)
     {
         log->Printf("Function data has contents:");
@@ -198,12 +194,12 @@ IRExecutionUnit::DisassembleFunction (St
                             16,
                             DataExtractor::TypeUInt8);
     }
-    
+
     disassembler_sp->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false, false);
-    
+
     InstructionList &instruction_list = disassembler_sp->GetInstructionList();
     const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
-    
+
     for (size_t instruction_index = 0, num_instructions = instruction_list.GetSize();
          instruction_index < num_instructions;
          ++instruction_index)
@@ -225,7 +221,7 @@ IRExecutionUnit::DisassembleFunction (St
 static void ReportInlineAsmError(const llvm::SMDiagnostic &diagnostic, void *Context, unsigned LocCookie)
 {
     Error *err = static_cast<Error*>(Context);
-    
+
     if (err && err->Success())
     {
         err->SetErrorToGenericError();
@@ -239,52 +235,52 @@ IRExecutionUnit::GetRunnableInfo(Error &
                                  lldb::addr_t &func_end)
 {
     lldb::ProcessSP process_sp(GetProcessWP().lock());
-    
+
     static Mutex s_runnable_info_mutex(Mutex::Type::eMutexTypeRecursive);
-    
+
     func_addr = LLDB_INVALID_ADDRESS;
     func_end = LLDB_INVALID_ADDRESS;
-    
+
     if (!process_sp)
     {
         error.SetErrorToGenericError();
         error.SetErrorString("Couldn't write the JIT compiled code into the process because the process is invalid");
         return;
     }
-    
+
     if (m_did_jit)
     {
         func_addr = m_function_load_addr;
         func_end = m_function_end_load_addr;
-        
+
         return;
     };
-    
+
     Mutex::Locker runnable_info_mutex_locker(s_runnable_info_mutex);
-    
+
     m_did_jit = true;
-    
+
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     std::string error_string;
-    
+
     if (log)
     {
         std::string s;
         llvm::raw_string_ostream oss(s);
-        
+
         m_module->print(oss, NULL);
-        
+
         oss.flush();
-        
+
         log->Printf ("Module being sent to JIT: \n%s", s.c_str());
     }
-    
+
     llvm::Triple triple(m_module->getTargetTriple());
     llvm::Function *function = m_module->getFunction (m_name.AsCString());
     llvm::Reloc::Model relocModel;
     llvm::CodeModel::Model codeModel;
-    
+
     if (triple.isOSBinFormatELF())
     {
         relocModel = llvm::Reloc::Static;
@@ -296,11 +292,11 @@ IRExecutionUnit::GetRunnableInfo(Error &
         relocModel = llvm::Reloc::PIC_;
         codeModel = llvm::CodeModel::Small;
     }
-    
+
     m_module_ap->getContext().setInlineAsmDiagnosticHandler(ReportInlineAsmError, &error);
-    
+
     llvm::EngineBuilder builder(m_module_ap.get());
-    
+
     builder.setEngineKind(llvm::EngineKind::JIT)
     .setErrorStr(&error_string)
     .setRelocationModel(relocModel)
@@ -309,21 +305,21 @@ IRExecutionUnit::GetRunnableInfo(Error &
     .setAllocateGVsWithCode(true)
     .setCodeModel(codeModel)
     .setUseMCJIT(true);
-    
+
     llvm::StringRef mArch;
     llvm::StringRef mCPU;
     llvm::SmallVector<std::string, 0> mAttrs;
-    
+
     for (std::string &feature : m_cpu_features)
         mAttrs.push_back(feature);
-    
+
     llvm::TargetMachine *target_machine = builder.selectTarget(triple,
                                                                mArch,
                                                                mCPU,
                                                                mAttrs);
-    
+
     m_execution_engine_ap.reset(builder.create(target_machine));
-    
+
     if (!m_execution_engine_ap.get())
     {
         error.SetErrorToGenericError();
@@ -334,46 +330,46 @@ IRExecutionUnit::GetRunnableInfo(Error &
     {
         m_module_ap.release(); // ownership was transferred
     }
-    
+
     // Make sure we see all sections, including ones that don't have relocations...
     m_execution_engine_ap->setProcessAllSections(true);
-    
+
     m_execution_engine_ap->DisableLazyCompilation();
-    
+
     // We don't actually need the function pointer here, this just forces it to get resolved.
-    
+
     void *fun_ptr = m_execution_engine_ap->getPointerToFunction(function);
-    
+
     if (!error.Success())
     {
         // We got an error through our callback!
         return;
     }
-    
+
     if (!function)
     {
         error.SetErrorToGenericError();
         error.SetErrorStringWithFormat("Couldn't find '%s' in the JITted module", m_name.AsCString());
         return;
     }
-    
+
     if (!fun_ptr)
     {
         error.SetErrorToGenericError();
         error.SetErrorStringWithFormat("'%s' was in the JITted module but wasn't lowered", m_name.AsCString());
         return;
     }
-    
+
     m_jitted_functions.push_back (JittedFunction(m_name.AsCString(), (lldb::addr_t)fun_ptr));
-    
+
     CommitAllocations(process_sp);
     ReportAllocations(*m_execution_engine_ap);
     WriteData(process_sp);
-            
+
     for (JittedFunction &jitted_function : m_jitted_functions)
     {
         jitted_function.m_remote_addr = GetRemoteAddressForLocal (jitted_function.m_local_addr);
-        
+
         if (!jitted_function.m_name.compare(m_name.AsCString()))
         {
             AddrRange func_range = GetRemoteRangeForLocal(jitted_function.m_local_addr);
@@ -381,15 +377,15 @@ IRExecutionUnit::GetRunnableInfo(Error &
             m_function_load_addr = jitted_function.m_remote_addr;
         }
     }
-    
+
     if (log)
     {
         log->Printf("Code can be run in the target.");
-        
+
         StreamString disassembly_stream;
-        
+
         Error err = DisassembleFunction(disassembly_stream, process_sp);
-        
+
         if (!err.Success())
         {
             log->Printf("Couldn't disassemble function : %s", err.AsCString("unknown error"));
@@ -398,18 +394,18 @@ IRExecutionUnit::GetRunnableInfo(Error &
         {
             log->Printf("Function disassembly:\n%s", disassembly_stream.GetData());
         }
-        
+
         log->Printf("Sections: ");
         for (AllocationRecord &record : m_records)
         {
             if (record.m_process_address != LLDB_INVALID_ADDRESS)
             {
                 record.dump(log);
-                
+
                 DataBufferHeap my_buffer(record.m_size, 0);
                 Error err;
                 ReadMemory(my_buffer.GetBytes(), record.m_process_address, record.m_size, err);
-                
+
                 if (err.Success())
                 {
                     DataExtractor my_extractor(my_buffer.GetBytes(), my_buffer.GetByteSize(), lldb::eByteOrderBig, 8);
@@ -418,10 +414,10 @@ IRExecutionUnit::GetRunnableInfo(Error &
             }
         }
     }
-    
+
     func_addr = m_function_load_addr;
     func_end = m_function_end_load_addr;
-    
+
     return;
 }
 
@@ -508,7 +504,7 @@ IRExecutionUnit::GetSectionTypeFromSecti
         case AllocationKind::Global:sect_type = lldb::eSectionTypeData; break;
         case AllocationKind::Bytes: sect_type = lldb::eSectionTypeOther; break;
     }
-    
+
     if (!name.empty())
     {
         if (name.equals("__text") || name.equals(".text"))
@@ -527,46 +523,46 @@ IRExecutionUnit::GetSectionTypeFromSecti
                     else if (dwarf_name.equals("aranges"))
                         sect_type = lldb::eSectionTypeDWARFDebugAranges;
                     break;
-                    
+
                 case 'f':
                     if (dwarf_name.equals("frame"))
                         sect_type = lldb::eSectionTypeDWARFDebugFrame;
                     break;
-                    
+
                 case 'i':
                     if (dwarf_name.equals("info"))
                         sect_type = lldb::eSectionTypeDWARFDebugInfo;
                     break;
-                    
+
                 case 'l':
                     if (dwarf_name.equals("line"))
                         sect_type = lldb::eSectionTypeDWARFDebugLine;
                     else if (dwarf_name.equals("loc"))
                         sect_type = lldb::eSectionTypeDWARFDebugLoc;
                     break;
-                    
+
                 case 'm':
                     if (dwarf_name.equals("macinfo"))
                         sect_type = lldb::eSectionTypeDWARFDebugMacInfo;
                     break;
-                    
+
                 case 'p':
                     if (dwarf_name.equals("pubnames"))
                         sect_type = lldb::eSectionTypeDWARFDebugPubNames;
                     else if (dwarf_name.equals("pubtypes"))
                         sect_type = lldb::eSectionTypeDWARFDebugPubTypes;
                     break;
-                    
+
                 case 's':
                     if (dwarf_name.equals("str"))
                         sect_type = lldb::eSectionTypeDWARFDebugStr;
                     break;
-                    
+
                 case 'r':
                     if (dwarf_name.equals("ranges"))
                         sect_type = lldb::eSectionTypeDWARFDebugRanges;
                     break;
-                    
+
                 default:
                     break;
             }
@@ -611,7 +607,7 @@ IRExecutionUnit::MemoryManager::allocate
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     uint8_t *return_value = m_default_mm_ap->allocateSpace(Size, Alignment);
-    
+
     m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
                                                   lldb::ePermissionsReadable | lldb::ePermissionsWritable,
                                                   GetSectionTypeFromSectionName (llvm::StringRef(), AllocationKind::Bytes),
@@ -619,13 +615,13 @@ IRExecutionUnit::MemoryManager::allocate
                                                   Alignment,
                                                   eSectionIDInvalid,
                                                   NULL));
-    
+
     if (log)
     {
         log->Printf("IRExecutionUnit::allocateSpace(Size=%" PRIu64 ", Alignment=%u) = %p",
                                (uint64_t)Size, Alignment, return_value);
     }
-        
+
     return return_value;
 }
 
@@ -636,9 +632,9 @@ IRExecutionUnit::MemoryManager::allocate
                                                     llvm::StringRef SectionName)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     uint8_t *return_value = m_default_mm_ap->allocateCodeSection(Size, Alignment, SectionID, SectionName);
-    
+
     m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
                                                   lldb::ePermissionsReadable | lldb::ePermissionsExecutable,
                                                   GetSectionTypeFromSectionName (SectionName, AllocationKind::Code),
@@ -646,13 +642,13 @@ IRExecutionUnit::MemoryManager::allocate
                                                   Alignment,
                                                   SectionID,
                                                   SectionName.str().c_str()));
-    
+
     if (log)
     {
         log->Printf("IRExecutionUnit::allocateCodeSection(Size=0x%" PRIx64 ", Alignment=%u, SectionID=%u) = %p",
                     (uint64_t)Size, Alignment, SectionID, return_value);
     }
-        
+
     return return_value;
 }
 
@@ -666,7 +662,7 @@ IRExecutionUnit::MemoryManager::allocate
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     uint8_t *return_value = m_default_mm_ap->allocateDataSection(Size, Alignment, SectionID, SectionName, IsReadOnly);
-    
+
     m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
                                                   lldb::ePermissionsReadable | (IsReadOnly ? 0 : lldb::ePermissionsWritable),
                                                   GetSectionTypeFromSectionName (SectionName, AllocationKind::Data),
@@ -679,8 +675,8 @@ IRExecutionUnit::MemoryManager::allocate
         log->Printf("IRExecutionUnit::allocateDataSection(Size=0x%" PRIx64 ", Alignment=%u, SectionID=%u) = %p",
                     (uint64_t)Size, Alignment, SectionID, return_value);
     }
-        
-    return return_value; 
+
+    return return_value;
 }
 
 uint8_t *
@@ -690,7 +686,7 @@ IRExecutionUnit::MemoryManager::allocate
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     uint8_t *return_value = m_default_mm_ap->allocateGlobal(Size, Alignment);
-    
+
     m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
                                                   lldb::ePermissionsReadable | lldb::ePermissionsWritable,
                                                   GetSectionTypeFromSectionName (llvm::StringRef(), AllocationKind::Global),
@@ -698,13 +694,13 @@ IRExecutionUnit::MemoryManager::allocate
                                                   Alignment,
                                                   eSectionIDInvalid,
                                                   NULL));
-    
+
     if (log)
     {
         log->Printf("IRExecutionUnit::allocateGlobal(Size=0x%" PRIx64 ", Alignment=%u) = %p",
                     (uint64_t)Size, Alignment, return_value);
     }
-    
+
     return return_value;
 }
 
@@ -726,9 +722,9 @@ IRExecutionUnit::GetRemoteAddressForLoca
         {
             if (record.m_process_address == LLDB_INVALID_ADDRESS)
                 return LLDB_INVALID_ADDRESS;
-            
+
             lldb::addr_t ret = record.m_process_address + (local_address - record.m_host_address);
-            
+
             if (log)
             {
                 log->Printf("IRExecutionUnit::GetRemoteAddressForLocal() found 0x%" PRIx64 " in [0x%" PRIx64 "..0x%" PRIx64 "], and returned 0x%" PRIx64 " from [0x%" PRIx64 "..0x%" PRIx64 "].",
@@ -739,7 +735,7 @@ IRExecutionUnit::GetRemoteAddressForLoca
                             record.m_process_address,
                             record.m_process_address + record.m_size);
             }
-            
+
             return ret;
         }
     }
@@ -757,11 +753,11 @@ IRExecutionUnit::GetRemoteRangeForLocal
         {
             if (record.m_process_address == LLDB_INVALID_ADDRESS)
                 return AddrRange(0, 0);
-            
+
             return AddrRange(record.m_process_address, record.m_size);
         }
     }
-    
+
     return AddrRange (0, 0);
 }
 
@@ -769,14 +765,14 @@ bool
 IRExecutionUnit::CommitAllocations (lldb::ProcessSP &process_sp)
 {
     bool ret = true;
-    
+
     lldb_private::Error err;
-    
+
     for (AllocationRecord &record : m_records)
     {
         if (record.m_process_address != LLDB_INVALID_ADDRESS)
             continue;
-        
+
         switch (record.m_sect_type)
         {
         case lldb::eSectionTypeInvalid:
@@ -805,14 +801,14 @@ IRExecutionUnit::CommitAllocations (lldb
                                                err);
             break;
         }
-        
+
         if (!err.Success())
         {
             ret = false;
             break;
         }
     }
-    
+
     if (!ret)
     {
         for (AllocationRecord &record : m_records)
@@ -824,7 +820,7 @@ IRExecutionUnit::CommitAllocations (lldb
             }
         }
     }
-    
+
     return ret;
 }
 
@@ -835,13 +831,13 @@ IRExecutionUnit::ReportAllocations (llvm
     {
         if (record.m_process_address == LLDB_INVALID_ADDRESS)
             continue;
-        
+
         if (record.m_section_id == eSectionIDInvalid)
             continue;
-        
+
         engine.mapSectionAddress((void*)record.m_host_address, record.m_process_address);
     }
-    
+
     // Trigger re-application of relocations.
     engine.finalizeObject();
 }
@@ -863,12 +859,12 @@ IRExecutionUnit::WriteData (lldb::Proces
     return wrote_something;
 }
 
-void 
+void
 IRExecutionUnit::AllocationRecord::dump (Log *log)
 {
     if (!log)
         return;
-    
+
     log->Printf("[0x%llx+0x%llx]->0x%llx (alignment %d, section ID %d)",
                 (unsigned long long)m_host_address,
                 (unsigned long long)m_size,

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Sun Jul  6 12:54:58 2014
@@ -59,7 +59,7 @@ IRForTarget::FunctionValueCache::~Functi
 }
 
 llvm::Value *IRForTarget::FunctionValueCache::GetValue(llvm::Function *function)
-{    
+{
     if (!m_values.count(function))
     {
         llvm::Value *ret = m_maker(function);
@@ -72,13 +72,13 @@ llvm::Value *IRForTarget::FunctionValueC
 lldb::addr_t IRForTarget::StaticDataAllocator::Allocate()
 {
     lldb_private::Error err;
-    
+
     if (m_allocation != LLDB_INVALID_ADDRESS)
     {
         m_execution_unit.FreeNow(m_allocation);
         m_allocation = LLDB_INVALID_ADDRESS;
     }
-    
+
     m_allocation = m_execution_unit.WriteNow((const uint8_t*)m_stream_string.GetData(), m_stream_string.GetSize(), err);
 
     return m_allocation;
@@ -88,7 +88,7 @@ static llvm::Value *FindEntryInstruction
 {
     if (function->empty())
         return NULL;
-    
+
     return function->getEntryBlock().getFirstNonPHIOrDbg();
 }
 
@@ -116,7 +116,7 @@ IRForTarget::IRForTarget (lldb_private::
 
 /* Handy utility functions used at several places in the code */
 
-static std::string 
+static std::string
 PrintValue(const Value *value, bool truncate = false)
 {
     std::string s;
@@ -151,9 +151,9 @@ bool
 IRForTarget::FixFunctionLinkage(llvm::Function &llvm_function)
 {
     llvm_function.setLinkage(GlobalValue::ExternalLinkage);
-    
+
     std::string name = llvm_function.getName().str();
-    
+
     return true;
 }
 
@@ -164,24 +164,24 @@ IRForTarget::GetFunctionAddress (llvm::F
                                  Constant **&value_ptr)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     fun_addr = LLDB_INVALID_ADDRESS;
     name.Clear();
     value_ptr = NULL;
-    
+
     if (fun->isIntrinsic())
     {
         Intrinsic::ID intrinsic_id = (Intrinsic::ID)fun->getIntrinsicID();
-        
+
         switch (intrinsic_id)
         {
         default:
             if (log)
                 log->Printf("Unresolved intrinsic \"%s\"", Intrinsic::getName(intrinsic_id).c_str());
-                
+
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Call to unhandled compiler intrinsic '%s'\n", Intrinsic::getName(intrinsic_id).c_str());
-            
+
                 return LookupResult::Fail;
         case Intrinsic::memcpy:
             {
@@ -199,7 +199,7 @@ IRForTarget::GetFunctionAddress (llvm::F
         case Intrinsic::dbg_value:
             return LookupResult::Ignore;
         }
-        
+
         if (log && name)
             log->Printf("Resolved intrinsic name \"%s\"", name.GetCString());
     }
@@ -207,14 +207,14 @@ IRForTarget::GetFunctionAddress (llvm::F
     {
         name.SetCStringWithLength (fun->getName().data(), fun->getName().size());
     }
-    
+
     // Find the address of the function.
-    
+
     clang::NamedDecl *fun_decl = DeclForGlobal (fun);
-    
+
     if (fun_decl)
     {
-        if (!m_decl_map->GetFunctionInfo (fun_decl, fun_addr)) 
+        if (!m_decl_map->GetFunctionInfo (fun_decl, fun_addr))
         {
             lldb_private::ConstString altnernate_name;
             bool found_it = m_decl_map->GetFunctionAddress (name, fun_addr);
@@ -231,7 +231,7 @@ IRForTarget::GetFunctionAddress (llvm::F
                     found_it = m_decl_map->GetFunctionAddress (altnernate_name, fun_addr);
                 }
             }
-            
+
             if (!found_it)
             {
                 lldb_private::Mangled mangled_name(name);
@@ -246,7 +246,7 @@ IRForTarget::GetFunctionAddress (llvm::F
                         log->Printf("Function \"%s\" had no address",
                                     mangled_name.GetName().GetCString());
                 }
-                
+
                 if (m_error_stream)
                 {
                     if (alt_mangled_name)
@@ -265,23 +265,23 @@ IRForTarget::GetFunctionAddress (llvm::F
             }
         }
     }
-    else 
+    else
     {
         if (!m_decl_map->GetFunctionAddress (name, fun_addr))
         {
             if (log)
                 log->Printf ("Metadataless function \"%s\" had no address", name.GetCString());
-            
+
             if (m_error_stream)
                 m_error_stream->Printf("Error [IRForTarget]: Call to a symbol-only function '%s' that is not present in the target\n", name.GetCString());
-            
+
             return LookupResult::Fail;
         }
     }
-    
+
     if (log)
         log->Printf("Found \"%s\" at 0x%" PRIx64, name.GetCString(), fun_addr);
-    
+
     return LookupResult::Success;
 }
 
@@ -296,7 +296,7 @@ IRForTarget::BuildFunctionPointer (llvm:
 
 void
 IRForTarget::RegisterFunctionMetadata(LLVMContext &context,
-                                      llvm::Value *function_ptr, 
+                                      llvm::Value *function_ptr,
                                       const char *name)
 {
     for (llvm::User *user : function_ptr->users())
@@ -316,51 +316,51 @@ IRForTarget::RegisterFunctionMetadata(LL
     }
 }
 
-bool 
+bool
 IRForTarget::ResolveFunctionPointers(llvm::Module &llvm_module)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     for (llvm::Module::iterator fi = llvm_module.begin();
          fi != llvm_module.end();
          ++fi)
     {
         Function *fun = fi;
-        
+
         bool is_decl = fun->isDeclaration();
-        
+
         if (log)
             log->Printf("Examining %s function %s", (is_decl ? "declaration" : "non-declaration"), fun->getName().str().c_str());
-        
+
         if (!is_decl)
             continue;
-        
+
         if (fun->use_empty())
             continue; // ignore
-        
+
         uint64_t addr = LLDB_INVALID_ADDRESS;
         lldb_private::ConstString name;
         Constant **value_ptr = NULL;
-        
+
         LookupResult result = GetFunctionAddress(fun,
                                                  addr,
                                                  name,
                                                  value_ptr);
-        
+
         switch (result)
         {
         case LookupResult::Fail:
             return false; // GetFunctionAddress reports its own errors
-                
+
         case LookupResult::Ignore:
             break; // Nothing to do
-                
+
         case LookupResult::Success:
             {
                 Constant *value = BuildFunctionPointer(fun->getFunctionType(), addr);
-                
+
                 RegisterFunctionMetadata (llvm_module.getContext(), fun, name.AsCString());
-                
+
                 if (value_ptr)
                     *value_ptr = value;
 
@@ -377,13 +377,13 @@ IRForTarget::ResolveFunctionPointers(llv
                         }
                     }
                 }
-                
+
                 fun->replaceAllUsesWith(value);
             }
             break;
         }
     }
-    
+
     return true;
 }
 
@@ -392,69 +392,69 @@ clang::NamedDecl *
 IRForTarget::DeclForGlobal (const GlobalValue *global_val, Module *module)
 {
     NamedMDNode *named_metadata = module->getNamedMetadata("clang.global.decl.ptrs");
-    
+
     if (!named_metadata)
         return NULL;
-    
+
     unsigned num_nodes = named_metadata->getNumOperands();
     unsigned node_index;
-    
+
     for (node_index = 0;
          node_index < num_nodes;
          ++node_index)
     {
         MDNode *metadata_node = named_metadata->getOperand(node_index);
-        
+
         if (!metadata_node)
             return NULL;
-        
+
         if (metadata_node->getNumOperands() != 2)
             continue;
-        
+
         if (metadata_node->getOperand(0) != global_val)
             continue;
-        
+
         ConstantInt *constant_int = dyn_cast<ConstantInt>(metadata_node->getOperand(1));
-        
+
         if (!constant_int)
             return NULL;
-        
+
         uintptr_t ptr = constant_int->getZExtValue();
-        
+
         return reinterpret_cast<clang::NamedDecl *>(ptr);
     }
-    
+
     return NULL;
 }
 
 clang::NamedDecl *
 IRForTarget::DeclForGlobal (GlobalValue *global_val)
-{        
+{
     return DeclForGlobal(global_val, m_module);
 }
 
-bool 
+bool
 IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     if (!m_resolve_vars)
         return true;
-    
+
     // Find the result variable.  If it doesn't exist, we can give up right here.
-    
+
     ValueSymbolTable& value_symbol_table = m_module->getValueSymbolTable();
-    
+
     std::string result_name_str;
     const char *result_name = NULL;
-    
+
     for (ValueSymbolTable::iterator vi = value_symbol_table.begin(), ve = value_symbol_table.end();
          vi != ve;
          ++vi)
     {
         result_name_str = vi->first().str();
         const char *value_name = result_name_str.c_str();
-        
+
         if (strstr(value_name, "$__lldb_expr_result_ptr") &&
             strncmp(value_name, "_ZGV", 4))
         {
@@ -462,7 +462,7 @@ IRForTarget::CreateResultVariable (llvm:
             m_result_is_pointer = true;
             break;
         }
-        
+
         if (strstr(value_name, "$__lldb_expr_result") &&
             strncmp(value_name, "_ZGV", 4))
         {
@@ -471,105 +471,105 @@ IRForTarget::CreateResultVariable (llvm:
             break;
         }
     }
-    
+
     if (!result_name)
     {
         if (log)
             log->PutCString("Couldn't find result variable");
-        
+
         return true;
     }
-    
+
     if (log)
         log->Printf("Result name: \"%s\"", result_name);
-    
+
     Value *result_value = m_module->getNamedValue(result_name);
-    
+
     if (!result_value)
     {
         if (log)
             log->PutCString("Result variable had no data");
-        
+
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Result variable's name (%s) exists, but not its definition\n", result_name);
-        
+
         return false;
     }
-        
+
     if (log)
         log->Printf("Found result in the IR: \"%s\"", PrintValue(result_value, false).c_str());
-    
+
     GlobalVariable *result_global = dyn_cast<GlobalVariable>(result_value);
-    
+
     if (!result_global)
     {
         if (log)
             log->PutCString("Result variable isn't a GlobalVariable");
-        
+
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Result variable (%s) is defined, but is not a global variable\n", result_name);
-        
+
         return false;
     }
-    
+
     clang::NamedDecl *result_decl = DeclForGlobal (result_global);
     if (!result_decl)
     {
         if (log)
             log->PutCString("Result variable doesn't have a corresponding Decl");
-        
+
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Result variable (%s) does not have a corresponding Clang entity\n", result_name);
-        
+
         return false;
     }
-    
+
     if (log)
     {
         std::string decl_desc_str;
         raw_string_ostream decl_desc_stream(decl_desc_str);
         result_decl->print(decl_desc_stream);
         decl_desc_stream.flush();
-        
+
         log->Printf("Found result decl: \"%s\"", decl_desc_str.c_str());
     }
-    
+
     clang::VarDecl *result_var = dyn_cast<clang::VarDecl>(result_decl);
     if (!result_var)
     {
         if (log)
             log->PutCString("Result variable Decl isn't a VarDecl");
-        
+
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Result variable (%s)'s corresponding Clang entity isn't a variable\n", result_name);
-        
+
         return false;
     }
-    
+
     // Get the next available result name from m_decl_map and create the persistent
     // variable for it
-        
+
     // If the result is an Lvalue, it is emitted as a pointer; see
     // ASTResultSynthesizer::SynthesizeBodyResult.
     if (m_result_is_pointer)
     {
         clang::QualType pointer_qual_type = result_var->getType();
         const clang::Type *pointer_type = pointer_qual_type.getTypePtr();
-        
+
         const clang::PointerType *pointer_pointertype = pointer_type->getAs<clang::PointerType>();
         const clang::ObjCObjectPointerType *pointer_objcobjpointertype = pointer_type->getAs<clang::ObjCObjectPointerType>();
-        
+
         if (pointer_pointertype)
         {
             clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
-            
+
             m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
                                                          &result_decl->getASTContext());
         }
         else if (pointer_objcobjpointertype)
         {
             clang::QualType element_qual_type = clang::QualType(pointer_objcobjpointertype->getObjectType(), 0);
-            
+
             m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
                                                          &result_decl->getASTContext());
         }
@@ -577,10 +577,10 @@ IRForTarget::CreateResultVariable (llvm:
         {
             if (log)
                 log->PutCString("Expected result to have pointer type, but it did not");
-            
+
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Lvalue result (%s) is not a pointer variable\n", result_name);
-            
+
             return false;
         }
     }
@@ -589,99 +589,99 @@ IRForTarget::CreateResultVariable (llvm:
         m_result_type = lldb_private::TypeFromParser(result_var->getType().getAsOpaquePtr(),
                                                      &result_decl->getASTContext());
     }
-    
+
     if (m_result_type.GetBitSize() == 0)
     {
         lldb_private::StreamString type_desc_stream;
         m_result_type.DumpTypeDescription(&type_desc_stream);
-        
+
         if (log)
             log->Printf("Result type has size 0");
-        
+
         if (m_error_stream)
-            m_error_stream->Printf("Error [IRForTarget]: Size of result type '%s' couldn't be determined\n", 
+            m_error_stream->Printf("Error [IRForTarget]: Size of result type '%s' couldn't be determined\n",
                                    type_desc_stream.GetData());
         return false;
     }
-    
+
     if (log)
     {
         lldb_private::StreamString type_desc_stream;
         m_result_type.DumpTypeDescription(&type_desc_stream);
-        
+
         log->Printf("Result decl type: \"%s\"", type_desc_stream.GetData());
     }
-    
+
     m_result_name = lldb_private::ConstString("$RESULT_NAME");
-    
+
     if (log)
         log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
                     m_result_name.GetCString(),
                     m_result_type.GetByteSize());
-        
+
     // Construct a new result global and set up its metadata
-    
-    GlobalVariable *new_result_global = new GlobalVariable((*m_module), 
+
+    GlobalVariable *new_result_global = new GlobalVariable((*m_module),
                                                            result_global->getType()->getElementType(),
                                                            false, /* not constant */
                                                            GlobalValue::ExternalLinkage,
                                                            NULL, /* no initializer */
                                                            m_result_name.GetCString ());
-    
+
     // It's too late in compilation to create a new VarDecl for this, but we don't
     // need to.  We point the metadata at the old VarDecl.  This creates an odd
     // anomaly: a variable with a Value whose name is something like $0 and a
     // Decl whose name is $__lldb_expr_result.  This condition is handled in
     // ClangExpressionDeclMap::DoMaterialize, and the name of the variable is
     // fixed up.
-    
+
     ConstantInt *new_constant_int = ConstantInt::get(llvm::Type::getInt64Ty(m_module->getContext()),
                                                      reinterpret_cast<uint64_t>(result_decl),
                                                      false);
-    
+
     llvm::Value* values[2];
     values[0] = new_result_global;
     values[1] = new_constant_int;
-    
+
     ArrayRef<Value*> value_ref(values, 2);
-    
+
     MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref);
     NamedMDNode *named_metadata = m_module->getNamedMetadata("clang.global.decl.ptrs");
     named_metadata->addOperand(persistent_global_md);
-    
+
     if (log)
         log->Printf("Replacing \"%s\" with \"%s\"",
                     PrintValue(result_global).c_str(),
                     PrintValue(new_result_global).c_str());
-    
+
     if (result_global->use_empty())
     {
         // We need to synthesize a store for this variable, because otherwise
         // there's nothing to put into its equivalent persistent variable.
-        
+
         BasicBlock &entry_block(llvm_function.getEntryBlock());
         Instruction *first_entry_instruction(entry_block.getFirstNonPHIOrDbg());
-        
+
         if (!first_entry_instruction)
             return false;
-        
+
         if (!result_global->hasInitializer())
         {
             if (log)
                 log->Printf("Couldn't find initializer for unused variable");
-            
+
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Result variable (%s) has no writes and no initializer\n", result_name);
-            
+
             return false;
         }
-        
+
         Constant *initializer = result_global->getInitializer();
-        
+
         StoreInst *synthesized_store = new StoreInst(initializer,
                                                      new_result_global,
                                                      first_entry_instruction);
-        
+
         if (log)
             log->Printf("Synthesized result store \"%s\"\n", PrintValue(synthesized_store).c_str());
     }
@@ -689,16 +689,16 @@ IRForTarget::CreateResultVariable (llvm:
     {
         result_global->replaceAllUsesWith(new_result_global);
     }
-        
+
     if (!m_decl_map->AddPersistentVariable(result_decl,
-                                           m_result_name, 
+                                           m_result_name,
                                            m_result_type,
                                            true,
                                            m_result_is_pointer))
         return false;
-    
+
     result_global->eraseFromParent();
-    
+
     return true;
 }
 
@@ -707,33 +707,33 @@ IRForTarget::RewriteObjCConstString (llv
                                      llvm::GlobalVariable *cstr)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     Type *ns_str_ty = ns_str->getType();
-    
+
     Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext());
     Type *i32_ty = Type::getInt32Ty(m_module->getContext());
     Type *i8_ty = Type::getInt8Ty(m_module->getContext());
-    
+
     if (!m_CFStringCreateWithBytes)
     {
         lldb::addr_t CFStringCreateWithBytes_addr;
-        
+
         static lldb_private::ConstString g_CFStringCreateWithBytes_str ("CFStringCreateWithBytes");
-        
+
         if (!m_decl_map->GetFunctionAddress (g_CFStringCreateWithBytes_str, CFStringCreateWithBytes_addr))
         {
             if (log)
                 log->PutCString("Couldn't find CFStringCreateWithBytes in the target");
-            
+
             if (m_error_stream)
                 m_error_stream->Printf("Error [IRForTarget]: Rewriting an Objective-C constant string requires CFStringCreateWithBytes\n");
-            
+
             return false;
         }
-            
+
         if (log)
             log->Printf("Found CFStringCreateWithBytes at 0x%" PRIx64, CFStringCreateWithBytes_addr);
-        
+
         // Build the function type:
         //
         // CFStringRef CFStringCreateWithBytes (
@@ -752,66 +752,66 @@ IRForTarget::RewriteObjCConstString (llv
         // CFIndex -> long (i32 or i64, as appropriate; we ask the module for its pointer size for now)
         // CFStringEncoding -> i32
         // Boolean -> i8
-        
+
         Type *arg_type_array[5];
-        
+
         arg_type_array[0] = i8_ptr_ty;
         arg_type_array[1] = i8_ptr_ty;
         arg_type_array[2] = m_intptr_ty;
         arg_type_array[3] = i32_ty;
         arg_type_array[4] = i8_ty;
-        
+
         ArrayRef<Type *> CFSCWB_arg_types(arg_type_array, 5);
-        
+
         llvm::Type *CFSCWB_ty = FunctionType::get(ns_str_ty, CFSCWB_arg_types, false);
-        
+
         // Build the constant containing the pointer to the function
         PointerType *CFSCWB_ptr_ty = PointerType::getUnqual(CFSCWB_ty);
         Constant *CFSCWB_addr_int = ConstantInt::get(m_intptr_ty, CFStringCreateWithBytes_addr, false);
         m_CFStringCreateWithBytes = ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty);
     }
-    
+
     ConstantDataSequential *string_array = NULL;
-    
+
     if (cstr)
         string_array = dyn_cast<ConstantDataSequential>(cstr->getInitializer());
-                            
+
     Constant *alloc_arg         = Constant::getNullValue(i8_ptr_ty);
     Constant *bytes_arg         = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty) : Constant::getNullValue(i8_ptr_ty);
     Constant *numBytes_arg      = ConstantInt::get(m_intptr_ty, cstr ? string_array->getNumElements() - 1 : 0, false);
     Constant *encoding_arg      = ConstantInt::get(i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */
     Constant *isExternal_arg    = ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
-    
+
     Value *argument_array[5];
-    
+
     argument_array[0] = alloc_arg;
     argument_array[1] = bytes_arg;
     argument_array[2] = numBytes_arg;
     argument_array[3] = encoding_arg;
     argument_array[4] = isExternal_arg;
-    
+
     ArrayRef <Value *> CFSCWB_arguments(argument_array, 5);
-    
+
     FunctionValueCache CFSCWB_Caller ([this, &CFSCWB_arguments] (llvm::Function *function)->llvm::Value * {
         return CallInst::Create(m_CFStringCreateWithBytes,
                                 CFSCWB_arguments,
                                 "CFStringCreateWithBytes",
                                 llvm::cast<Instruction>(m_entry_instruction_finder.GetValue(function)));
     });
-            
+
     if (!UnfoldConstant(ns_str, CFSCWB_Caller, m_entry_instruction_finder))
     {
         if (log)
             log->PutCString("Couldn't replace the NSString with the result of the call");
-        
+
         if (m_error_stream)
             m_error_stream->Printf("Error [IRForTarget]: Couldn't replace an Objective-C constant string with a dynamic string\n");
-        
+
         return false;
     }
-    
+
     ns_str->eraseFromParent();
-    
+
     return true;
 }
 
@@ -819,57 +819,57 @@ bool
 IRForTarget::RewriteObjCConstStrings()
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     ValueSymbolTable& value_symbol_table = m_module->getValueSymbolTable();
-    
+
     for (ValueSymbolTable::iterator vi = value_symbol_table.begin(), ve = value_symbol_table.end();
          vi != ve;
          ++vi)
     {
         std::string value_name = vi->first().str();
         const char *value_name_cstr = value_name.c_str();
-        
+
         if (strstr(value_name_cstr, "_unnamed_cfstring_"))
         {
             Value *nsstring_value = vi->second;
-            
+
             GlobalVariable *nsstring_global = dyn_cast<GlobalVariable>(nsstring_value);
-            
+
             if (!nsstring_global)
             {
                 if (log)
                     log->PutCString("NSString variable is not a GlobalVariable");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string is not a global variable\n");
-                
+
                 return false;
             }
-            
+
             if (!nsstring_global->hasInitializer())
             {
                 if (log)
                     log->PutCString("NSString variable does not have an initializer");
-            
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string does not have an initializer\n");
-                
+
                 return false;
             }
-            
+
             ConstantStruct *nsstring_struct = dyn_cast<ConstantStruct>(nsstring_global->getInitializer());
-            
+
             if (!nsstring_struct)
             {
                 if (log)
                     log->PutCString("NSString variable's initializer is not a ConstantStruct");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string is not a structure constant\n");
-                
+
                 return false;
             }
-            
+
             // We expect the following structure:
             //
             // struct {
@@ -878,107 +878,107 @@ IRForTarget::RewriteObjCConstStrings()
             //   char *str;
             //   long length;
             // };
-            
+
             if (nsstring_struct->getNumOperands() != 4)
             {
                 if (log)
                     log->Printf("NSString variable's initializer structure has an unexpected number of members.  Should be 4, is %d", nsstring_struct->getNumOperands());
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: The struct for an Objective-C constant string is not as expected\n");
-                
+
                 return false;
             }
-            
+
             Constant *nsstring_member = nsstring_struct->getOperand(2);
-            
+
             if (!nsstring_member)
             {
                 if (log)
                     log->PutCString("NSString initializer's str element was empty");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string does not have a string initializer\n");
-                
+
                 return false;
             }
-            
+
             ConstantExpr *nsstring_expr = dyn_cast<ConstantExpr>(nsstring_member);
-            
+
             if (!nsstring_expr)
             {
                 if (log)
                     log->PutCString("NSString initializer's str element is not a ConstantExpr");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string's string initializer is not constant\n");
-                
+
                 return false;
             }
-            
+
             if (nsstring_expr->getOpcode() != Instruction::GetElementPtr)
             {
                 if (log)
                     log->Printf("NSString initializer's str element is not a GetElementPtr expression, it's a %s", nsstring_expr->getOpcodeName());
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string's string initializer is not an array\n");
-                
+
                 return false;
             }
-            
+
             Constant *nsstring_cstr = nsstring_expr->getOperand(0);
-            
+
             GlobalVariable *cstr_global = dyn_cast<GlobalVariable>(nsstring_cstr);
-            
+
             if (!cstr_global)
             {
                 if (log)
                     log->PutCString("NSString initializer's str element is not a GlobalVariable");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string's string initializer doesn't point to a global\n");
-                    
+
                 return false;
             }
-            
+
             if (!cstr_global->hasInitializer())
             {
                 if (log)
                     log->PutCString("NSString initializer's str element does not have an initializer");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string's string initializer doesn't point to initialized data\n");
-                
+
                 return false;
             }
-                        
+
             /*
             if (!cstr_array)
             {
                 if (log)
                     log->PutCString("NSString initializer's str element is not a ConstantArray");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string's string initializer doesn't point to an array\n");
-                
+
                 return false;
             }
-            
+
             if (!cstr_array->isCString())
             {
                 if (log)
                     log->PutCString("NSString initializer's str element is not a C string array");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: An Objective-C constant string's string initializer doesn't point to a C string\n");
-                
+
                 return false;
             }
             */
-            
+
             ConstantDataArray *cstr_array = dyn_cast<ConstantDataArray>(cstr_global->getInitializer());
-            
+
             if (log)
             {
                 if (cstr_array)
@@ -986,175 +986,175 @@ IRForTarget::RewriteObjCConstStrings()
                 else
                     log->Printf("Found NSString constant %s, which contains \"\"", value_name_cstr);
             }
-            
+
             if (!cstr_array)
                 cstr_global = NULL;
-            
+
             if (!RewriteObjCConstString(nsstring_global, cstr_global))
-            {                
+            {
                 if (log)
                     log->PutCString("Error rewriting the constant string");
-                
+
                 // We don't print an error message here because RewriteObjCConstString has done so for us.
-                
+
                 return false;
             }
         }
     }
-    
+
     for (ValueSymbolTable::iterator vi = value_symbol_table.begin(), ve = value_symbol_table.end();
          vi != ve;
          ++vi)
     {
         std::string value_name = vi->first().str();
         const char *value_name_cstr = value_name.c_str();
-        
+
         if (!strcmp(value_name_cstr, "__CFConstantStringClassReference"))
         {
             GlobalVariable *gv = dyn_cast<GlobalVariable>(vi->second);
-            
+
             if (!gv)
             {
                 if (log)
                     log->PutCString("__CFConstantStringClassReference is not a global variable");
-                
+
                 if (m_error_stream)
                     m_error_stream->Printf("Internal error [IRForTarget]: Found a CFConstantStringClassReference, but it is not a global object\n");
-                
+
                 return false;
             }
-                
+
             gv->eraseFromParent();
-                
+
             break;
         }
     }
-    
+
     return true;
 }
 
 static bool IsObjCSelectorRef (Value *value)
 {
     GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value);
-    
+
     if (!global_variable || !global_variable->hasName() || !global_variable->getName().startswith("\01L_OBJC_SELECTOR_REFERENCES_"))
         return false;
-    
+
     return true;
 }
 
 // This function does not report errors; its callers are responsible.
-bool 
+bool
 IRForTarget::RewriteObjCSelector (Instruction* selector_load)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     LoadInst *load = dyn_cast<LoadInst>(selector_load);
-    
+
     if (!load)
         return false;
-    
+
     // Unpack the message name from the selector.  In LLVM IR, an objc_msgSend gets represented as
     //
     // %tmp     = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_" ; <i8*>
     // %call    = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %obj, i8* %tmp, ...) ; <i8*>
     //
     // where %obj is the object pointer and %tmp is the selector.
-    // 
+    //
     // @"\01L_OBJC_SELECTOR_REFERENCES_" is a pointer to a character array called @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_".
     // @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_" contains the string.
-    
+
     // Find the pointer's initializer (a ConstantExpr with opcode GetElementPtr) and get the string from its target
-    
+
     GlobalVariable *_objc_selector_references_ = dyn_cast<GlobalVariable>(load->getPointerOperand());
-    
+
     if (!_objc_selector_references_ || !_objc_selector_references_->hasInitializer())
         return false;
-    
+
     Constant *osr_initializer = _objc_selector_references_->getInitializer();
-    
+
     ConstantExpr *osr_initializer_expr = dyn_cast<ConstantExpr>(osr_initializer);
-    
+
     if (!osr_initializer_expr || osr_initializer_expr->getOpcode() != Instruction::GetElementPtr)
         return false;
-    
+
     Value *osr_initializer_base = osr_initializer_expr->getOperand(0);
 
     if (!osr_initializer_base)
         return false;
-    
+
     // Find the string's initializer (a ConstantArray) and get the string from it
-    
+
     GlobalVariable *_objc_meth_var_name_ = dyn_cast<GlobalVariable>(osr_initializer_base);
-    
+
     if (!_objc_meth_var_name_ || !_objc_meth_var_name_->hasInitializer())
         return false;
-    
+
     Constant *omvn_initializer = _objc_meth_var_name_->getInitializer();
 
     ConstantDataArray *omvn_initializer_array = dyn_cast<ConstantDataArray>(omvn_initializer);
-    
+
     if (!omvn_initializer_array->isString())
         return false;
-    
+
     std::string omvn_initializer_string = omvn_initializer_array->getAsString();
-    
+
     if (log)
         log->Printf("Found Objective-C selector reference \"%s\"", omvn_initializer_string.c_str());
-    
+
     // Construct a call to sel_registerName
-    
+
     if (!m_sel_registerName)
     {
         lldb::addr_t sel_registerName_addr;
-        
+
         static lldb_private::ConstString g_sel_registerName_str ("sel_registerName");
         if (!m_decl_map->GetFunctionAddress (g_sel_registerName_str, sel_registerName_addr))
             return false;
-        
+
         if (log)
             log->Printf("Found sel_registerName at 0x%" PRIx64, sel_registerName_addr);
-        
+
         // Build the function type: struct objc_selector *sel_registerName(uint8_t*)
-        
+
         // The below code would be "more correct," but in actuality what's required is uint8_t*
         //Type *sel_type = StructType::get(m_module->getContext());
         //Type *sel_ptr_type = PointerType::getUnqual(sel_type);
         Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext());
-        
+
         Type *type_array[1];
-        
+
         type_array[0] = llvm::Type::getInt8PtrTy(m_module->getContext());
-        
+
         ArrayRef<Type *> srN_arg_types(type_array, 1);
-        
+
         llvm::Type *srN_type = FunctionType::get(sel_ptr_type, srN_arg_types, false);
-        
+
         // Build the constant containing the pointer to the function
         PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type);
         Constant *srN_addr_int = ConstantInt::get(m_intptr_ty, sel_registerName_addr, false);
         m_sel_registerName = ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty);
     }
-    
+
     Value *argument_array[1];
-        
+
     Constant *omvn_pointer = ConstantExpr::getBitCast(_objc_meth_var_name_, Type::getInt8PtrTy(m_module->getContext()));
-    
+
     argument_array[0] = omvn_pointer;
-    
+
     ArrayRef<Value *> srN_arguments(argument_array, 1);
-        
-    CallInst *srN_call = CallInst::Create(m_sel_registerName, 
+
+    CallInst *srN_call = CallInst::Create(m_sel_registerName,
                                           srN_arguments,
                                           "sel_registerName",
                                           selector_load);
-    
+
     // Replace the load with the call in all users
-    
+
     selector_load->replaceAllUsesWith(srN_call);
-    
+
     selector_load->eraseFromParent();
-    
+
     return true;
 }
 
@@ -1164,25 +1164,25 @@ IRForTarget::RewriteObjCSelectors (Basic
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     BasicBlock::iterator ii;
-    
+
     typedef SmallVector <Instruction*, 2> InstrList;
     typedef InstrList::iterator InstrIterator;
-    
+
     InstrList selector_loads;
-    
+
     for (ii = basic_block.begin();
          ii != basic_block.end();
          ++ii)
     {
         Instruction &inst = *ii;
-        
+
         if (LoadInst *load = dyn_cast<LoadInst>(&inst))
             if (IsObjCSelectorRef(load->getPointerOperand()))
                 selector_loads.push_back(&inst);
     }
-    
+
     InstrIterator iter;
-    
+
     for (iter = selector_loads.begin();
          iter != selector_loads.end();
          ++iter)
@@ -1191,111 +1191,111 @@ IRForTarget::RewriteObjCSelectors (Basic
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Couldn't change a static reference to an Objective-C selector to a dynamic reference\n");
-            
+
             if (log)
                 log->PutCString("Couldn't rewrite a reference to an Objective-C selector");
-            
+
             return false;
         }
     }
-        
+
     return true;
 }
 
 // This function does not report errors; its callers are responsible.
-bool 
+bool
 IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     AllocaInst *alloc = dyn_cast<AllocaInst>(persistent_alloc);
-    
+
     MDNode *alloc_md = alloc->getMetadata("clang.decl.ptr");
 
     if (!alloc_md || !alloc_md->getNumOperands())
         return false;
-    
+
     ConstantInt *constant_int = dyn_cast<ConstantInt>(alloc_md->getOperand(0));
-    
+
     if (!constant_int)
         return false;
-    
+
     // We attempt to register this as a new persistent variable with the DeclMap.
-    
+
     uintptr_t ptr = constant_int->getZExtValue();
-    
+
     clang::VarDecl *decl = reinterpret_cast<clang::VarDecl *>(ptr);
-    
+
     lldb_private::TypeFromParser result_decl_type (decl->getType().getAsOpaquePtr(),
                                                    &decl->getASTContext());
-    
+
     StringRef decl_name (decl->getName());
     lldb_private::ConstString persistent_variable_name (decl_name.data(), decl_name.size());
     if (!m_decl_map->AddPersistentVariable(decl, persistent_variable_name, result_decl_type, false, false))
         return false;
-    
+
     GlobalVariable *persistent_global = new GlobalVariable((*m_module),
                                                            alloc->getType(),
                                                            false, /* not constant */
                                                            GlobalValue::ExternalLinkage,
                                                            NULL, /* no initializer */
                                                            alloc->getName().str().c_str());
-    
+
     // What we're going to do here is make believe this was a regular old external
     // variable.  That means we need to make the metadata valid.
-    
+
     NamedMDNode *named_metadata = m_module->getOrInsertNamedMetadata("clang.global.decl.ptrs");
-    
+
     llvm::Value* values[2];
     values[0] = persistent_global;
     values[1] = constant_int;
-    
+
     ArrayRef<llvm::Value*> value_ref(values, 2);
 
     MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref);
     named_metadata->addOperand(persistent_global_md);
-    
+
     // Now, since the variable is a pointer variable, we will drop in a load of that
     // pointer variable.
-    
+
     LoadInst *persistent_load = new LoadInst (persistent_global, "", alloc);
-    
+
     if (log)
         log->Printf("Replacing \"%s\" with \"%s\"",
                     PrintValue(alloc).c_str(),
                     PrintValue(persistent_load).c_str());
-    
+
     alloc->replaceAllUsesWith(persistent_load);
     alloc->eraseFromParent();
-    
+
     return true;
 }
 
-bool 
+bool
 IRForTarget::RewritePersistentAllocs(llvm::BasicBlock &basic_block)
 {
     if (!m_resolve_vars)
         return true;
-    
+
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     BasicBlock::iterator ii;
-    
+
     typedef SmallVector <Instruction*, 2> InstrList;
     typedef InstrList::iterator InstrIterator;
-    
+
     InstrList pvar_allocs;
-    
+
     for (ii = basic_block.begin();
          ii != basic_block.end();
          ++ii)
     {
         Instruction &inst = *ii;
-        
+
         if (AllocaInst *alloc = dyn_cast<AllocaInst>(&inst))
         {
             llvm::StringRef alloc_name = alloc->getName();
-            
+
             if (alloc_name.startswith("$") &&
                 !alloc_name.startswith("$__lldb"))
             {
@@ -1303,20 +1303,20 @@ IRForTarget::RewritePersistentAllocs(llv
                 {
                     if (log)
                         log->Printf("Rejecting a numeric persistent variable.");
-                    
+
                     if (m_error_stream)
                         m_error_stream->Printf("Error [IRForTarget]: Names starting with $0, $1, ... are reserved for use as result names\n");
-                    
+
                     return false;
                 }
-                
+
                 pvar_allocs.push_back(alloc);
             }
         }
     }
-    
+
     InstrIterator iter;
-    
+
     for (iter = pvar_allocs.begin();
          iter != pvar_allocs.end();
          ++iter)
@@ -1325,14 +1325,14 @@ IRForTarget::RewritePersistentAllocs(llv
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite the creation of a persistent variable\n");
-            
+
             if (log)
                 log->PutCString("Couldn't rewrite the creation of a persistent variable");
-            
+
             return false;
         }
     }
-    
+
     return true;
 }
 
@@ -1341,14 +1341,14 @@ IRForTarget::MaterializeInitializer (uin
 {
     if (!initializer)
         return true;
-    
+
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     if (log && log->GetVerbose())
         log->Printf("  MaterializeInitializer(%p, %s)", data, PrintValue(initializer).c_str());
-    
+
     Type *initializer_type = initializer->getType();
-    
+
     if (ConstantInt *int_initializer = dyn_cast<ConstantInt>(initializer))
     {
         memcpy (data, int_initializer->getValue().getRawData(), m_target_data->getTypeStoreSize(initializer_type));
@@ -1365,17 +1365,17 @@ IRForTarget::MaterializeInitializer (uin
         {
             ArrayType *array_initializer_type = array_initializer->getType();
             Type *array_element_type = array_initializer_type->getElementType();
-                        
+
             size_t element_size = m_target_data->getTypeAllocSize(array_element_type);
-            
+
             for (unsigned i = 0; i < array_initializer->getNumOperands(); ++i)
             {
                 Value *operand_value = array_initializer->getOperand(i);
                 Constant *operand_constant = dyn_cast<Constant>(operand_value);
-                
+
                 if (!operand_constant)
                     return false;
-                
+
                 if (!MaterializeInitializer(data + (i * element_size), operand_constant))
                     return false;
             }
@@ -1409,52 +1409,52 @@ IRForTarget::MaterializeInternalVariable
 {
     if (GlobalVariable::isExternalLinkage(global_variable->getLinkage()))
         return false;
-    
+
     if (global_variable == m_reloc_placeholder)
         return true;
-    
+
     uint64_t offset = m_data_allocator.GetStream().GetSize();
-    
+
     llvm::Type *variable_type = global_variable->getType();
-    
+
     Constant *initializer = global_variable->getInitializer();
-    
+
     llvm::Type *initializer_type = initializer->getType();
-    
+
     size_t size = m_target_data->getTypeAllocSize(initializer_type);
     size_t align = m_target_data->getPrefTypeAlignment(initializer_type);
-    
+
     const size_t mask = (align - 1);
     uint64_t aligned_offset = (offset + mask) & ~mask;
     m_data_allocator.GetStream().PutNHex8(aligned_offset - offset, 0);
     offset = aligned_offset;
-    
+
     lldb_private::DataBufferHeap data(size, '\0');
-    
+
     if (initializer)
         if (!MaterializeInitializer(data.GetBytes(), initializer))
             return false;
-    
+
     m_data_allocator.GetStream().Write(data.GetBytes(), data.GetByteSize());
-    
+
     Constant *new_pointer = BuildRelocation(variable_type, offset);
-        
+
     global_variable->replaceAllUsesWith(new_pointer);
 
     global_variable->eraseFromParent();
-    
+
     return true;
 }
 
 // This function does not report errors; its callers are responsible.
-bool 
+bool
 IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     if (log)
         log->Printf("MaybeHandleVariable (%s)", PrintValue(llvm_value_ptr).c_str());
-        
+
     if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(llvm_value_ptr))
     {
         switch (constant_expr->getOpcode())
@@ -1472,31 +1472,31 @@ IRForTarget::MaybeHandleVariable (Value
     {
         if (!GlobalValue::isExternalLinkage(global_variable->getLinkage()))
             return MaterializeInternalVariable(global_variable);
-        
+
         clang::NamedDecl *named_decl = DeclForGlobal(global_variable);
-        
+
         if (!named_decl)
         {
             if (IsObjCSelectorRef(llvm_value_ptr))
                 return true;
-            
+
             if (!global_variable->hasExternalLinkage())
                 return true;
-            
+
             if (log)
                 log->Printf("Found global variable \"%s\" without metadata", global_variable->getName().str().c_str());
-            
+
             return false;
         }
-        
+
         std::string name (named_decl->getName().str());
-        
+
         clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl);
         if (value_decl == NULL)
             return false;
 
         lldb_private::ClangASTType clang_type(&value_decl->getASTContext(), value_decl->getType());
-        
+
         const Type *value_type = NULL;
 
         if (name[0] == '$')
@@ -1517,25 +1517,25 @@ IRForTarget::MaybeHandleVariable (Value
         {
             value_type = global_variable->getType();
         }
-        
+
         const uint64_t value_size = clang_type.GetByteSize();
         lldb::offset_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
-        
+
         if (log)
         {
             log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRIu64 "]",
-                        name.c_str(), 
+                        name.c_str(),
                         clang_type.GetQualType().getAsString().c_str(),
                         PrintType(value_type).c_str(),
-                        value_size, 
+                        value_size,
                         value_alignment);
         }
-        
-        
+
+
         if (named_decl && !m_decl_map->AddValueToStruct(named_decl,
                                                         lldb_private::ConstString (name.c_str()),
                                                         llvm_value_ptr,
-                                                        value_size, 
+                                                        value_size,
                                                         value_alignment))
         {
             if (!global_variable->hasExternalLinkage())
@@ -1550,45 +1550,45 @@ IRForTarget::MaybeHandleVariable (Value
     {
         if (log)
             log->Printf("Function pointers aren't handled right now");
-        
+
         return false;
     }
-    
+
     return true;
 }
 
 // This function does not report errors; its callers are responsible.
 bool
 IRForTarget::HandleSymbol (Value *symbol)
-{    
+{
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     lldb_private::ConstString name(symbol->getName().str().c_str());
-    
+
     lldb::addr_t symbol_addr = m_decl_map->GetSymbolAddress (name, lldb::eSymbolTypeAny);
-    
+
     if (symbol_addr == LLDB_INVALID_ADDRESS)
     {
         if (log)
             log->Printf ("Symbol \"%s\" had no address", name.GetCString());
-        
+
         return false;
     }
 
     if (log)
         log->Printf("Found \"%s\" at 0x%" PRIx64, name.GetCString(), symbol_addr);
-    
+
     Type *symbol_type = symbol->getType();
-    
+
     Constant *symbol_addr_int = ConstantInt::get(m_intptr_ty, symbol_addr, false);
-    
+
     Value *symbol_addr_ptr = ConstantExpr::getIntToPtr(symbol_addr_int, symbol_type);
-    
+
     if (log)
         log->Printf("Replacing %s with %s", PrintValue(symbol).c_str(), PrintValue(symbol_addr_ptr).c_str());
-    
+
     symbol->replaceAllUsesWith(symbol_addr_ptr);
-    
+
     return true;
 }
 
@@ -1596,10 +1596,10 @@ bool
 IRForTarget::MaybeHandleCallArguments (CallInst *Old)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     if (log)
         log->Printf("MaybeHandleCallArguments(%s)", PrintValue(Old).c_str());
-    
+
     for (unsigned op_index = 0, num_ops = Old->getNumArgOperands();
          op_index < num_ops;
          ++op_index)
@@ -1607,10 +1607,10 @@ IRForTarget::MaybeHandleCallArguments (C
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite one of the arguments of a function call.\n");
-            
+
             return false;
         }
-            
+
     return true;
 }
 
@@ -1620,53 +1620,53 @@ IRForTarget::HandleObjCClass(Value *clas
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     GlobalVariable *global_variable = dyn_cast<GlobalVariable>(classlist_reference);
-    
+
     if (!global_variable)
         return false;
-    
+
     Constant *initializer = global_variable->getInitializer();
-    
+
     if (!initializer)
         return false;
-    
+
     if (!initializer->hasName())
         return false;
-    
+
     StringRef name(initializer->getName());
     lldb_private::ConstString name_cstr(name.str().c_str());
     lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr, lldb::eSymbolTypeObjCClass);
-    
+
     if (log)
         log->Printf("Found reference to Objective-C class %s (0x%llx)", name_cstr.AsCString(), (unsigned long long)class_ptr);
-    
+
     if (class_ptr == LLDB_INVALID_ADDRESS)
         return false;
-    
+
     if (global_variable->use_empty())
         return false;
-    
+
     SmallVector<LoadInst *, 2> load_instructions;
-        
+
     for (llvm::User *u : global_variable->users())
     {
         if (LoadInst *load_instruction = dyn_cast<LoadInst>(u))
             load_instructions.push_back(load_instruction);
     }
-    
+
     if (load_instructions.empty())
         return false;
-    
+
     Constant *class_addr = ConstantInt::get(m_intptr_ty, (uint64_t)class_ptr);
-    
+
     for (LoadInst *load_instruction : load_instructions)
     {
         Constant *class_bitcast = ConstantExpr::getIntToPtr(class_addr, load_instruction->getType());
-    
+
         load_instruction->replaceAllUsesWith(class_bitcast);
-    
+
         load_instruction->eraseFromParent();
     }
-    
+
     return true;
 }
 
@@ -1674,54 +1674,54 @@ bool
 IRForTarget::RemoveCXAAtExit (BasicBlock &basic_block)
 {
     BasicBlock::iterator ii;
-    
+
     std::vector<CallInst *> calls_to_remove;
-    
+
     for (ii = basic_block.begin();
          ii != basic_block.end();
          ++ii)
     {
         Instruction &inst = *ii;
-        
+
         CallInst *call = dyn_cast<CallInst>(&inst);
-        
+
         // MaybeHandleCallArguments handles error reporting; we are silent here
         if (!call)
             continue;
-        
+
         bool remove = false;
-    
+
         llvm::Function *func = call->getCalledFunction();
-        
+
         if (func && func->getName() == "__cxa_atexit")
             remove = true;
-        
+
         llvm::Value *val = call->getCalledValue();
-        
+
         if (val && val->getName() == "__cxa_atexit")
             remove = true;
-        
+
         if (remove)
             calls_to_remove.push_back(call);
     }
-    
+
     for (std::vector<CallInst *>::iterator ci = calls_to_remove.begin(), ce = calls_to_remove.end();
          ci != ce;
          ++ci)
     {
         (*ci)->eraseFromParent();
     }
-    
+
     return true;
 }
 
 bool
 IRForTarget::ResolveCalls(BasicBlock &basic_block)
-{        
+{
     /////////////////////////////////////////////////////////////////////////
     // Prepare the current basic block for execution in the remote process
     //
-    
+
     BasicBlock::iterator ii;
 
     for (ii = basic_block.begin();
@@ -1729,14 +1729,14 @@ IRForTarget::ResolveCalls(BasicBlock &ba
          ++ii)
     {
         Instruction &inst = *ii;
-        
+
         CallInst *call = dyn_cast<CallInst>(&inst);
-        
+
         // MaybeHandleCallArguments handles error reporting; we are silent here
         if (call && !MaybeHandleCallArguments(call))
             return false;
     }
-    
+
     return true;
 }
 
@@ -1803,36 +1803,36 @@ bool
 IRForTarget::ReplaceStrings ()
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     typedef std::map <GlobalVariable *, size_t> OffsetsTy;
-    
+
     OffsetsTy offsets;
-    
+
     for (GlobalVariable &gv : m_module->globals())
     {
         if (!gv.hasInitializer())
             continue;
-        
+
         Constant *gc = gv.getInitializer();
-        
+
         std::string str;
-        
+
         if (gc->isNullValue())
         {
             Type *gc_type = gc->getType();
-            
+
             ArrayType *gc_array_type = dyn_cast<ArrayType>(gc_type);
-            
+
             if (!gc_array_type)
                 continue;
-            
+
             Type *gc_element_type = gc_array_type->getElementType();
-            
+
             IntegerType *gc_integer_type = dyn_cast<IntegerType>(gc_element_type);
-            
+
             if (gc_integer_type->getBitWidth() != 8)
                 continue;
-            
+
             str = "";
         }
         else
@@ -1841,102 +1841,102 @@ IRForTarget::ReplaceStrings ()
 
             if (!gc_array)
                 continue;
-        
+
             if (!gc_array->isCString())
                 continue;
-        
+
             if (log)
                 log->Printf("Found a GlobalVariable with string initializer %s", PrintValue(gc).c_str());
-        
+
             str = gc_array->getAsString();
         }
-            
+
         offsets[&gv] = m_data_allocator.GetStream().GetSize();
-        
+
         m_data_allocator.GetStream().Write(str.c_str(), str.length() + 1);
     }
-    
+
     Type *char_ptr_ty = Type::getInt8PtrTy(m_module->getContext());
-    
+
     for (OffsetsTy::iterator oi = offsets.begin(), oe = offsets.end();
          oi != oe;
          ++oi)
     {
         GlobalVariable *gv = oi->first;
         size_t offset = oi->second;
-    
+
         Constant *new_initializer = BuildRelocation(char_ptr_ty, offset);
-                
+
         if (log)
             log->Printf("Replacing GV %s with %s", PrintValue(gv).c_str(), PrintValue(new_initializer).c_str());
-        
+
         for (llvm::User *u : gv->users())
         {
             if (log)
                 log->Printf("Found use %s", PrintValue(u).c_str());
-            
+
             ConstantExpr *const_expr = dyn_cast<ConstantExpr>(u);
             StoreInst *store_inst = dyn_cast<StoreInst>(u);
-            
+
             if (const_expr)
             {
                 if (const_expr->getOpcode() != Instruction::GetElementPtr)
                 {
                     if (log)
                         log->Printf("Use (%s) of string variable is not a GetElementPtr constant", PrintValue(const_expr).c_str());
-                    
+
                     return false;
                 }
-                
+
                 Constant *bit_cast = ConstantExpr::getBitCast(new_initializer, const_expr->getOperand(0)->getType());
                 Constant *new_gep = const_expr->getWithOperandReplaced(0, bit_cast);
-                
+
                 const_expr->replaceAllUsesWith(new_gep);
             }
             else if (store_inst)
             {
                 Constant *bit_cast = ConstantExpr::getBitCast(new_initializer, store_inst->getValueOperand()->getType());
-                
+
                 store_inst->setOperand(0, bit_cast);
             }
             else
             {
                 if (log)
                     log->Printf("Use (%s) of string variable is neither a constant nor a store", PrintValue(const_expr).c_str());
-                
+
                 return false;
             }
         }
-                
+
         gv->eraseFromParent();
     }
-    
+
     return true;
 }
 
-bool 
+bool
 IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     typedef SmallVector <Value*, 2> ConstantList;
     typedef SmallVector <llvm::Instruction*, 2> UserList;
     typedef ConstantList::iterator ConstantIterator;
     typedef UserList::iterator UserIterator;
-    
+
     ConstantList static_constants;
     UserList static_users;
-    
+
     for (BasicBlock::iterator ii = basic_block.begin(), ie = basic_block.end();
          ii != ie;
          ++ii)
     {
         llvm::Instruction &inst = *ii;
-        
+
         for (Value *operand_val : inst.operand_values())
         {
             ConstantFP *operand_constant_fp = dyn_cast<ConstantFP>(operand_val);
-            
+
             if (operand_constant_fp/* && operand_constant_fp->getType()->isX86_FP80Ty()*/)
             {
                 static_constants.push_back(operand_val);
@@ -1944,10 +1944,10 @@ IRForTarget::ReplaceStaticLiterals (llvm
             }
         }
     }
-    
+
     ConstantIterator constant_iter;
     UserIterator user_iter;
-        
+
     for (constant_iter = static_constants.begin(), user_iter = static_users.begin();
          constant_iter != static_constants.end();
          ++constant_iter, ++user_iter)
@@ -1956,17 +1956,17 @@ IRForTarget::ReplaceStaticLiterals (llvm
         llvm::Instruction *inst = *user_iter;
 
         ConstantFP *operand_constant_fp = dyn_cast<ConstantFP>(operand_val);
-        
+
         if (operand_constant_fp)
         {
             Type *operand_type = operand_constant_fp->getType();
 
             APFloat operand_apfloat = operand_constant_fp->getValueAPF();
             APInt operand_apint = operand_apfloat.bitcastToAPInt();
-            
+
             const uint8_t* operand_raw_data = (const uint8_t*)operand_apint.getRawData();
             size_t operand_data_size = operand_apint.getBitWidth() / 8;
-            
+
             if (log)
             {
                 std::string s;
@@ -1979,16 +1979,16 @@ IRForTarget::ReplaceStaticLiterals (llvm
                     ss << " ";
                 }
                 ss.flush();
-                
+
                 log->Printf("Found ConstantFP with size %" PRIu64 " and raw data %s", (uint64_t)operand_data_size, s.c_str());
             }
-            
+
             lldb_private::DataBufferHeap data(operand_data_size, 0);
-            
+
             if (lldb::endian::InlHostByteOrder() != m_data_allocator.GetStream().GetByteOrder())
             {
                 uint8_t *data_bytes = data.GetBytes();
-                
+
                 for (size_t index = 0;
                      index < operand_data_size;
                      ++index)
@@ -2000,56 +2000,56 @@ IRForTarget::ReplaceStaticLiterals (llvm
             {
                 memcpy(data.GetBytes(), operand_raw_data, operand_data_size);
             }
-            
+
             uint64_t offset = m_data_allocator.GetStream().GetSize();
-            
+
             size_t align = m_target_data->getPrefTypeAlignment(operand_type);
-            
+
             const size_t mask = (align - 1);
             uint64_t aligned_offset = (offset + mask) & ~mask;
             m_data_allocator.GetStream().PutNHex8(aligned_offset - offset, 0);
-            
+
             m_data_allocator.GetStream().Write(data.GetBytes(), operand_data_size);
-            
+
             llvm::Type *fp_ptr_ty = operand_constant_fp->getType()->getPointerTo();
-            
+
             Constant *new_pointer = BuildRelocation(fp_ptr_ty, aligned_offset);
-            
+
             llvm::LoadInst *fp_load = new llvm::LoadInst(new_pointer, "fp_load", inst);
-            
+
             operand_constant_fp->replaceAllUsesWith(fp_load);
         }
     }
-    
+
     return true;
 }
 
 static bool isGuardVariableRef(Value *V)
 {
     Constant *Old = NULL;
-    
+
     if (!(Old = dyn_cast<Constant>(V)))
         return false;
-    
+
     ConstantExpr *CE = NULL;
-    
+
     if ((CE = dyn_cast<ConstantExpr>(V)))
     {
         if (CE->getOpcode() != Instruction::BitCast)
             return false;
-        
+
         Old = CE->getOperand(0);
     }
-    
+
     GlobalVariable *GV = dyn_cast<GlobalVariable>(Old);
-    
+
     if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV"))
         return false;
-    
+
     return true;
 }
 
-void 
+void
 IRForTarget::TurnGuardLoadIntoZero(llvm::Instruction* guard_load)
 {
     Constant* zero(ConstantInt::get(Type::getInt8Ty(m_module->getContext()), 0, true));
@@ -2065,7 +2065,7 @@ IRForTarget::TurnGuardLoadIntoZero(llvm:
             u->replaceUsesOfWith(guard_load, zero);
         }
     }
-    
+
     guard_load->eraseFromParent();
 }
 
@@ -2076,46 +2076,46 @@ static void ExciseGuardStore(Instruction
 
 bool
 IRForTarget::RemoveGuards(BasicBlock &basic_block)
-{        
+{
     ///////////////////////////////////////////////////////
     // Eliminate any reference to guard variables found.
     //
-    
+
     BasicBlock::iterator ii;
-    
+
     typedef SmallVector <Instruction*, 2> InstrList;
     typedef InstrList::iterator InstrIterator;
-    
+
     InstrList guard_loads;
     InstrList guard_stores;
-    
+
     for (ii = basic_block.begin();
          ii != basic_block.end();
          ++ii)
     {
         Instruction &inst = *ii;
-        
+
         if (LoadInst *load = dyn_cast<LoadInst>(&inst))
             if (isGuardVariableRef(load->getPointerOperand()))
-                guard_loads.push_back(&inst);                
-        
-        if (StoreInst *store = dyn_cast<StoreInst>(&inst))            
+                guard_loads.push_back(&inst);
+
+        if (StoreInst *store = dyn_cast<StoreInst>(&inst))
             if (isGuardVariableRef(store->getPointerOperand()))
                 guard_stores.push_back(&inst);
     }
-    
+
     InstrIterator iter;
-    
+
     for (iter = guard_loads.begin();
          iter != guard_loads.end();
          ++iter)
         TurnGuardLoadIntoZero(*iter);
-    
+
     for (iter = guard_stores.begin();
          iter != guard_stores.end();
          ++iter)
         ExciseGuardStore(*iter);
-    
+
     return true;
 }
 
@@ -2128,22 +2128,22 @@ IRForTarget::UnfoldConstant(Constant *ol
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     SmallVector<User*, 16> users;
-    
+
     // We do this because the use list might change, invalidating our iterator.
     // Much better to keep a work list ourselves.
     for (llvm::User *u : old_constant->users())
         users.push_back(u);
-        
+
     for (size_t i = 0;
          i < users.size();
          ++i)
     {
         User *user = users[i];
-                
+
         if (Constant *constant = dyn_cast<Constant>(user))
         {
             // synthesize a new non-constant equivalent of the constant
-            
+
             if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(constant))
             {
                 switch (constant_expr->getOpcode())
@@ -2153,20 +2153,20 @@ IRForTarget::UnfoldConstant(Constant *ol
                         log->Printf("Unhandled constant expression type: \"%s\"", PrintValue(constant_expr).c_str());
                     return false;
                 case Instruction::BitCast:
-                    {                                                
+                    {
                         FunctionValueCache bit_cast_maker ([&value_maker, &entry_instruction_finder, old_constant, constant_expr] (llvm::Function *function)->llvm::Value* {
                             // UnaryExpr
                             //   OperandList[0] is value
 
                             if (constant_expr->getOperand(0) != old_constant)
                                 return constant_expr;
-                            
+
                             return new BitCastInst(value_maker.GetValue(function),
                                                    constant_expr->getType(),
                                                    "",
                                                    llvm::cast<Instruction>(entry_instruction_finder.GetValue(function)));
                         });
-                        
+
                         if (!UnfoldConstant(constant_expr, bit_cast_maker, entry_instruction_finder))
                             return false;
                     }
@@ -2176,35 +2176,35 @@ IRForTarget::UnfoldConstant(Constant *ol
                         // GetElementPtrConstantExpr
                         //   OperandList[0] is base
                         //   OperandList[1]... are indices
-                        
+
                         FunctionValueCache get_element_pointer_maker ([&value_maker, &entry_instruction_finder, old_constant, constant_expr] (llvm::Function *function)->llvm::Value* {
                             Value *ptr = constant_expr->getOperand(0);
-                            
+
                             if (ptr == old_constant)
                                 ptr = value_maker.GetValue(function);
-                            
+
                             std::vector<Value*> index_vector;
-                            
+
                             unsigned operand_index;
                             unsigned num_operands = constant_expr->getNumOperands();
-                            
+
                             for (operand_index = 1;
                                  operand_index < num_operands;
                                  ++operand_index)
                             {
                                 Value *operand = constant_expr->getOperand(operand_index);
-                                
+
                                 if (operand == old_constant)
                                     operand = value_maker.GetValue(function);
-                                
+
                                 index_vector.push_back(operand);
                             }
-                            
+
                             ArrayRef <Value*> indices(index_vector);
-                            
+
                             return GetElementPtrInst::Create(ptr, indices, "", llvm::cast<Instruction>(entry_instruction_finder.GetValue(function)));
                         });
-                        
+
                         if (!UnfoldConstant(constant_expr, get_element_pointer_maker, entry_instruction_finder))
                             return false;
                     }
@@ -2232,162 +2232,162 @@ IRForTarget::UnfoldConstant(Constant *ol
             }
         }
     }
-    
+
     if (!isa<GlobalValue>(old_constant))
     {
         old_constant->destroyConstant();
     }
-    
+
     return true;
 }
 
-bool 
+bool
 IRForTarget::ReplaceVariables (Function &llvm_function)
 {
     if (!m_resolve_vars)
         return true;
-    
+
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     m_decl_map->DoStructLayout();
-    
+
     if (log)
         log->Printf("Element arrangement:");
-    
+
     uint32_t num_elements;
     uint32_t element_index;
-    
+
     size_t size;
     lldb::offset_t alignment;
-    
+
     if (!m_decl_map->GetStructInfo (num_elements, size, alignment))
         return false;
-    
+
     Function::arg_iterator iter(llvm_function.getArgumentList().begin());
-    
+
     if (iter == llvm_function.getArgumentList().end())
     {
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Wrapper takes no arguments (should take at least a struct pointer)");
-        
+
         return false;
     }
-        
+
     Argument *argument = iter;
-    
+
     if (argument->getName().equals("this"))
     {
         ++iter;
-        
+
         if (iter == llvm_function.getArgumentList().end())
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Wrapper takes only 'this' argument (should take a struct pointer too)");
-         
+
             return false;
         }
-        
+
         argument = iter;
     }
     else if (argument->getName().equals("self"))
     {
         ++iter;
-        
+
         if (iter == llvm_function.getArgumentList().end())
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Wrapper takes only 'self' argument (should take '_cmd' and a struct pointer too)");
-            
+
             return false;
         }
-        
+
         if (!iter->getName().equals("_cmd"))
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Wrapper takes '%s' after 'self' argument (should take '_cmd')", iter->getName().str().c_str());
-            
+
             return false;
         }
-        
+
         ++iter;
-        
+
         if (iter == llvm_function.getArgumentList().end())
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Wrapper takes only 'self' and '_cmd' arguments (should take a struct pointer too)");
-            
+
             return false;
         }
-        
+
         argument = iter;
     }
-    
+
     if (!argument->getName().equals("$__lldb_arg"))
     {
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Wrapper takes an argument named '%s' instead of the struct pointer", argument->getName().str().c_str());
-        
+
         return false;
     }
-        
+
     if (log)
         log->Printf("Arg: \"%s\"", PrintValue(argument).c_str());
-    
+
     BasicBlock &entry_block(llvm_function.getEntryBlock());
     Instruction *FirstEntryInstruction(entry_block.getFirstNonPHIOrDbg());
-    
+
     if (!FirstEntryInstruction)
     {
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Couldn't find the first instruction in the wrapper for use in rewriting");
-        
+
         return false;
     }
-    
+
     LLVMContext &context(m_module->getContext());
     IntegerType *offset_type(Type::getInt32Ty(context));
-    
+
     if (!offset_type)
     {
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Couldn't produce an offset type");
-        
+
         return false;
     }
-        
+
     for (element_index = 0; element_index < num_elements; ++element_index)
     {
         const clang::NamedDecl *decl = NULL;
         Value *value = NULL;
         lldb::offset_t offset;
         lldb_private::ConstString name;
-        
+
         if (!m_decl_map->GetStructElement (decl, value, offset, name, element_index))
         {
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Structure information is incomplete");
-            
+
             return false;
         }
-            
+
         if (log)
             log->Printf("  \"%s\" (\"%s\") placed at %" PRIu64,
                         name.GetCString(),
                         decl->getNameAsString().c_str(),
                         offset);
-    
+
         if (value)
         {
             if (log)
                 log->Printf("    Replacing [%s]", PrintValue(value).c_str());
-            
+
             FunctionValueCache body_result_maker ([this, name, offset_type, offset, argument, value] (llvm::Function *function)->llvm::Value * {
                 // Per the comment at ASTResultSynthesizer::SynthesizeBodyResult, in cases where the result
                 // variable is an rvalue, we have to synthesize a dereference of the appropriate structure
                 // entry in order to produce the static variable that the AST thinks it is accessing.
-                
+
                 llvm::Instruction *entry_instruction = llvm::cast<Instruction>(m_entry_instruction_finder.GetValue(function));
-                
+
                 ConstantInt *offset_int(ConstantInt::get(offset_type, offset, true));
                 GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(argument,
                                                                                offset_int,
@@ -2400,19 +2400,19 @@ IRForTarget::ReplaceVariables (Function
                                                             value->getType()->getPointerTo(),
                                                             "",
                                                             entry_instruction);
-                    
+
                     LoadInst *load = new LoadInst(bit_cast, "", entry_instruction);
-                    
+
                     return load;
                 }
                 else
                 {
                     BitCastInst *bit_cast = new BitCastInst(get_element_ptr, value->getType(), "", entry_instruction);
-                    
+
                     return bit_cast;
                 }
-            });            
-            
+            });
+
             if (Constant *constant = dyn_cast<Constant>(value))
             {
                 UnfoldConstant(constant, body_result_maker, m_entry_instruction_finder);
@@ -2427,15 +2427,15 @@ IRForTarget::ReplaceVariables (Function
                     log->Printf("Unhandled non-constant type: \"%s\"", PrintValue(value).c_str());
                 return false;
             }
-            
+
             if (GlobalVariable *var = dyn_cast<GlobalVariable>(value))
                 var->eraseFromParent();
         }
     }
-    
+
     if (log)
         log->Printf("Total structure [align %" PRId64 ", size %" PRIu64 "]", (int64_t)alignment, (uint64_t)size);
-    
+
     return true;
 }
 
@@ -2443,29 +2443,29 @@ llvm::Constant *
 IRForTarget::BuildRelocation(llvm::Type *type, uint64_t offset)
 {
     llvm::Constant *offset_int = ConstantInt::get(m_intptr_ty, offset);
-    
+
     llvm::Constant *offset_array[1];
-    
+
     offset_array[0] = offset_int;
-    
+
     llvm::ArrayRef<llvm::Constant *> offsets(offset_array, 1);
-    
+
     llvm::Constant *reloc_getelementptr = ConstantExpr::getGetElementPtr(m_reloc_placeholder, offsets);
     llvm::Constant *reloc_getbitcast = ConstantExpr::getBitCast(reloc_getelementptr, type);
-    
+
     return reloc_getbitcast;
 }
 
-bool 
+bool
 IRForTarget::CompleteDataAllocation ()
-{    
+{
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     if (!m_data_allocator.GetStream().GetSize())
         return true;
-    
+
     lldb::addr_t allocation = m_data_allocator.Allocate();
-    
+
     if (log)
     {
         if (allocation)
@@ -2473,15 +2473,15 @@ IRForTarget::CompleteDataAllocation ()
         else
             log->Printf("Failed to allocate static data");
     }
-    
+
     if (!allocation || allocation == LLDB_INVALID_ADDRESS)
         return false;
-    
+
     Constant *relocated_addr = ConstantInt::get(m_intptr_ty, (uint64_t)allocation);
     Constant *relocated_bitcast = ConstantExpr::getIntToPtr(relocated_addr, llvm::Type::getInt8PtrTy(m_module->getContext()));
-    
+
     m_reloc_placeholder->replaceAllUsesWith(relocated_bitcast);
-    
+
     m_reloc_placeholder->eraseFromParent();
 
     return true;
@@ -2493,17 +2493,17 @@ IRForTarget::StripAllGVs (Module &llvm_m
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     std::vector<GlobalVariable *> global_vars;
     std::set<GlobalVariable *>erased_vars;
-    
+
     bool erased = true;
-    
+
     while (erased)
     {
         erased = false;
-        
+
         for (GlobalVariable &global_var : llvm_module.globals())
         {
             global_var.removeDeadConstantUsers();
-            
+
             if (global_var.use_empty())
             {
                 if (log)
@@ -2515,17 +2515,17 @@ IRForTarget::StripAllGVs (Module &llvm_m
             }
         }
     }
-    
+
     for (GlobalVariable &global_var : llvm_module.globals())
     {
         GlobalValue::user_iterator ui = global_var.user_begin();
-        
+
         if (log)
             log->Printf("Couldn't remove %s because of %s",
                         PrintValue(&global_var).c_str(),
                         PrintValue(*ui).c_str());
     }
-    
+
     return true;
 }
 
@@ -2533,46 +2533,46 @@ bool
 IRForTarget::runOnModule (Module &llvm_module)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     m_module = &llvm_module;
     m_target_data.reset(new DataLayout(m_module));
     m_intptr_ty = llvm::Type::getIntNTy(m_module->getContext(), m_target_data->getPointerSizeInBits());
-   
+
     if (log)
     {
         std::string s;
         raw_string_ostream oss(s);
-        
+
         m_module->print(oss, NULL);
-        
+
         oss.flush();
-        
+
         log->Printf("Module as passed in to IRForTarget: \n\"%s\"", s.c_str());
     }
-    
+
     Function* main_function = m_module->getFunction(StringRef(m_func_name.c_str()));
-    
+
     if (!main_function)
     {
         if (log)
             log->Printf("Couldn't find \"%s()\" in the module", m_func_name.c_str());
-        
+
         if (m_error_stream)
             m_error_stream->Printf("Internal error [IRForTarget]: Couldn't find wrapper '%s' in the module", m_func_name.c_str());
 
         return false;
     }
-    
+
     if (!FixFunctionLinkage (*main_function))
     {
         if (log)
             log->Printf("Couldn't fix the linkage for the function");
-        
+
         return false;
     }
-    
+
     llvm::Type *int8_ty = Type::getInt8Ty(m_module->getContext());
-    
+
     m_reloc_placeholder = new llvm::GlobalVariable((*m_module),
                                                    int8_ty,
                                                    false /* IsConstant */,
@@ -2586,14 +2586,14 @@ IRForTarget::runOnModule (Module &llvm_m
     ////////////////////////////////////////////////////////////
     // Replace $__lldb_expr_result with a persistent variable
     //
-    
+
     if (!CreateResultVariable(*main_function))
     {
         if (log)
             log->Printf("CreateResultVariable() failed");
-        
+
         // CreateResultVariable() reports its own errors, so we don't do so here
-        
+
         return false;
     }
 
@@ -2601,25 +2601,25 @@ IRForTarget::runOnModule (Module &llvm_m
     {
         std::string s;
         raw_string_ostream oss(s);
-        
+
         m_module->print(oss, NULL);
-        
+
         oss.flush();
-        
+
         log->Printf("Module after creating the result variable: \n\"%s\"", s.c_str());
     }
-    
+
     for (Module::iterator fi = m_module->begin(), fe = m_module->end();
          fi != fe;
          ++fi)
     {
         llvm::Function *function = fi;
-        
+
         if (function->begin() == function->end())
             continue;
-        
+
         Function::iterator bbi;
-        
+
         for (bbi = function->begin();
              bbi != function->end();
              ++bbi)
@@ -2628,62 +2628,62 @@ IRForTarget::runOnModule (Module &llvm_m
             {
                 if (log)
                     log->Printf("RemoveGuards() failed");
-                
+
                 // RemoveGuards() reports its own errors, so we don't do so here
-                
+
                 return false;
             }
-            
+
             if (!RewritePersistentAllocs(*bbi))
             {
                 if (log)
                     log->Printf("RewritePersistentAllocs() failed");
-                
+
                 // RewritePersistentAllocs() reports its own errors, so we don't do so here
-                
+
                 return false;
             }
-            
+
             if (!RemoveCXAAtExit(*bbi))
             {
                 if (log)
                     log->Printf("RemoveCXAAtExit() failed");
-                
+
                 // RemoveCXAAtExit() reports its own errors, so we don't do so here
-                
+
                 return false;
             }
         }
     }
-    
+
     ///////////////////////////////////////////////////////////////////////////////
     // Fix all Objective-C constant strings to use NSStringWithCString:encoding:
     //
-    
+
     if (!RewriteObjCConstStrings())
     {
         if (log)
             log->Printf("RewriteObjCConstStrings() failed");
-        
+
         // RewriteObjCConstStrings() reports its own errors, so we don't do so here
-        
+
         return false;
     }
-    
+
     ///////////////////////////////
     // Resolve function pointers
     //
-    
+
     if (!ResolveFunctionPointers(llvm_module))
     {
         if (log)
             log->Printf("ResolveFunctionPointers() failed");
-        
+
         // ResolveFunctionPointers() reports its own errors, so we don't do so here
-        
+
         return false;
     }
-    
+
     for (Module::iterator fi = m_module->begin(), fe = m_module->end();
          fi != fe;
          ++fi)
@@ -2698,9 +2698,9 @@ IRForTarget::runOnModule (Module &llvm_m
             {
                 if (log)
                     log->Printf("RewriteObjCSelectors() failed");
-                
+
                 // RewriteObjCSelectors() reports its own errors, so we don't do so here
-                
+
                 return false;
             }
         }
@@ -2711,7 +2711,7 @@ IRForTarget::runOnModule (Module &llvm_m
          ++fi)
     {
         llvm::Function *function = fi;
-        
+
         for (llvm::Function::iterator bbi = function->begin(), bbe = function->end();
              bbi != bbe;
              ++bbi)
@@ -2720,81 +2720,81 @@ IRForTarget::runOnModule (Module &llvm_m
             {
                 if (log)
                     log->Printf("ResolveCalls() failed");
-                
+
                 // ResolveCalls() reports its own errors, so we don't do so here
-                
+
                 return false;
             }
-            
+
             if (!ReplaceStaticLiterals(*bbi))
             {
                 if (log)
                     log->Printf("ReplaceStaticLiterals() failed");
-                
+
                 return false;
             }
         }
     }
-        
+
     ////////////////////////////////////////////////////////////////////////
     // Run function-level passes that only make sense on the main function
     //
-    
+
     if (!ResolveExternals(*main_function))
     {
         if (log)
             log->Printf("ResolveExternals() failed");
-        
+
         // ResolveExternals() reports its own errors, so we don't do so here
-        
+
         return false;
     }
-    
+
     if (!ReplaceVariables(*main_function))
     {
         if (log)
             log->Printf("ReplaceVariables() failed");
-        
+
         // ReplaceVariables() reports its own errors, so we don't do so here
-        
+
         return false;
     }
-        
+
     if (!ReplaceStrings())
     {
         if (log)
             log->Printf("ReplaceStrings() failed");
-        
+
         return false;
     }
-    
+
     if (!CompleteDataAllocation())
     {
         if (log)
             log->Printf("CompleteDataAllocation() failed");
-        
+
         return false;
     }
-        
+
     if (!StripAllGVs(llvm_module))
     {
         if (log)
             log->Printf("StripAllGVs() failed");
     }
-    
+
     if (log && log->GetVerbose())
     {
         std::string s;
         raw_string_ostream oss(s);
-        
+
         m_module->print(oss, NULL);
-        
+
         oss.flush();
-        
+
         log->Printf("Module after preparing for execution: \n\"%s\"", s.c_str());
     }
-    
-    return true;    
+
+    return true;
 }
 
 void

Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Sun Jul  6 12:54:58 2014
@@ -28,7 +28,7 @@
 
 using namespace llvm;
 
-static std::string 
+static std::string
 PrintValue(const Value *value, bool truncate = false)
 {
     std::string s;
@@ -37,13 +37,13 @@ PrintValue(const Value *value, bool trun
     rso.flush();
     if (truncate)
         s.resize(s.length() - 1);
-    
+
     size_t offset;
     while ((offset = s.find('\n')) != s.npos)
         s.erase(offset, 1);
     while (s[0] == ' ' || s[0] == '\t')
         s.erase(0, 1);
-        
+
     return s;
 }
 
@@ -63,10 +63,10 @@ static bool
 CanIgnoreCall (const CallInst *call)
 {
     const llvm::Function *called_function = call->getCalledFunction();
-    
+
     if (!called_function)
         return false;
-    
+
     if (called_function->isIntrinsic())
     {
         switch (called_function->getIntrinsicID())
@@ -78,7 +78,7 @@ CanIgnoreCall (const CallInst *call)
             return true;
         }
     }
-    
+
     return false;
 }
 
@@ -86,21 +86,21 @@ class InterpreterStackFrame
 {
 public:
     typedef std::map <const Value*, lldb::addr_t> ValueMap;
-    
+
     ValueMap                                m_values;
     DataLayout                             &m_target_data;
     lldb_private::IRMemoryMap              &m_memory_map;
     const BasicBlock                       *m_bb;
     BasicBlock::const_iterator              m_ii;
     BasicBlock::const_iterator              m_ie;
-    
+
     lldb::addr_t                            m_frame_process_address;
     size_t                                  m_frame_size;
     lldb::addr_t                            m_stack_pointer;
-    
+
     lldb::ByteOrder                         m_byte_order;
     size_t                                  m_addr_byte_size;
-    
+
     InterpreterStackFrame (DataLayout &target_data,
                            lldb_private::IRMemoryMap &memory_map,
                            lldb::addr_t stack_frame_bottom,
@@ -110,41 +110,41 @@ public:
     {
         m_byte_order = (target_data.isLittleEndian() ? lldb::eByteOrderLittle : lldb::eByteOrderBig);
         m_addr_byte_size = (target_data.getPointerSize(0));
-                        
+
         m_frame_process_address = stack_frame_bottom;
         m_frame_size = stack_frame_top - stack_frame_bottom;
         m_stack_pointer = stack_frame_top;
     }
-    
+
     ~InterpreterStackFrame ()
     {
     }
-    
+
     void Jump (const BasicBlock *bb)
     {
         m_bb = bb;
         m_ii = m_bb->begin();
         m_ie = m_bb->end();
     }
-    
+
     std::string SummarizeValue (const Value *value)
     {
         lldb_private::StreamString ss;
 
         ss.Printf("%s", PrintValue(value).c_str());
-        
+
         ValueMap::iterator i = m_values.find(value);
 
         if (i != m_values.end())
         {
             lldb::addr_t addr = i->second;
-            
+
             ss.Printf(" 0x%llx", (unsigned long long)addr);
         }
-        
+
         return ss.GetString();
     }
-    
+
     bool AssignToMatchType (lldb_private::Scalar &scalar, uint64_t u64value, Type *type)
     {
         size_t type_size = m_target_data.getTypeStoreSize(type);
@@ -166,36 +166,36 @@ public:
         default:
             return false;
         }
-        
+
         return true;
     }
-    
+
     bool EvaluateValue (lldb_private::Scalar &scalar, const Value *value, Module &module)
     {
         const Constant *constant = dyn_cast<Constant>(value);
-        
+
         if (constant)
         {
             APInt value_apint;
-            
+
             if (!ResolveConstantValue(value_apint, constant))
                 return false;
-            
+
             return AssignToMatchType(scalar, value_apint.getLimitedValue(), value->getType());
         }
         else
         {
             lldb::addr_t process_address = ResolveValue(value, module);
             size_t value_size = m_target_data.getTypeStoreSize(value->getType());
-        
+
             lldb_private::DataExtractor value_extractor;
             lldb_private::Error extract_error;
-            
+
             m_memory_map.GetMemoryData(value_extractor, process_address, value_size, extract_error);
-            
+
             if (!extract_error.Success())
                 return false;
-            
+
             lldb::offset_t offset = 0;
             if (value_size == 1 || value_size == 2 || value_size == 4 || value_size == 8)
             {
@@ -203,38 +203,38 @@ public:
                 return AssignToMatchType(scalar, u64value, value->getType());
             }
         }
-        
+
         return false;
     }
-    
+
     bool AssignValue (const Value *value, lldb_private::Scalar &scalar, Module &module)
     {
         lldb::addr_t process_address = ResolveValue (value, module);
-        
+
         if (process_address == LLDB_INVALID_ADDRESS)
             return false;
-    
+
         lldb_private::Scalar cast_scalar;
-        
+
         if (!AssignToMatchType(cast_scalar, scalar.GetRawBits64(0), value->getType()))
             return false;
-                
+
         size_t value_byte_size = m_target_data.getTypeStoreSize(value->getType());
-        
+
         lldb_private::DataBufferHeap buf(value_byte_size, 0);
-        
+
         lldb_private::Error get_data_error;
-        
+
         if (!cast_scalar.GetAsMemoryData(buf.GetBytes(), buf.GetByteSize(), m_byte_order, get_data_error))
             return false;
-        
+
         lldb_private::Error write_error;
-        
+
         m_memory_map.WriteMemory(process_address, buf.GetBytes(), buf.GetByteSize(), write_error);
-        
+
         return write_error.Success();
     }
-    
+
     bool ResolveConstantValue (APInt &value, const Constant *constant)
     {
         switch (constant->getValueID())
@@ -270,27 +270,27 @@ public:
                     {
                         ConstantExpr::const_op_iterator op_cursor = constant_expr->op_begin();
                         ConstantExpr::const_op_iterator op_end = constant_expr->op_end();
-                        
+
                         Constant *base = dyn_cast<Constant>(*op_cursor);
-                        
+
                         if (!base)
                             return false;
-                        
+
                         if (!ResolveConstantValue(value, base))
                             return false;
-                        
+
                         op_cursor++;
-                        
+
                         if (op_cursor == op_end)
                             return true; // no offset to apply!
-                        
+
                         SmallVector <Value *, 8> indices (op_cursor, op_end);
-                        
+
                         uint64_t offset = m_target_data.getIndexedOffset(base->getType(), indices);
-                        
+
                         const bool is_signed = true;
                         value += APInt(value.getBitWidth(), offset, is_signed);
-                        
+
                         return true;
                     }
                 }
@@ -306,27 +306,27 @@ public:
         }
         return false;
     }
-    
+
     bool MakeArgument(const Argument *value, uint64_t address)
     {
         lldb::addr_t data_address = Malloc(value->getType());
-        
+
         if (data_address == LLDB_INVALID_ADDRESS)
             return false;
-        
+
         lldb_private::Error write_error;
-        
+
         m_memory_map.WritePointerToMemory(data_address, address, write_error);
-        
+
         if (!write_error.Success())
         {
             lldb_private::Error free_error;
             m_memory_map.Free(data_address, free_error);
             return false;
         }
-        
+
         m_values[value] = data_address;
-        
+
         lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
         if (log)
@@ -335,75 +335,75 @@ public:
             log->Printf("  Data region    : %llx", (unsigned long long)address);
             log->Printf("  Ref region     : %llx", (unsigned long long)data_address);
         }
-        
+
         return true;
     }
-    
+
     bool ResolveConstant (lldb::addr_t process_address, const Constant *constant)
     {
         APInt resolved_value;
-        
+
         if (!ResolveConstantValue(resolved_value, constant))
             return false;
-        
+
         lldb_private::StreamString buffer (lldb_private::Stream::eBinary,
                                            m_memory_map.GetAddressByteSize(),
                                            m_memory_map.GetByteOrder());
-        
+
         size_t constant_size = m_target_data.getTypeStoreSize(constant->getType());
-        
+
         const uint64_t *raw_data = resolved_value.getRawData();
-        
+
         buffer.PutRawBytes(raw_data, constant_size, lldb::endian::InlHostByteOrder());
-        
+
         lldb_private::Error write_error;
-        
+
         m_memory_map.WriteMemory(process_address, (const uint8_t*)buffer.GetData(), constant_size, write_error);
-        
+
         return write_error.Success();
     }
-    
+
     lldb::addr_t Malloc (size_t size, uint8_t byte_alignment)
     {
         lldb::addr_t ret = m_stack_pointer;
-        
+
         ret -= size;
         ret -= (ret % byte_alignment);
-        
+
         if (ret < m_frame_process_address)
             return LLDB_INVALID_ADDRESS;
-        
+
         m_stack_pointer = ret;
         return ret;
     }
-        
+
     lldb::addr_t MallocPointer ()
     {
         return Malloc(m_target_data.getPointerSize(), m_target_data.getPointerPrefAlignment());
     }
-    
+
     lldb::addr_t Malloc (llvm::Type *type)
     {
         lldb_private::Error alloc_error;
-        
+
         return Malloc(m_target_data.getTypeAllocSize(type), m_target_data.getPrefTypeAlignment(type));
     }
-    
+
     std::string PrintData (lldb::addr_t addr, llvm::Type *type)
     {
         size_t length = m_target_data.getTypeStoreSize(type);
-        
+
         lldb_private::DataBufferHeap buf(length, 0);
-        
+
         lldb_private::Error read_error;
-        
+
         m_memory_map.ReadMemory(buf.GetBytes(), addr, length, read_error);
-        
+
         if (!read_error.Success())
             return std::string("<couldn't read data>");
-        
+
         lldb_private::StreamString ss;
-        
+
         for (size_t i = 0; i < length; i++)
         {
             if ((!(i & 0xf)) && i)
@@ -411,21 +411,21 @@ public:
             else
                 ss.Printf("%02hhx ", buf.GetBytes()[i]);
         }
-        
+
         return ss.GetString();
     }
-    
+
     lldb::addr_t ResolveValue (const Value *value, Module &module)
     {
         ValueMap::iterator i = m_values.find(value);
-        
+
         if (i != m_values.end())
             return i->second;
-        
+
         // Fall back and allocate space [allocation type Alloca]
-        
+
         lldb::addr_t data_address = Malloc(value->getType());
-        
+
         if (const Constant *constant = dyn_cast<Constant>(value))
         {
             if (!ResolveConstant (data_address, constant))
@@ -435,7 +435,7 @@ public:
                 return LLDB_INVALID_ADDRESS;
             }
         }
-        
+
         m_values[value] = data_address;
         return data_address;
     }
@@ -458,9 +458,9 @@ IRInterpreter::CanInterpret (llvm::Modul
                              lldb_private::Error &error)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     bool saw_function_with_body = false;
-    
+
     for (Module::iterator fi = module.begin(), fe = module.end();
          fi != fe;
          ++fi)
@@ -472,7 +472,7 @@ IRInterpreter::CanInterpret (llvm::Modul
             saw_function_with_body = true;
         }
     }
-    
+
     for (Function::iterator bbi = function.begin(), bbe = function.end();
          bbi != bbe;
          ++bbi)
@@ -499,14 +499,14 @@ IRInterpreter::CanInterpret (llvm::Modul
             case Instruction::Call:
                 {
                     CallInst *call_inst = dyn_cast<CallInst>(ii);
-                    
+
                     if (!call_inst)
                     {
                         error.SetErrorToGenericError();
                         error.SetErrorString(interpreter_internal_error);
                         return false;
                     }
-                    
+
                     if (!CanIgnoreCall(call_inst))
                     {
                         if (log)
@@ -522,21 +522,21 @@ IRInterpreter::CanInterpret (llvm::Modul
             case Instruction::ICmp:
                 {
                     ICmpInst *icmp_inst = dyn_cast<ICmpInst>(ii);
-                    
+
                     if (!icmp_inst)
                     {
                         error.SetErrorToGenericError();
                         error.SetErrorString(interpreter_internal_error);
                         return false;
                     }
-                    
+
                     switch (icmp_inst->getPredicate())
                     {
                     default:
                     {
                         if (log)
                             log->Printf("Unsupported ICmp predicate: %s", PrintValue(ii).c_str());
-                        
+
                         error.SetErrorToGenericError();
                         error.SetErrorString(unsupported_opcode_error);
                         return false;
@@ -577,14 +577,14 @@ IRInterpreter::CanInterpret (llvm::Modul
             case Instruction::ZExt:
                 break;
             }
-            
+
             for (int oi = 0, oe = ii->getNumOperands();
                  oi != oe;
                  ++oi)
             {
                 Value *operand = ii->getOperand(oi);
                 Type *operand_type = operand->getType();
-                
+
                 switch (operand_type->getTypeID())
                 {
                 default:
@@ -599,9 +599,9 @@ IRInterpreter::CanInterpret (llvm::Modul
                 }
             }
         }
-        
+
     }
-    
+
     return true;}
 
 bool
@@ -614,30 +614,30 @@ IRInterpreter::Interpret (llvm::Module &
                           lldb::addr_t stack_frame_top)
 {
     lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
+
     if (log)
     {
         std::string s;
         raw_string_ostream oss(s);
-        
+
         module.print(oss, NULL);
-        
+
         oss.flush();
-        
+
         log->Printf("Module as passed in to IRInterpreter::Interpret: \n\"%s\"", s.c_str());
     }
-    
+
     DataLayout data_layout(&module);
-    
+
     InterpreterStackFrame frame(data_layout, memory_map, stack_frame_bottom, stack_frame_top);
-    
+
     if (frame.m_frame_process_address == LLDB_INVALID_ADDRESS)
     {
         error.SetErrorString("Couldn't allocate stack frame");
     }
-    
+
     int arg_index = 0;
-    
+
     for (llvm::Function::arg_iterator ai = function.arg_begin(), ae = function.arg_end();
          ai != ae;
          ++ai, ++arg_index)
@@ -647,23 +647,23 @@ IRInterpreter::Interpret (llvm::Module &
             error.SetErrorString ("Not enough arguments passed in to function");
             return false;
         }
-        
+
         lldb::addr_t ptr = args[arg_index];
 
         frame.MakeArgument(ai, ptr);
     }
-    
+
     uint32_t num_insts = 0;
-    
+
     frame.Jump(function.begin());
-    
+
     while (frame.m_ii != frame.m_ie && (++num_insts < 4096))
     {
         const Instruction *inst = frame.m_ii;
-        
+
         if (log)
             log->Printf("Interpreting %s", PrintValue(inst).c_str());
-        
+
         switch (inst->getOpcode())
         {
             default:
@@ -671,7 +671,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::Call:
             {
                 const CallInst *call_inst = dyn_cast<CallInst>(inst);
-                
+
                 if (!call_inst)
                 {
                     if (log)
@@ -680,7 +680,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 if (!CanIgnoreCall(call_inst))
                 {
                     if (log)
@@ -706,7 +706,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::Xor:
             {
                 const BinaryOperator *bin_op = dyn_cast<BinaryOperator>(inst);
-                
+
                 if (!bin_op)
                 {
                     if (log)
@@ -715,13 +715,13 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 Value *lhs = inst->getOperand(0);
                 Value *rhs = inst->getOperand(1);
-                
+
                 lldb_private::Scalar L;
                 lldb_private::Scalar R;
-                
+
                 if (!frame.EvaluateValue(L, lhs, module))
                 {
                     if (log)
@@ -730,7 +730,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 if (!frame.EvaluateValue(R, rhs, module))
                 {
                     if (log)
@@ -739,9 +739,9 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 lldb_private::Scalar result;
-                
+
                 switch (inst->getOpcode())
                 {
                     default:
@@ -791,9 +791,9 @@ IRInterpreter::Interpret (llvm::Module &
                         result = L ^ R;
                         break;
                 }
-                
+
                 frame.AssignValue(inst, result, module);
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted a %s", inst->getOpcodeName());
@@ -806,7 +806,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::Alloca:
             {
                 const AllocaInst *alloca_inst = dyn_cast<AllocaInst>(inst);
-                
+
                 if (!alloca_inst)
                 {
                     if (log)
@@ -815,7 +815,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 if (alloca_inst->isArrayAllocation())
                 {
                     if (log)
@@ -824,17 +824,17 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(unsupported_opcode_error);
                     return false;
                 }
-                
+
                 // The semantics of Alloca are:
                 //   Create a region R of virtual memory of type T, backed by a data buffer
                 //   Create a region P of virtual memory of type T*, backed by a data buffer
                 //   Write the virtual address of R into P
-                
+
                 Type *T = alloca_inst->getAllocatedType();
                 Type *Tptr = alloca_inst->getType();
-                
+
                 lldb::addr_t R = frame.Malloc(T);
-                
+
                 if (R == LLDB_INVALID_ADDRESS)
                 {
                     if (log)
@@ -843,9 +843,9 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_allocation_error);
                     return false;
                 }
-                
+
                 lldb::addr_t P = frame.Malloc(Tptr);
-                
+
                 if (P == LLDB_INVALID_ADDRESS)
                 {
                     if (log)
@@ -854,11 +854,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_allocation_error);
                     return false;
                 }
-                
+
                 lldb_private::Error write_error;
-                
+
                 memory_map.WritePointerToMemory(P, R, write_error);
-                
+
                 if (!write_error.Success())
                 {
                     if (log)
@@ -870,9 +870,9 @@ IRInterpreter::Interpret (llvm::Module &
                     memory_map.Free(R, free_error);
                     return false;
                 }
-                
+
                 frame.m_values[alloca_inst] = P;
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted an AllocaInst");
@@ -885,7 +885,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::ZExt:
             {
                 const CastInst *cast_inst = dyn_cast<CastInst>(inst);
-                
+
                 if (!cast_inst)
                 {
                     if (log)
@@ -894,11 +894,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 Value *source = cast_inst->getOperand(0);
-                
+
                 lldb_private::Scalar S;
-                
+
                 if (!frame.EvaluateValue(S, source, module))
                 {
                     if (log)
@@ -907,14 +907,14 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 frame.AssignValue(inst, S, module);
             }
                 break;
             case Instruction::SExt:
             {
                 const CastInst *cast_inst = dyn_cast<CastInst>(inst);
-                
+
                 if (!cast_inst)
                 {
                     if (log)
@@ -923,11 +923,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 Value *source = cast_inst->getOperand(0);
-                
+
                 lldb_private::Scalar S;
-                
+
                 if (!frame.EvaluateValue(S, source, module))
                 {
                     if (log)
@@ -936,18 +936,18 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 S.MakeSigned();
-                
+
                 lldb_private::Scalar S_signextend(S.SLongLong());
-                
+
                 frame.AssignValue(inst, S_signextend, module);
             }
                 break;
             case Instruction::Br:
             {
                 const BranchInst *br_inst = dyn_cast<BranchInst>(inst);
-                
+
                 if (!br_inst)
                 {
                     if (log)
@@ -956,13 +956,13 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 if (br_inst->isConditional())
                 {
                     Value *condition = br_inst->getCondition();
-                    
+
                     lldb_private::Scalar C;
-                    
+
                     if (!frame.EvaluateValue(C, condition, module))
                     {
                         if (log)
@@ -971,12 +971,12 @@ IRInterpreter::Interpret (llvm::Module &
                         error.SetErrorString(bad_value_error);
                         return false;
                     }
-                    
+
                     if (C.GetRawBits64(0))
                         frame.Jump(br_inst->getSuccessor(0));
                     else
                         frame.Jump(br_inst->getSuccessor(1));
-                    
+
                     if (log)
                     {
                         log->Printf("Interpreted a BrInst with a condition");
@@ -986,7 +986,7 @@ IRInterpreter::Interpret (llvm::Module &
                 else
                 {
                     frame.Jump(br_inst->getSuccessor(0));
-                    
+
                     if (log)
                     {
                         log->Printf("Interpreted a BrInst with no condition");
@@ -997,7 +997,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::GetElementPtr:
             {
                 const GetElementPtrInst *gep_inst = dyn_cast<GetElementPtrInst>(inst);
-                
+
                 if (!gep_inst)
                 {
                     if (log)
@@ -1006,12 +1006,12 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 const Value *pointer_operand = gep_inst->getPointerOperand();
                 Type *pointer_type = pointer_operand->getType();
-                
+
                 lldb_private::Scalar P;
-                
+
                 if (!frame.EvaluateValue(P, pointer_operand, module))
                 {
                     if (log)
@@ -1020,25 +1020,25 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 typedef SmallVector <Value *, 8> IndexVector;
                 typedef IndexVector::iterator IndexIterator;
-                
+
                 SmallVector <Value *, 8> indices (gep_inst->idx_begin(),
                                                   gep_inst->idx_end());
-                
+
                 SmallVector <Value *, 8> const_indices;
-                
+
                 for (IndexIterator ii = indices.begin(), ie = indices.end();
                      ii != ie;
                      ++ii)
                 {
                     ConstantInt *constant_index = dyn_cast<ConstantInt>(*ii);
-                    
+
                     if (!constant_index)
                     {
                         lldb_private::Scalar I;
-                        
+
                         if (!frame.EvaluateValue(I, *ii, module))
                         {
                             if (log)
@@ -1047,22 +1047,22 @@ IRInterpreter::Interpret (llvm::Module &
                             error.SetErrorString(bad_value_error);
                             return false;
                         }
-                        
+
                         if (log)
                             log->Printf("Evaluated constant index %s as %llu", PrintValue(*ii).c_str(), I.ULongLong(LLDB_INVALID_ADDRESS));
-                        
+
                         constant_index = cast<ConstantInt>(ConstantInt::get((*ii)->getType(), I.ULongLong(LLDB_INVALID_ADDRESS)));
                     }
-                    
+
                     const_indices.push_back(constant_index);
                 }
-                
+
                 uint64_t offset = data_layout.getIndexedOffset(pointer_type, const_indices);
-                
+
                 lldb_private::Scalar Poffset = P + offset;
-                
+
                 frame.AssignValue(inst, Poffset, module);
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted a GetElementPtrInst");
@@ -1074,7 +1074,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::ICmp:
             {
                 const ICmpInst *icmp_inst = dyn_cast<ICmpInst>(inst);
-                
+
                 if (!icmp_inst)
                 {
                     if (log)
@@ -1083,15 +1083,15 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 CmpInst::Predicate predicate = icmp_inst->getPredicate();
-                
+
                 Value *lhs = inst->getOperand(0);
                 Value *rhs = inst->getOperand(1);
-                
+
                 lldb_private::Scalar L;
                 lldb_private::Scalar R;
-                
+
                 if (!frame.EvaluateValue(L, lhs, module))
                 {
                     if (log)
@@ -1100,7 +1100,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 if (!frame.EvaluateValue(R, rhs, module))
                 {
                     if (log)
@@ -1109,9 +1109,9 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 lldb_private::Scalar result;
-                
+
                 switch (predicate)
                 {
                     default:
@@ -1155,9 +1155,9 @@ IRInterpreter::Interpret (llvm::Module &
                         result = (L <= R);
                         break;
                 }
-                
+
                 frame.AssignValue(inst, result, module);
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted an ICmpInst");
@@ -1170,7 +1170,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::IntToPtr:
             {
                 const IntToPtrInst *int_to_ptr_inst = dyn_cast<IntToPtrInst>(inst);
-                
+
                 if (!int_to_ptr_inst)
                 {
                     if (log)
@@ -1179,11 +1179,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 Value *src_operand = int_to_ptr_inst->getOperand(0);
-                
+
                 lldb_private::Scalar I;
-                
+
                 if (!frame.EvaluateValue(I, src_operand, module))
                 {
                     if (log)
@@ -1192,9 +1192,9 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 frame.AssignValue(inst, I, module);
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted an IntToPtr");
@@ -1206,7 +1206,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::PtrToInt:
             {
                 const PtrToIntInst *ptr_to_int_inst = dyn_cast<PtrToIntInst>(inst);
-                
+
                 if (!ptr_to_int_inst)
                 {
                     if (log)
@@ -1215,11 +1215,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 Value *src_operand = ptr_to_int_inst->getOperand(0);
-                
+
                 lldb_private::Scalar I;
-                
+
                 if (!frame.EvaluateValue(I, src_operand, module))
                 {
                     if (log)
@@ -1228,9 +1228,9 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 frame.AssignValue(inst, I, module);
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted a PtrToInt");
@@ -1242,7 +1242,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::Trunc:
             {
                 const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst);
-                
+
                 if (!trunc_inst)
                 {
                     if (log)
@@ -1251,11 +1251,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 Value *src_operand = trunc_inst->getOperand(0);
-                
+
                 lldb_private::Scalar I;
-                
+
                 if (!frame.EvaluateValue(I, src_operand, module))
                 {
                     if (log)
@@ -1264,9 +1264,9 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 frame.AssignValue(inst, I, module);
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted a Trunc");
@@ -1278,7 +1278,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::Load:
             {
                 const LoadInst *load_inst = dyn_cast<LoadInst>(inst);
-                
+
                 if (!load_inst)
                 {
                     if (log)
@@ -1287,15 +1287,15 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 // The semantics of Load are:
                 //   Create a region D that will contain the loaded data
                 //   Resolve the region P containing a pointer
                 //   Dereference P to get the region R that the data should be loaded from
                 //   Transfer a unit of type type(D) from R to D
-                
+
                 const Value *pointer_operand = load_inst->getPointerOperand();
-                
+
                 Type *pointer_ty = pointer_operand->getType();
                 PointerType *pointer_ptr_ty = dyn_cast<PointerType>(pointer_ty);
                 if (!pointer_ptr_ty)
@@ -1307,10 +1307,10 @@ IRInterpreter::Interpret (llvm::Module &
                     return false;
                 }
                 Type *target_ty = pointer_ptr_ty->getElementType();
-                
+
                 lldb::addr_t D = frame.ResolveValue(load_inst, module);
                 lldb::addr_t P = frame.ResolveValue(pointer_operand, module);
-                
+
                 if (D == LLDB_INVALID_ADDRESS)
                 {
                     if (log)
@@ -1319,7 +1319,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 if (P == LLDB_INVALID_ADDRESS)
                 {
                     if (log)
@@ -1328,11 +1328,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 lldb::addr_t R;
                 lldb_private::Error read_error;
                 memory_map.ReadPointerFromMemory(&R, P, read_error);
-                
+
                 if (!read_error.Success())
                 {
                     if (log)
@@ -1341,10 +1341,10 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_read_error);
                     return false;
                 }
-                
+
                 size_t target_size = data_layout.getTypeStoreSize(target_ty);
                 lldb_private::DataBufferHeap buffer(target_size, 0);
-                
+
                 read_error.Clear();
                 memory_map.ReadMemory(buffer.GetBytes(), R, buffer.GetByteSize(), read_error);
                 if (!read_error.Success())
@@ -1355,7 +1355,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_read_error);
                     return false;
                 }
-                
+
                 lldb_private::Error write_error;
                 memory_map.WriteMemory(D, buffer.GetBytes(), buffer.GetByteSize(), write_error);
                 if (!write_error.Success())
@@ -1366,7 +1366,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_read_error);
                     return false;
                 }
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted a LoadInst");
@@ -1383,7 +1383,7 @@ IRInterpreter::Interpret (llvm::Module &
             case Instruction::Store:
             {
                 const StoreInst *store_inst = dyn_cast<StoreInst>(inst);
-                
+
                 if (!store_inst)
                 {
                     if (log)
@@ -1392,25 +1392,25 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(interpreter_internal_error);
                     return false;
                 }
-                
+
                 // The semantics of Store are:
                 //   Resolve the region D containing the data to be stored
                 //   Resolve the region P containing a pointer
                 //   Dereference P to get the region R that the data should be stored in
                 //   Transfer a unit of type type(D) from D to R
-                
+
                 const Value *value_operand = store_inst->getValueOperand();
                 const Value *pointer_operand = store_inst->getPointerOperand();
-                
+
                 Type *pointer_ty = pointer_operand->getType();
                 PointerType *pointer_ptr_ty = dyn_cast<PointerType>(pointer_ty);
                 if (!pointer_ptr_ty)
                     return false;
                 Type *target_ty = pointer_ptr_ty->getElementType();
-                
+
                 lldb::addr_t D = frame.ResolveValue(value_operand, module);
                 lldb::addr_t P = frame.ResolveValue(pointer_operand, module);
-                
+
                 if (D == LLDB_INVALID_ADDRESS)
                 {
                     if (log)
@@ -1419,7 +1419,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 if (P == LLDB_INVALID_ADDRESS)
                 {
                     if (log)
@@ -1428,11 +1428,11 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(bad_value_error);
                     return false;
                 }
-                
+
                 lldb::addr_t R;
                 lldb_private::Error read_error;
                 memory_map.ReadPointerFromMemory(&R, P, read_error);
-                
+
                 if (!read_error.Success())
                 {
                     if (log)
@@ -1441,10 +1441,10 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_read_error);
                     return false;
                 }
-                
+
                 size_t target_size = data_layout.getTypeStoreSize(target_ty);
                 lldb_private::DataBufferHeap buffer(target_size, 0);
-                
+
                 read_error.Clear();
                 memory_map.ReadMemory(buffer.GetBytes(), D, buffer.GetByteSize(), read_error);
                 if (!read_error.Success())
@@ -1455,7 +1455,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_read_error);
                     return false;
                 }
-                
+
                 lldb_private::Error write_error;
                 memory_map.WriteMemory(R, buffer.GetBytes(), buffer.GetByteSize(), write_error);
                 if (!write_error.Success())
@@ -1466,7 +1466,7 @@ IRInterpreter::Interpret (llvm::Module &
                     error.SetErrorString(memory_write_error);
                     return false;
                 }
-                
+
                 if (log)
                 {
                     log->Printf("Interpreted a StoreInst");
@@ -1477,16 +1477,16 @@ IRInterpreter::Interpret (llvm::Module &
             }
                 break;
         }
-        
+
         ++frame.m_ii;
     }
-    
+
     if (num_insts >= 4096)
     {
         error.SetErrorToGenericError();
         error.SetErrorString(infinite_loop_error);
         return false;
     }
-    
+
     return false;
 }

Modified: lldb/trunk/source/Expression/IRMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRMemoryMap.cpp?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRMemoryMap.cpp (original)
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp Sun Jul  6 12:54:58 2014
@@ -28,11 +28,11 @@ IRMemoryMap::IRMemoryMap (lldb::TargetSP
 IRMemoryMap::~IRMemoryMap ()
 {
     lldb::ProcessSP process_sp = m_process_wp.lock();
-    
+
     if (process_sp)
     {
         AllocationMap::iterator iter;
-        
+
         Error err;
 
         while ((iter = m_allocations.begin()) != m_allocations.end())
@@ -51,25 +51,25 @@ IRMemoryMap::FindSpace (size_t size)
 {
     lldb::TargetSP target_sp = m_target_wp.lock();
     lldb::ProcessSP process_sp = m_process_wp.lock();
-        
+
     lldb::addr_t ret = LLDB_INVALID_ADDRESS;
-    
+
     if (process_sp && process_sp->CanJIT() && process_sp->IsAlive())
     {
         Error alloc_error;
-        
+
         ret = process_sp->AllocateMemory(size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, alloc_error);
-        
+
         if (!alloc_error.Success())
             return LLDB_INVALID_ADDRESS;
         else
             return ret;
     }
-    
+
     for (int iterations = 0; iterations < 16; ++iterations)
     {
         lldb::addr_t candidate = LLDB_INVALID_ADDRESS;
-        
+
         switch (target_sp->GetArchitecture().GetAddressByteSize())
         {
         case 4:
@@ -90,15 +90,15 @@ IRMemoryMap::FindSpace (size_t size)
                 break;
             }
         }
-        
+
         if (IntersectsAllocation(candidate, size))
             continue;
-                
+
         ret = candidate;
-            
+
         return ret;
     }
-    
+
     return ret;
 }
 
@@ -107,9 +107,9 @@ IRMemoryMap::FindAllocation (lldb::addr_
 {
     if (addr == LLDB_INVALID_ADDRESS)
         return m_allocations.end();
-    
+
     AllocationMap::iterator iter = m_allocations.lower_bound (addr);
-    
+
     if (iter == m_allocations.end() ||
         iter->first > addr)
     {
@@ -117,10 +117,10 @@ IRMemoryMap::FindAllocation (lldb::addr_
             return m_allocations.end();
         iter--;
     }
-    
+
     if (iter->first <= addr && iter->first + iter->second.m_size >= addr + size)
         return iter;
-    
+
     return m_allocations.end();
 }
 
@@ -129,9 +129,9 @@ IRMemoryMap::IntersectsAllocation (lldb:
 {
     if (addr == LLDB_INVALID_ADDRESS)
         return false;
-    
+
     AllocationMap::const_iterator iter = m_allocations.lower_bound (addr);
-    
+
     // Since we only know that the returned interval begins at a location greater than or
     // equal to where the given interval begins, it's possible that the given interval
     // intersects either the returned interval or the previous interval.  Thus, we need to
@@ -171,15 +171,15 @@ lldb::ByteOrder
 IRMemoryMap::GetByteOrder()
 {
     lldb::ProcessSP process_sp = m_process_wp.lock();
-    
+
     if (process_sp)
         return process_sp->GetByteOrder();
-    
+
     lldb::TargetSP target_sp = m_target_wp.lock();
-    
+
     if (target_sp)
         return target_sp->GetArchitecture().GetByteOrder();
-    
+
     return lldb::eByteOrderInvalid;
 }
 
@@ -187,15 +187,15 @@ uint32_t
 IRMemoryMap::GetAddressByteSize()
 {
     lldb::ProcessSP process_sp = m_process_wp.lock();
-    
+
     if (process_sp)
         return process_sp->GetAddressByteSize();
-    
+
     lldb::TargetSP target_sp = m_target_wp.lock();
-    
+
     if (target_sp)
         return target_sp->GetArchitecture().GetAddressByteSize();
-    
+
     return UINT32_MAX;
 }
 
@@ -203,15 +203,15 @@ ExecutionContextScope *
 IRMemoryMap::GetBestExecutionContextScope() const
 {
     lldb::ProcessSP process_sp = m_process_wp.lock();
-    
+
     if (process_sp)
         return process_sp.get();
-    
+
     lldb::TargetSP target_sp = m_target_wp.lock();
-    
+
     if (target_sp)
         return target_sp.get();
-    
+
     return NULL;
 }
 
@@ -251,7 +251,7 @@ IRMemoryMap::Malloc (size_t size, uint8_
 {
     lldb_private::Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     error.Clear();
-    
+
     lldb::ProcessSP process_sp;
     lldb::addr_t    allocation_address  = LLDB_INVALID_ADDRESS;
     lldb::addr_t    aligned_address     = LLDB_INVALID_ADDRESS;
@@ -263,7 +263,7 @@ IRMemoryMap::Malloc (size_t size, uint8_
         allocation_size = alignment;
     else
         allocation_size = (size & alignment_mask) ? ((size + alignment) & (~alignment_mask)) : size;
-    
+
     switch (policy)
     {
     default:
@@ -328,8 +328,8 @@ IRMemoryMap::Malloc (size_t size, uint8_
         }
         break;
     }
-    
-    
+
+
     lldb::addr_t mask = alignment - 1;
     aligned_address = (allocation_address + mask) & (~mask);
 
@@ -339,11 +339,11 @@ IRMemoryMap::Malloc (size_t size, uint8_
                                                 permissions,
                                                 alignment,
                                                 policy);
-    
+
     if (log)
     {
         const char * policy_string;
-        
+
         switch (policy)
         {
         default:
@@ -359,7 +359,7 @@ IRMemoryMap::Malloc (size_t size, uint8_
             policy_string = "eAllocationPolicyMirror";
             break;
         }
-        
+
         log->Printf("IRMemoryMap::Malloc (%" PRIu64 ", 0x%" PRIx64 ", 0x%" PRIx64 ", %s) -> 0x%" PRIx64,
                     (uint64_t)allocation_size,
                     (uint64_t)alignment,
@@ -367,7 +367,7 @@ IRMemoryMap::Malloc (size_t size, uint8_
                     policy_string,
                     aligned_address);
     }
-    
+
     return aligned_address;
 }
 
@@ -375,16 +375,16 @@ void
 IRMemoryMap::Leak (lldb::addr_t process_address, Error &error)
 {
     error.Clear();
-    
+
     AllocationMap::iterator iter = m_allocations.find(process_address);
-    
+
     if (iter == m_allocations.end())
     {
         error.SetErrorToGenericError();
         error.SetErrorString("Couldn't leak: allocation doesn't exist");
         return;
     }
-    
+
     Allocation &allocation = iter->second;
 
     allocation.m_leak = true;
@@ -394,18 +394,18 @@ void
 IRMemoryMap::Free (lldb::addr_t process_address, Error &error)
 {
     error.Clear();
-    
+
     AllocationMap::iterator iter = m_allocations.find(process_address);
-    
+
     if (iter == m_allocations.end())
     {
         error.SetErrorToGenericError();
         error.SetErrorString("Couldn't free: allocation doesn't exist");
         return;
     }
-    
+
     Allocation &allocation = iter->second;
-        
+
     switch (allocation.m_policy)
     {
     default:
@@ -417,7 +417,7 @@ IRMemoryMap::Free (lldb::addr_t process_
                 if (process_sp->CanJIT() && process_sp->IsAlive())
                     process_sp->DeallocateMemory(allocation.m_process_alloc); // FindSpace allocated this for real
             }
-    
+
             break;
         }
     case eAllocationPolicyMirror:
@@ -428,15 +428,15 @@ IRMemoryMap::Free (lldb::addr_t process_
                 process_sp->DeallocateMemory(allocation.m_process_alloc);
         }
     }
-    
+
     if (lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS))
-    {        
+    {
         log->Printf("IRMemoryMap::Free (0x%" PRIx64 ") freed [0x%" PRIx64 "..0x%" PRIx64 ")",
                     (uint64_t)process_address,
                     iter->second.m_process_start,
                     iter->second.m_process_start + iter->second.m_size);
     }
-    
+
     m_allocations.erase(iter);
 }
 
@@ -444,28 +444,28 @@ void
 IRMemoryMap::WriteMemory (lldb::addr_t process_address, const uint8_t *bytes, size_t size, Error &error)
 {
     error.Clear();
-    
+
     AllocationMap::iterator iter = FindAllocation(process_address, size);
-    
+
     if (iter == m_allocations.end())
     {
         lldb::ProcessSP process_sp = m_process_wp.lock();
-        
+
         if (process_sp)
         {
             process_sp->WriteMemory(process_address, bytes, size, error);
             return;
         }
-        
+
         error.SetErrorToGenericError();
         error.SetErrorString("Couldn't write: no allocation contains the target range and the process doesn't exist");
         return;
     }
-    
+
     Allocation &allocation = iter->second;
-    
+
     uint64_t offset = process_address - allocation.m_process_start;
-    
+
     lldb::ProcessSP process_sp;
 
     switch (allocation.m_policy)
@@ -509,9 +509,9 @@ IRMemoryMap::WriteMemory (lldb::addr_t p
         }
         break;
     }
-    
+
     if (lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS))
-    {        
+    {
         log->Printf("IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64 ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
                     (uint64_t)process_address,
                     (uint64_t)bytes,
@@ -525,10 +525,10 @@ void
 IRMemoryMap::WriteScalarToMemory (lldb::addr_t process_address, Scalar &scalar, size_t size, Error &error)
 {
     error.Clear();
-    
+
     if (size == UINT32_MAX)
         size = scalar.GetByteSize();
-    
+
     if (size > 0)
     {
         uint8_t buf[32];
@@ -555,9 +555,9 @@ void
 IRMemoryMap::WritePointerToMemory (lldb::addr_t process_address, lldb::addr_t address, Error &error)
 {
     error.Clear();
-    
+
     Scalar scalar(address);
-    
+
     WriteScalarToMemory(process_address, scalar, GetAddressByteSize(), error);
 }
 
@@ -565,46 +565,46 @@ void
 IRMemoryMap::ReadMemory (uint8_t *bytes, lldb::addr_t process_address, size_t size, Error &error)
 {
     error.Clear();
-    
+
     AllocationMap::iterator iter = FindAllocation(process_address, size);
-    
+
     if (iter == m_allocations.end())
     {
         lldb::ProcessSP process_sp = m_process_wp.lock();
-        
+
         if (process_sp)
         {
             process_sp->ReadMemory(process_address, bytes, size, error);
             return;
         }
-        
+
         lldb::TargetSP target_sp = m_target_wp.lock();
-        
+
         if (target_sp)
         {
             Address absolute_address(process_address);
             target_sp->ReadMemory(absolute_address, false, bytes, size, error);
             return;
         }
-        
+
         error.SetErrorToGenericError();
         error.SetErrorString("Couldn't read: no allocation contains the target range, and neither the process nor the target exist");
         return;
     }
-    
+
     Allocation &allocation = iter->second;
-    
+
     uint64_t offset = process_address - allocation.m_process_start;
-    
+
     if (offset > allocation.m_size)
     {
         error.SetErrorToGenericError();
         error.SetErrorString("Couldn't read: data is not in the allocation");
         return;
     }
-    
+
     lldb::ProcessSP process_sp;
-    
+
     switch (allocation.m_policy)
     {
     default:
@@ -656,7 +656,7 @@ IRMemoryMap::ReadMemory (uint8_t *bytes,
         }
         break;
     }
-    
+
     if (lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS))
     {
         log->Printf("IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIx64 ", 0x%" PRId64 ") came from [0x%" PRIx64 "..0x%" PRIx64 ")",
@@ -672,19 +672,19 @@ void
 IRMemoryMap::ReadScalarFromMemory (Scalar &scalar, lldb::addr_t process_address, size_t size, Error &error)
 {
     error.Clear();
-    
+
     if (size > 0)
     {
         DataBufferHeap buf(size, 0);
         ReadMemory(buf.GetBytes(), process_address, size, error);
-        
+
         if (!error.Success())
             return;
-        
+
         DataExtractor extractor(buf.GetBytes(), buf.GetByteSize(), GetByteOrder(), GetAddressByteSize());
-        
+
         lldb::offset_t offset = 0;
-        
+
         switch (size)
         {
         default:
@@ -709,15 +709,15 @@ void
 IRMemoryMap::ReadPointerFromMemory (lldb::addr_t *address, lldb::addr_t process_address, Error &error)
 {
     error.Clear();
-    
+
     Scalar pointer_scalar;
     ReadScalarFromMemory(pointer_scalar, process_address, GetAddressByteSize(), error);
-    
+
     if (!error.Success())
         return;
-    
+
     *address = pointer_scalar.ULongLong();
-    
+
     return;
 }
 
@@ -725,20 +725,20 @@ void
 IRMemoryMap::GetMemoryData (DataExtractor &extractor, lldb::addr_t process_address, size_t size, Error &error)
 {
     error.Clear();
-    
+
     if (size > 0)
     {
         AllocationMap::iterator iter = FindAllocation(process_address, size);
-        
+
         if (iter == m_allocations.end())
         {
             error.SetErrorToGenericError();
             error.SetErrorStringWithFormat("Couldn't find an allocation containing [0x%" PRIx64 "..0x%" PRIx64 ")", process_address, process_address + size);
             return;
         }
-        
+
         Allocation &allocation = iter->second;
-        
+
         switch (allocation.m_policy)
         {
         default:
@@ -788,5 +788,3 @@ IRMemoryMap::GetMemoryData (DataExtracto
         return;
     }
 }
-
-

Modified: lldb/trunk/source/Expression/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Makefile?rev=212411&r1=212410&r2=212411&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Makefile (original)
+++ lldb/trunk/source/Expression/Makefile Sun Jul  6 12:54:58 2014
@@ -1,10 +1,10 @@
 ##===- source/Expression/Makefile --------------------------*- Makefile -*-===##
-# 
+#
 #                     The LLVM Compiler Infrastructure
 #
 # This file is distributed under the University of Illinois Open Source
 # License. See LICENSE.TXT for details.
-# 
+#
 ##===----------------------------------------------------------------------===##
 
 LLDB_LEVEL := ../..





More information about the lldb-commits mailing list