Brought LLDB top-of-tree into sync with LLVM/Clang
top-of-tree. Removed all local patches and llvm.zip.
The intent is that fron now on top-of-tree will
always build against LLVM/Clang top-of-tree, and
that problems building will be resolved as they
occur. Stable release branches of LLDB can be
constructed as needed and linked to specific release
branches of LLVM/Clang.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index 7c14dce..6a00895 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -39,7 +39,7 @@
{
{ LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
{ LLDB_OPT_SET_2, false, "binary" ,'b', no_argument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
- { LLDB_OPT_SET_3, true , "view-as" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
+ { LLDB_OPT_SET_3, true , "type" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
{ LLDB_OPT_SET_4, false, "force" ,'r', no_argument, NULL, 0, eArgTypeNone ,"Necessary if reading over 1024 bytes of memory."},
};
diff --git a/source/Expression/ASTStructExtractor.cpp b/source/Expression/ASTStructExtractor.cpp
index 7bc31a5..d1f2192 100644
--- a/source/Expression/ASTStructExtractor.cpp
+++ b/source/Expression/ASTStructExtractor.cpp
@@ -59,13 +59,42 @@
void
ASTStructExtractor::ExtractFromFunctionDecl(FunctionDecl *F)
{
- DeclarationName struct_name(&m_ast_context->Idents.get(m_struct_name.c_str()));
- RecordDecl::lookup_result struct_lookup = F->lookup(struct_name);
-
- if (struct_lookup.first == struct_lookup.second)
+ if (!F->hasBody())
return;
- RecordDecl *struct_decl = dyn_cast<RecordDecl>(*(struct_lookup.first));
+ 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)
+ {
+ Stmt *curr_stmt = *bi;
+ DeclStmt *curr_decl_stmt = dyn_cast<DeclStmt>(curr_stmt);
+ if (!curr_decl_stmt)
+ continue;
+ DeclGroupRef decl_group = curr_decl_stmt->getDeclGroup();
+ for (Decl *candidate_decl : decl_group)
+ {
+ RecordDecl *candidate_record_decl = dyn_cast<RecordDecl>(candidate_decl);
+ if (!candidate_record_decl)
+ continue;
+ if (candidate_record_decl->getName() == desired_name)
+ {
+ struct_decl = candidate_record_decl;
+ break;
+ }
+ }
+ if (struct_decl)
+ break;
+ }
if (!struct_decl)
return;
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 3d3a6f6..ef84b50 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -439,9 +439,9 @@
{
ASTDumper ast_dumper(decl);
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
- log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString());
+ log->Printf(" FELD[%d] Adding [to %sDecl %s] lexical %sDecl %s", current_id, context_named_decl->getDeclKindName(), context_named_decl->getNameAsString().c_str(), decl->getDeclKindName(), ast_dumper.GetCString());
else
- log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString());
+ log->Printf(" FELD[%d] Adding lexical %sDecl %s", current_id, decl->getDeclKindName(), ast_dumper.GetCString());
}
Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl);
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 3391027..f4bdfc0 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/Decl.h"
#include "lldb/lldb-private.h"
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 5dd2ce2..ea03def 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -43,12 +43,13 @@
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/ParseAST.h"
-#include "clang/Rewrite/FrontendActions.h"
+#include "clang/Rewrite/Frontend/FrontendActions.h"
#include "clang/Sema/SemaConsumer.h"
#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/TargetSelect.h"
#if !defined(__APPLE__)
@@ -199,11 +200,59 @@
llvm::DisablePrettyStackTrace = true;
}
} InitializeLLVM;
-
+
+ llvm::setCurrentDebugType("internalize");
+ llvm::DebugFlag = true;
+
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());
- // 2. Set options.
+ // 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
+ // and other things that _are_ target specific really shouldn't just be
+ // using the host triple. This needs to be fixed in a better way.
+ if (target_sp && target_sp->GetArchitecture().IsValid())
+ {
+ std::string triple = target_sp->GetArchitecture().GetTriple().str();
+
+ int dash_count = 0;
+ for (size_t i = 0; i < triple.size(); ++i)
+ {
+ if (triple[i] == '-')
+ dash_count++;
+ if (dash_count == 3)
+ {
+ triple.resize(i);
+ break;
+ }
+ }
+
+ m_compiler->getTargetOpts().Triple = triple;
+ }
+ else
+ {
+ m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
+ }
+
+ if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos)
+ m_compiler->getTargetOpts().ABI = "apcs-gnu";
+
+ m_compiler->createDiagnostics(0, 0);
+
+ // Create the target instance.
+ m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
+ m_compiler->getTargetOpts()));
+
+ assert (m_compiler->hasTarget());
+
+ // 3. Set options.
lldb::LanguageType language = expr.Language();
@@ -247,15 +296,12 @@
if (process_sp->GetObjCLanguageRuntime())
{
if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == eAppleObjC_V2)
- {
- m_compiler->getLangOpts().ObjCNonFragileABI = true; // NOT i386
- m_compiler->getLangOpts().ObjCNonFragileABI2 = true; // NOT i386
- }
+ 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;
- }
}
}
@@ -270,51 +316,6 @@
// Disable some warnings.
m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
- // Set the target triple.
- 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
- // and other things that _are_ target specific really shouldn't just be
- // using the host triple. This needs to be fixed in a better way.
- if (target_sp && target_sp->GetArchitecture().IsValid())
- {
- std::string triple = target_sp->GetArchitecture().GetTriple().str();
-
- int dash_count = 0;
- for (size_t i = 0; i < triple.size(); ++i)
- {
- if (triple[i] == '-')
- dash_count++;
- if (dash_count == 3)
- {
- triple.resize(i);
- break;
- }
- }
-
- m_compiler->getTargetOpts().Triple = triple;
- }
- else
- {
- m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
- }
-
- if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos)
- m_compiler->getTargetOpts().ABI = "apcs-gnu";
-
- // 3. Set up various important bits of infrastructure.
- m_compiler->createDiagnostics(0, 0);
-
- // Create the target instance.
- m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
- m_compiler->getTargetOpts()));
-
- assert (m_compiler->hasTarget());
-
// Inform the target of the language options
//
// FIXME: We shouldn't need to do this, the target should be immutable once
@@ -509,7 +510,7 @@
error_stream,
function_name.c_str());
- ir_for_target.runOnModule(*module);
+ bool ir_can_run = ir_for_target.runOnModule(*module);
Error &interpreter_error(ir_for_target.getInterpreterError());
@@ -534,6 +535,13 @@
return err;
}
+ else if (!ir_can_run)
+ {
+ err.SetErrorToGenericError();
+ err.SetErrorString("The expression could not be prepared to run in the target");
+
+ return err;
+ }
if (execution_policy != eExecutionPolicyNever &&
m_expr.NeedsValidation() &&
@@ -599,7 +607,18 @@
.setAllocateGVsWithCode(true)
.setCodeModel(CodeModel::Small)
.setUseMCJIT(true);
- execution_engine.reset(builder.create());
+
+ llvm::Triple triple(module->getTargetTriple());
+ StringRef mArch;
+ StringRef mCPU;
+ SmallVector<std::string, 0> mAttrs;
+
+ TargetMachine *target_machine = builder.selectTarget(triple,
+ mArch,
+ mCPU,
+ mAttrs);
+
+ execution_engine.reset(builder.create(target_machine));
if (!execution_engine.get())
{
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 544c4bc..b74e9f9 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -15,7 +15,9 @@
#include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/Module.h"
+#include "llvm/PassManager.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Transforms/IPO.h"
#include "llvm/ValueSymbolTable.h"
#include "clang/AST/ASTContext.h"
@@ -2630,6 +2632,55 @@
}
bool
+IRForTarget::StripAllGVs (Module &llvm_module)
+{
+ lldb::LogSP 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 (Module::global_iterator gi = llvm_module.global_begin(), ge = llvm_module.global_end();
+ gi != ge;
+ ++gi)
+ {
+ GlobalVariable *global_var = dyn_cast<GlobalVariable>(gi);
+
+ global_var->removeDeadConstantUsers();
+
+ if (global_var->use_empty())
+ {
+ if (log)
+ log->Printf("Did remove %s",
+ PrintValue(global_var).c_str());
+ global_var->eraseFromParent();
+ erased = true;
+ break;
+ }
+ }
+ }
+
+ for (Module::global_iterator gi = llvm_module.global_begin(), ge = llvm_module.global_end();
+ gi != ge;
+ ++gi)
+ {
+ GlobalVariable *global_var = dyn_cast<GlobalVariable>(gi);
+
+ GlobalValue::use_iterator ui = global_var->use_begin();
+
+ log->Printf("Couldn't remove %s because of %s",
+ PrintValue(global_var).c_str(),
+ PrintValue(*ui).c_str());
+ }
+
+ return true;
+}
+
+bool
IRForTarget::runOnModule (Module &llvm_module)
{
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -2674,12 +2725,12 @@
m_reloc_placeholder = new llvm::GlobalVariable((*m_module),
intptr_ty,
- false /* isConstant */,
+ false /* IsConstant */,
GlobalVariable::InternalLinkage,
Constant::getNullValue(intptr_ty),
"reloc_placeholder",
NULL /* InsertBefore */,
- false /* ThreadLocal */,
+ GlobalVariable::NotThreadLocal /* ThreadLocal */,
0 /* AddressSpace */);
Function::iterator bbi;
@@ -2876,6 +2927,12 @@
return false;
}
+ if (!StripAllGVs(llvm_module))
+ {
+ if (log)
+ log->Printf("StripAllGVs() failed");
+ }
+
if (log && log->GetVerbose())
{
std::string s;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 52e262e..144b8f9 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1388,7 +1388,9 @@
if (tag == DW_TAG_template_value_parameter && ClangASTContext::IsIntegerType (clang_type, is_signed) && uval64_valid)
{
llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed);
- template_param_infos.args.push_back (clang::TemplateArgument (llvm::APSInt(apint), clang_qual_type));
+ template_param_infos.args.push_back (clang::TemplateArgument (*GetClangASTContext().getASTContext(),
+ llvm::APSInt(apint),
+ clang_qual_type));
}
else
{
@@ -1547,7 +1549,7 @@
switch (tag)
{
case DW_TAG_member:
- case DW_TAG_APPLE_Property:
+ case DW_TAG_APPLE_property:
{
DWARFDebugInfoEntry::Attributes attributes;
const size_t num_attributes = die->GetAttributes (this,
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 9c8e24e..5929ebb 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -358,7 +358,7 @@
// inlining enabled.
//
// FIXME: This is affected by other options (-fno-inline).
- Opts.NoInline = !Opt;
+ Opts.NoInlineDefine = !Opt;
// unsigned SSP = getLastArgIntValue(Args, OPT_stack_protector, 0, Diags);
// switch (SSP) {
@@ -1167,7 +1167,7 @@
static TemplateParameterList *
CreateTemplateParameterList (ASTContext *ast,
- const ClangASTContext::TemplateParameterInfos &template_param_infos,
+ const ClangASTContext::TemplateParameterInfos &template_param_infos,
llvm::SmallVector<NamedDecl *, 8> &template_param_decls)
{
const bool parameter_pack = false;
@@ -1177,7 +1177,7 @@
for (size_t i=0; i<num_template_params; ++i)
{
const char *name = template_param_infos.names[i];
- if (template_param_infos.args[i].getAsIntegral())
+ if (template_param_infos.args[i].getKind() == TemplateArgument::Integral)
{
template_param_decls.push_back (NonTypeTemplateParmDecl::Create (*ast,
ast->getTranslationUnitDecl(), // Is this the right decl context?, SourceLocation StartLoc,
@@ -1948,15 +1948,15 @@
bit_width = new (*ast)IntegerLiteral (*ast, bitfield_bit_size_apint, ast->IntTy, SourceLocation());
}
field = FieldDecl::Create (*ast,
- record_decl,
- SourceLocation(),
- SourceLocation(),
- name ? &identifier_table->get(name) : NULL, // Identifier
- QualType::getFromOpaquePtr(field_type), // Field type
- NULL, // TInfo *
- bit_width, // BitWidth
- false, // Mutable
- false); // HasInit
+ record_decl,
+ SourceLocation(),
+ SourceLocation(),
+ name ? &identifier_table->get(name) : NULL, // Identifier
+ QualType::getFromOpaquePtr(field_type), // Field type
+ NULL, // TInfo *
+ bit_width, // BitWidth
+ false, // Mutable
+ ICIS_NoInit); // HasInit
if (!name) {
// Determine whether this field corresponds to an anonymous
@@ -3698,6 +3698,7 @@
case clang::BuiltinType::Half:
case clang::BuiltinType::ARCUnbridgedCast:
case clang::BuiltinType::PseudoObject:
+ case clang::BuiltinType::BuiltinFn:
return 1;
}
break;
@@ -5586,6 +5587,7 @@
case clang::BuiltinType::Half:
case clang::BuiltinType::ARCUnbridgedCast:
case clang::BuiltinType::PseudoObject:
+ case clang::BuiltinType::BuiltinFn:
break;
}
break;
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index 4043438..b1328aa 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -535,7 +535,8 @@
TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);
to_tag_decl->setHasExternalLexicalStorage();
-
+ to_tag_decl->setMustBuildLookupTable();
+
if (log)
log->Printf(" [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
(to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
diff --git a/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp
index 8e5f3b8..2d76d52 100644
--- a/source/Symbol/ClangASTType.cpp
+++ b/source/Symbol/ClangASTType.cpp
@@ -555,6 +555,7 @@
case clang::BuiltinType::Half:
case clang::BuiltinType::ARCUnbridgedCast:
case clang::BuiltinType::PseudoObject:
+ case clang::BuiltinType::BuiltinFn:
return lldb::eFormatHex;
}
break;
@@ -1271,7 +1272,7 @@
if (class_interface_decl)
{
clang::PrintingPolicy policy = ast_context->getPrintingPolicy();
- policy.Dump = 1;
+ policy.DumpSourceManager = &ast_context->getSourceManager();
class_interface_decl->print(llvm_ostrm, policy, s->GetIndentLevel());
}
}
diff --git a/source/Symbol/TypeHierarchyNavigator.cpp b/source/Symbol/TypeHierarchyNavigator.cpp
index 6bf4338..e046204 100644
--- a/source/Symbol/TypeHierarchyNavigator.cpp
+++ b/source/Symbol/TypeHierarchyNavigator.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/AST/ASTContext.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/ClangASTContext.h"