Fixed some warnings after enabling some stricter warnings in the Xcode project
settings.
Also fixed an issue where we weren't creating anonymous namepaces correctly:
<rdar://problem/10371295>
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143403 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj
index 80ca5dc..2f646ab 100644
--- a/lldb.xcodeproj/project.pbxproj
+++ b/lldb.xcodeproj/project.pbxproj
@@ -3592,7 +3592,7 @@
LLDB_CONFIGURATION_DEBUG,
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
@@ -3600,6 +3600,8 @@
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LLVM_BUILD_DIR = "$(SRCROOT)/llvm";
@@ -3628,7 +3630,7 @@
LLDB_CONFIGURATION_RELEASE,
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
@@ -3636,6 +3638,8 @@
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LLVM_BUILD_DIR = "$(SRCROOT)/llvm";
@@ -3913,7 +3917,7 @@
LLDB_CONFIGURATION_BUILD_AND_INTEGRATION,
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
@@ -3921,6 +3925,8 @@
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LLVM_BUILD_DIR = "$(OBJROOT)/llvm";
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index b795f23..dbe6579 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -375,11 +375,9 @@
const OptionDefinition *opt_defs = GetDefinitions ();
if (opt_defs)
{
- const char *long_option_name;
+ const char *long_option_name = long_option;
if (long_option[0] == '-' && long_option[1] == '-')
long_option_name += 2;
- else
- long_option_name = long_option;
for (uint32_t i = 0; opt_defs[i].long_option; ++i)
{
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index f729dbb..1633d44 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -13185,11 +13185,11 @@
{
default:
return false;
- eModeARM:
+ case eModeARM:
// Clear the T bit.
m_new_inst_cpsr &= ~MASK_CPSR_T;
break;
- eModeThumb:
+ case eModeThumb:
// Set the T bit.
m_new_inst_cpsr |= MASK_CPSR_T;
break;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 1e2a572..f61750a 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1012,7 +1012,17 @@
std::auto_ptr<LineTable> line_table_ap(new LineTable(sc.comp_unit));
if (line_table_ap.get())
{
- ParseDWARFLineTableCallbackInfo info = { line_table_ap.get(), m_obj_file->GetSectionList(), 0, 0, m_debug_map_symfile != NULL, false};
+ ParseDWARFLineTableCallbackInfo info = {
+ line_table_ap.get(),
+ m_obj_file->GetSectionList(),
+ 0,
+ 0,
+ m_debug_map_symfile != NULL,
+ false,
+ DWARFDebugLine::Row(),
+ SectionSP(),
+ SectionSP()
+ };
uint32_t offset = cu_line_offset;
DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info);
sc.comp_unit->SetLineTable(line_table_ap.release());
@@ -3516,14 +3526,14 @@
else
{
const char *namespace_name = die->GetAttributeValueAsString(this, curr_cu, DW_AT_name, NULL);
- if (namespace_name)
+ clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (curr_cu, die, NULL);
+ namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx);
+ LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+ if (log)
{
- clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (curr_cu, die, NULL);
- namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx);
- LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
- if (log)
+ const char *object_name = m_obj_file->GetModule()->GetObjectName().GetCString();
+ if (namespace_name)
{
- const char *object_name = m_obj_file->GetModule()->GetObjectName().GetCString();
log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)",
GetClangASTContext().getASTContext(),
MakeUserID(die->GetOffset()),
@@ -3536,11 +3546,24 @@
object_name ? "(" : "",
namespace_decl->getOriginalNamespace());
}
-
- if (namespace_decl)
- LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
- return namespace_decl;
+ else
+ {
+ log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)",
+ GetClangASTContext().getASTContext(),
+ MakeUserID(die->GetOffset()),
+ namespace_decl,
+ m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+ m_obj_file->GetFileSpec().GetFilename().GetCString(),
+ object_name ? "(" : "",
+ object_name ? object_name : "",
+ object_name ? "(" : "",
+ namespace_decl->getOriginalNamespace());
+ }
}
+
+ if (namespace_decl)
+ LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
+ return namespace_decl;
}
}
return NULL;
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 444b8fd..abc789f 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -4299,12 +4299,13 @@
ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *decl_ctx)
{
NamespaceDecl *namespace_decl = NULL;
+ ASTContext *ast = getASTContext();
+ TranslationUnitDecl *translation_unit_decl = ast->getTranslationUnitDecl ();
+ if (decl_ctx == NULL)
+ decl_ctx = translation_unit_decl;
+
if (name)
{
- ASTContext *ast = getASTContext();
- if (decl_ctx == NULL)
- decl_ctx = ast->getTranslationUnitDecl();
-
IdentifierInfo &identifier_info = ast->Idents.get(name);
DeclarationName decl_name (&identifier_info);
clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
@@ -4317,12 +4318,61 @@
namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), &identifier_info);
- decl_ctx->addDecl (namespace_decl);
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(namespace_decl);
-#endif
+ decl_ctx->addDecl (namespace_decl);
}
+ else
+ {
+ if (decl_ctx == translation_unit_decl)
+ {
+ namespace_decl = translation_unit_decl->getAnonymousNamespace();
+ if (namespace_decl)
+ return namespace_decl;
+
+ namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), NULL);
+ translation_unit_decl->setAnonymousNamespace (namespace_decl);
+ translation_unit_decl->addDecl (namespace_decl);
+ assert (namespace_decl == translation_unit_decl->getAnonymousNamespace());
+ }
+ else
+ {
+ NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
+ if (parent_namespace_decl)
+ {
+ namespace_decl = parent_namespace_decl->getAnonymousNamespace();
+ if (namespace_decl)
+ return namespace_decl;
+ namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), NULL);
+ parent_namespace_decl->setAnonymousNamespace (namespace_decl);
+ parent_namespace_decl->addDecl (namespace_decl);
+ assert (namespace_decl == parent_namespace_decl->getAnonymousNamespace());
+ }
+ else
+ {
+ // BAD!!!
+ }
+ }
+
+
+ if (namespace_decl)
+ {
+ // If we make it here, we are creating the anonymous namespace decl
+ // for the first time, so we need to do the using directive magic
+ // like SEMA does
+ UsingDirectiveDecl* using_directive_decl = UsingDirectiveDecl::Create (*ast,
+ decl_ctx,
+ SourceLocation(),
+ SourceLocation(),
+ NestedNameSpecifierLoc(),
+ SourceLocation(),
+ namespace_decl,
+ decl_ctx);
+ using_directive_decl->setImplicit();
+ decl_ctx->addDecl(using_directive_decl);
+ }
+ }
+#ifdef LLDB_CONFIGURATION_DEBUG
+ VerifyDecl(namespace_decl);
+#endif
return namespace_decl;
}
diff --git a/tools/darwin-debug/darwin-debug.cpp b/tools/darwin-debug/darwin-debug.cpp
index 4a91c3b..511b615 100644
--- a/tools/darwin-debug/darwin-debug.cpp
+++ b/tools/darwin-debug/darwin-debug.cpp
@@ -178,7 +178,7 @@
cpu_type_t cpu_type = 0;
bool show_usage = false;
- char ch;
+ int ch;
int disable_aslr = 0; // By default we disable ASLR
int pass_env = 1;
std::string unix_socket_name;
diff --git a/tools/lldb-platform/lldb-platform.cpp b/tools/lldb-platform/lldb-platform.cpp
index 5922603..7426d21 100644
--- a/tools/lldb-platform/lldb-platform.cpp
+++ b/tools/lldb-platform/lldb-platform.cpp
@@ -73,7 +73,7 @@
Args log_args;
Error error;
std::string listen_host_port;
- char ch;
+ int ch;
Debugger::Initialize();
// ConnectionMachPort a;