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/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;
 }