The implementation of categories is now synchronization safe
Code cleanup:
 - The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
   actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
   FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
   are contained. The wrapper code always remains in Debugger.{h|cpp}
 - Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
 - for type category enable, saying "enable A B C" is the same as saying
    enable C
    enable B
    enable A
   (the ordering is relevant in enabling categories, and it is expected that a user typing
    enable A B C wants to look into category A, then into B, then into C and not the other
    way round)
 - for the other two commands, the order is not really relevant (however, the same inverted ordering
   is used for consistency)


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@135494 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 8db88e7..ab35741 100644
--- a/source/Commands/CommandObjectType.cpp
+++ b/source/Commands/CommandObjectType.cpp
@@ -192,7 +192,7 @@
 
         // now I have a valid format, let's add it to every type
         
-        for(int i = 0; i < argc; i++) {
+        for (int i = 0; i < argc; i++) {
             const char* typeA = command.GetArgumentAtIndex(i);
             ConstString typeCS(typeA);
             if (typeCS)
@@ -537,7 +537,6 @@
                                                     options->m_no_children,
                                                     options->m_no_value,
                                                     options->m_one_liner,
-                                                    options->m_is_system,
                                                     std::string(funct_name),
                                                     options->m_user_source.CopyList("     ")));
         
@@ -659,7 +658,6 @@
     m_python_script = "";
     m_python_function = "";
     m_is_add_script = false;
-    m_is_system = false;
     m_category = NULL;
 }
 
@@ -730,7 +728,6 @@
                                                     m_options.m_no_children,
                                                     m_options.m_no_value,
                                                     m_options.m_one_liner,
-                                                    m_options.m_is_system,
                                                     std::string(funct_name),
                                                     "     " + m_options.m_python_function + "(valobj,dict)"));
     }
@@ -773,7 +770,6 @@
                                                     m_options.m_no_children,
                                                     m_options.m_no_value,
                                                     m_options.m_one_liner,
-                                                    m_options.m_is_system,
                                                     std::string(funct_name),
                                                     "     " + m_options.m_python_script));
     }
@@ -786,11 +782,10 @@
                                                          m_options.m_no_value,
                                                          m_options.m_one_liner,
                                                          m_options.m_regex,
-                                                         m_options.m_is_system,
                                                          m_options.m_name,
                                                          m_options.m_category);
         
-        for(int i = 0; i < argc; i++) {
+        for (int i = 0; i < argc; i++) {
             const char* typeA = command.GetArgumentAtIndex(i);
             if (typeA && *typeA)
                 options->m_target_types << typeA;
@@ -880,7 +875,6 @@
                                                                m_options.m_no_children,
                                                                m_options.m_no_value,
                                                                m_options.m_one_liner,
-                                                               m_options.m_is_system,
                                                                format_cstr));
     
     if (error.Fail()) 
@@ -892,7 +886,7 @@
     
     // now I have a valid format, let's add it to every type
     
-    for(int i = 0; i < argc; i++) {
+    for (int i = 0; i < argc; i++) {
         const char* typeA = command.GetArgumentAtIndex(i);
         if (!typeA || typeA[0] == '\0')
         {
@@ -1039,9 +1033,12 @@
 CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name,
                                         SummaryFormatSP entry,
                                         SummaryFormatType type,
-                                        const char* category,
+                                        const char* category_name,
                                         Error* error)
 {
+    lldb::FormatCategorySP category;
+    Debugger::Formatting::Categories::Get(ConstString(category_name), category);
+    
     if (type == eRegexSummary)
     {
         RegularExpressionSP typeRX(new RegularExpression());
@@ -1052,8 +1049,8 @@
             return false;
         }
         
-        Debugger::Formatting::SummaryFormats(category)->RegexSummary()->Delete(type_name.GetCString());
-        Debugger::Formatting::SummaryFormats(category)->RegexSummary()->Add(typeRX, entry);
+        category->RegexSummary()->Delete(type_name.GetCString());
+        category->RegexSummary()->Add(typeRX, entry);
         
         return true;
     }
@@ -1065,7 +1062,7 @@
     }
     else
     {
-        Debugger::Formatting::SummaryFormats(category)->Summary()->Add(type_name.GetCString(), entry);
+        category->Summary()->Add(type_name.GetCString(), entry);
         return true;
     }
 }    
@@ -1226,7 +1223,10 @@
             return result.Succeeded();
         }
         
-        bool delete_category = Debugger::Formatting::SummaryFormats(m_options.m_category)->Delete(typeCS.GetCString());
+        lldb::FormatCategorySP category;
+        Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category);
+        
+        bool delete_category = category->Delete(typeCS.GetCString());
         bool delete_named = Debugger::Formatting::NamedSummaryFormats::Delete(typeCS);
         
         if (delete_category || delete_named)
@@ -1347,14 +1347,20 @@
         
         if (m_options.m_delete_all)
             Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL);
-        else if (command.GetArgumentCount() > 0)
-        {
-            const char* cat_name = command.GetArgumentAtIndex(0);
-            ConstString cat_nameCS(cat_name);
-            Debugger::Formatting::SummaryFormats(cat_nameCS.GetCString())->Clear();
-        }
+        
         else
-            Debugger::Formatting::SummaryFormats()->Clear();
+        {        
+            lldb::FormatCategorySP category;
+            if (command.GetArgumentCount() > 0)
+            {
+                const char* cat_name = command.GetArgumentAtIndex(0);
+                ConstString cat_nameCS(cat_name);
+                Debugger::Formatting::Categories::Get(cat_nameCS, category);
+            }
+            else
+                Debugger::Formatting::Categories::Get(ConstString(NULL), category);
+            category->Clear();
+        }
         
         Debugger::Formatting::NamedSummaryFormats::Clear();
         
@@ -1523,7 +1529,7 @@
         CommandArgumentData type_style_arg;
         
         type_style_arg.arg_type = eArgTypeName;
-        type_style_arg.arg_repetition = eArgRepeatPlain;
+        type_style_arg.arg_repetition = eArgRepeatPlus;
         
         type_arg.push_back (type_style_arg);
         
@@ -1540,24 +1546,27 @@
     {
         const size_t argc = command.GetArgumentCount();
         
-        if (argc != 1)
+        if (argc < 1)
         {
-            result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+            result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
         
-        const char* typeA = command.GetArgumentAtIndex(0);
-        ConstString typeCS(typeA);
-        
-        if (!typeCS)
+        for (int i = argc - 1; i >= 0; i--)
         {
-            result.AppendError("empty category name not allowed");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
+            const char* typeA = command.GetArgumentAtIndex(i);
+            ConstString typeCS(typeA);
+            
+            if (!typeCS)
+            {
+                result.AppendError("empty category name not allowed");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+            Debugger::Formatting::Categories::Enable(typeCS);
         }
         
-        Debugger::Formatting::Categories::Enable(typeCS);
         result.SetStatus(eReturnStatusSuccessFinishResult);
         return result.Succeeded();
     }
@@ -1581,7 +1590,7 @@
         CommandArgumentData type_style_arg;
         
         type_style_arg.arg_type = eArgTypeName;
-        type_style_arg.arg_repetition = eArgRepeatPlain;
+        type_style_arg.arg_repetition = eArgRepeatPlus;
         
         type_arg.push_back (type_style_arg);
         
@@ -1598,36 +1607,42 @@
     {
         const size_t argc = command.GetArgumentCount();
         
-        if (argc != 1)
+        if (argc < 1)
         {
-            result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+            result.AppendErrorWithFormat ("%s takes 1 or more arg.\n", m_cmd_name.c_str());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
         
-        const char* typeA = command.GetArgumentAtIndex(0);
-        ConstString typeCS(typeA);
+        bool success = true;
         
-        if (!typeCS)
+        // the order is not relevant here
+        for (int i = argc - 1; i >= 0; i--)
         {
-            result.AppendError("empty category name not allowed");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
+            const char* typeA = command.GetArgumentAtIndex(i);
+            ConstString typeCS(typeA);
+            
+            if (!typeCS)
+            {
+                result.AppendError("empty category name not allowed");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+            if (!Debugger::Formatting::Categories::Delete(typeCS))
+                success = false; // keep deleting even if we hit an error
         }
-        
-        if (Debugger::Formatting::Categories::Delete(typeCS))
+        if (success)
         {
             result.SetStatus(eReturnStatusSuccessFinishResult);
             return result.Succeeded();
         }
         else
         {
-            result.AppendErrorWithFormat ("cannot delete category %s.\n", typeA);
+            result.AppendError("cannot delete one or more categories\n");
             result.SetStatus(eReturnStatusFailed);
             return false;
-        }        
+        }
     }
-    
 };
 
 //-------------------------------------------------------------------------
@@ -1647,7 +1662,7 @@
         CommandArgumentData type_style_arg;
         
         type_style_arg.arg_type = eArgTypeName;
-        type_style_arg.arg_repetition = eArgRepeatPlain;
+        type_style_arg.arg_repetition = eArgRepeatPlus;
         
         type_arg.push_back (type_style_arg);
         
@@ -1664,24 +1679,28 @@
     {
         const size_t argc = command.GetArgumentCount();
         
-        if (argc != 1)
+        if (argc < 1)
         {
-            result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+            result.AppendErrorWithFormat ("%s takes 1 or more args.\n", m_cmd_name.c_str());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
         
-        const char* typeA = command.GetArgumentAtIndex(0);
-        ConstString typeCS(typeA);
-        
-        if (!typeCS)
+        // the order is not relevant here
+        for (int i = argc - 1; i >= 0; i--)
         {
-            result.AppendError("empty category name not allowed");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
+            const char* typeA = command.GetArgumentAtIndex(i);
+            ConstString typeCS(typeA);
+            
+            if (!typeCS)
+            {
+                result.AppendError("empty category name not allowed");
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+            }
+            Debugger::Formatting::Categories::Disable(typeCS);
         }
-        
-        Debugger::Formatting::Categories::Disable(typeCS);
+
         result.SetStatus(eReturnStatusSuccessFinishResult);
         return result.Succeeded();
     }
diff --git a/source/Commands/CommandObjectType.h b/source/Commands/CommandObjectType.h
index d924287..c37bc70 100644
--- a/source/Commands/CommandObjectType.h
+++ b/source/Commands/CommandObjectType.h
@@ -39,8 +39,6 @@
     bool m_one_liner;
     bool m_regex;
     
-    bool m_is_system;
-    
     ConstString* m_name;
     
     const char* m_category;
@@ -52,7 +50,6 @@
                      bool novl,
                      bool onel,
                      bool regx,
-                     bool syst,
                      ConstString* name,
                      const char* catg) :
     m_skip_pointers(sptr),
@@ -64,7 +61,6 @@
     m_no_value(novl),
     m_one_liner(onel),
     m_regex(regx),
-    m_is_system(syst),
     m_name(name),
     m_category(catg)
     {
@@ -130,7 +126,6 @@
         std::string m_python_script;
         std::string m_python_function;
         bool m_is_add_script;
-        bool m_is_system;
         const char* m_category;
     };
     
diff --git a/source/Core/DataExtractor.cpp b/source/Core/DataExtractor.cpp
index e364dfd..f8be9a4 100644
--- a/source/Core/DataExtractor.cpp
+++ b/source/Core/DataExtractor.cpp
@@ -754,7 +754,7 @@
         if (bitfield_bit_offset > 0)
             uval64 >>= bitfield_bit_offset;
         uint64_t bitfield_mask = ((1ul << bitfield_bit_size) - 1);
-        if(!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64)
+        if (!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64)
             return uval64;
         uval64 &= bitfield_mask;
     }
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index 1c62a8c..cce768f 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -1755,12 +1755,6 @@
     return GetFormatManager().Value().GetCount();
 }
 
-lldb::FormatCategorySP
-Debugger::Formatting::SummaryFormats(const char* category_name)
-{
-    return GetFormatManager().Category(category_name);
-}
-
 bool
 Debugger::Formatting::GetSummaryFormat(ValueObject& vobj,
                                        lldb::SummaryFormatSP& entry)
@@ -1804,15 +1798,10 @@
 Debugger::Formatting::Categories::Enable(ConstString& category)
 {
     if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false)
-    {
-        //GetFormatManager().Category(category.GetCString())->Enable();
         GetFormatManager().EnableCategory(category.GetCString());
-    }
     else
     {
-        //GetFormatManager().Category(category.GetCString())->Disable();
         GetFormatManager().DisableCategory(category.GetCString());
-        //GetFormatManager().Category(category.GetCString())->Enable();
         GetFormatManager().EnableCategory(category.GetCString());
     }
 }
@@ -1821,10 +1810,7 @@
 Debugger::Formatting::Categories::Disable(ConstString& category)
 {
     if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true)
-    {
-        //GetFormatManager().Category(category.GetCString())->Disable();
         GetFormatManager().DisableCategory(category.GetCString());
-    }
 }
 
 void
diff --git a/source/Core/FormatClasses.cpp b/source/Core/FormatClasses.cpp
new file mode 100644
index 0000000..8ff237a
--- /dev/null
+++ b/source/Core/FormatClasses.cpp
@@ -0,0 +1,140 @@
+//===-- FormatClasses.cpp ----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+
+// C++ Includes
+#include <ostream>
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatClasses.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Target/StackFrame.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+std::string
+ValueFormat::FormatObject(lldb::ValueObjectSP object)
+{
+    if (!object.get())
+        return "NULL";
+    
+    StreamString sstr;
+    
+    if (ClangASTType::DumpTypeValue (object->GetClangAST(),            // The clang AST
+                                     object->GetClangType(),           // The clang type to display
+                                     &sstr,
+                                     m_format,                          // Format to display this type with
+                                     object->GetDataExtractor(),       // Data to extract from
+                                     0,                                // Byte offset into "data"
+                                     object->GetByteSize(),            // Byte size of item in "data"
+                                     object->GetBitfieldBitSize(),     // Bitfield bit size
+                                     object->GetBitfieldBitOffset()))  // Bitfield bit offset
+        return (sstr.GetString());
+    else
+    {
+        return ("unsufficient data for value");
+    }
+}
+
+std::string
+StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
+{
+    if (!object.get())
+        return "NULL";
+    
+    StreamString s;
+    ExecutionContext exe_ctx;
+    object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx);
+    SymbolContext sc;
+    if (exe_ctx.frame)
+        sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
+    
+    if (m_show_members_oneliner)
+    {
+        const uint32_t num_children = object->GetNumChildren();
+        if (num_children)
+        {
+            s.PutChar('(');
+            
+            for (uint32_t idx=0; idx<num_children; ++idx)
+            {
+                lldb::ValueObjectSP child_sp(object->GetChildAtIndex(idx, true));
+                if (child_sp.get())
+                {
+                    if (idx)
+                        s.PutCString(", ");
+                    s.PutCString(child_sp.get()->GetName().AsCString());
+                    s.PutChar('=');
+                    s.PutCString(child_sp.get()->GetPrintableRepresentation());
+                }
+            }
+            
+            s.PutChar(')');
+            
+            return s.GetString();
+        }
+        else
+            return "";
+        
+    }
+    else
+    {
+        if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get()))
+            return s.GetString();
+        else
+            return "";
+    }
+}
+
+std::string
+StringSummaryFormat::GetDescription()
+{
+    StreamString sstr;
+    sstr.Printf ("`%s`%s%s%s%s%s%s",      m_format.c_str(),
+                 m_cascades ? "" : " (not cascading)",
+                 m_dont_show_children ? "" : " (show children)",
+                 m_dont_show_value ? " (hide value)" : "",
+                 m_show_members_oneliner ? " (one-line printout)" : "",
+                 m_skip_pointers ? " (skip pointers)" : "",
+                 m_skip_references ? " (skip references)" : "");
+    return sstr.GetString();
+}
+
+std::string
+ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object)
+{
+    return std::string(ScriptInterpreterPython::CallPythonScriptFunction(m_function_name.c_str(),
+                                                                         object).c_str());
+}
+
+std::string
+ScriptSummaryFormat::GetDescription()
+{
+    StreamString sstr;
+    sstr.Printf ("%s%s%s%s%s%s\n%s",       m_cascades ? "" : " (not cascading)",
+                 m_dont_show_children ? "" : " (show children)",
+                 m_dont_show_value ? " (hide value)" : "",
+                 m_show_members_oneliner ? " (one-line printout)" : "",
+                 m_skip_pointers ? " (skip pointers)" : "",
+                 m_skip_references ? " (skip references)" : "",
+                 m_python_script.c_str());
+    return sstr.GetString();
+    
+}
+
+
diff --git a/source/Core/FormatManager.cpp b/source/Core/FormatManager.cpp
index 2ce91ae..e064534 100644
--- a/source/Core/FormatManager.cpp
+++ b/source/Core/FormatManager.cpp
@@ -184,7 +184,7 @@
         if ( ::strcmp(type,regex->GetText()) == 0)
         {
             m_format_map.map().erase(pos);
-            if(m_format_map.listener)
+            if (m_format_map.listener)
                 m_format_map.listener->Changed();
             return true;
         }
@@ -220,75 +220,4 @@
         default:
             return lldb::eFormatInvalid;
     }
-}
-
-std::string
-StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
-{
-    if (!object.get())
-        return "NULL";
-    
-    StreamString s;
-    ExecutionContext exe_ctx;
-    object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx);
-    SymbolContext sc;
-    if (exe_ctx.frame)
-        sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
-    
-    if (m_show_members_oneliner)
-    {
-        const uint32_t num_children = object->GetNumChildren();
-        if (num_children)
-        {
-            s.PutChar('(');
-            
-            for (uint32_t idx=0; idx<num_children; ++idx)
-            {
-                lldb::ValueObjectSP child_sp(object->GetChildAtIndex(idx, true));
-                if (child_sp.get())
-                {
-                    if (idx)
-                        s.PutCString(", ");
-                    s.PutCString(child_sp.get()->GetName().AsCString());
-                    s.PutChar('=');
-                    s.PutCString(child_sp.get()->GetPrintableRepresentation());
-                }
-            }
-            
-            s.PutChar(')');
-            
-            return s.GetString();
-        }
-        else
-            return "";
-        
-    }
-    else
-    {
-        if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get()))
-            return s.GetString();
-        else
-            return "";
-    }
-}
-
-void
-FormatCategory::ChooseAsPreferential(const char* name)
-{
-    Mutex::Locker(m_mutex);
-    lldb::SummaryFormatSP format;
-    
-    uint32_t revision = Debugger::Formatting::ValueFormats::GetCurrentRevision();
-    
-    if ( Summary()->Get(name, format) )
-        format->SetPriority(revision);
-    
-    format.reset();
-    
-    if ( RegexSummary()->Get(name, format) )
-        format->SetPriority(revision);
-    
-    if(m_change_listener)
-        m_change_listener->Changed();
-    
-}
+}
\ No newline at end of file
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 2c411e4..c7050f3 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -506,7 +506,7 @@
     }
     else
     {
-        if(log)
+        if (log)
             log->Printf("Found function %s for %s", function_name.c_str(), m_expr.FunctionName());
     }
     
@@ -733,7 +733,7 @@
         return ret;
     }
     
-    if(log)
+    if (log)
         log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
     
     std::pair <lldb::addr_t, lldb::addr_t> func_range;
@@ -747,7 +747,7 @@
         return ret;
     }
     
-    if(log)
+    if (log)
         log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second);
     
     if (!exe_ctx.target)
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index 0df6a5b..359b011 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -179,7 +179,7 @@
         
         m_needs_object_ptr = true;
     }
-    else if(m_objectivec)
+    else if (m_objectivec)
     {
         const char *function_name = FunctionName();
         
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index 09f520c..dd09b12 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -307,7 +307,7 @@
     {
         lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
-        if(log)
+        if (log)
             log->Printf("Instrumenting load/store instruction: %s\n", 
                         PrintValue(inst).c_str());
         
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 03716ff..e20af16 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -253,7 +253,7 @@
         {
             next_value = cast_inst->getOperand(0);
         }
-        else if(load_inst)
+        else if (load_inst)
         {
             if (isa<LoadInst>(load_inst->getPointerOperand()))
             {
@@ -1064,7 +1064,7 @@
             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)
+            if (log)
                 log->PutCString("Couldn't rewrite a reference to an Objective-C selector");
             
             return false;
@@ -1198,7 +1198,7 @@
             if (m_error_stream)
                 m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite the creation of a persistent variable\n");
             
-            if(log)
+            if (log)
                 log->PutCString("Couldn't rewrite the creation of a persistent variable");
             
             return false;
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index caed8c5..972d9a3 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -325,7 +325,7 @@
 
                 if (show_token)
                 {
-                    if(EDGetTokenString(&tokenStr, token))
+                    if (EDGetTokenString(&tokenStr, token))
                     {
                         printTokenized = false;
                         break;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index cc42306..e62c3bb 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -167,7 +167,7 @@
         SymbolContextList contexts;
         SymbolContext context;
         
-        if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) &&
+        if ((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) &&
            (!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts)))
             return NULL;
         
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index ac67767..48055d0 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -752,15 +752,15 @@
                                 // able to find the child member
                                 break;
                             }
-                            else if(end && *end == '-')
+                            else if (end && *end == '-')
                             {
                                 // this is most probably a BitField, let's take a look
                                 char *real_end = NULL;
                                 long final_index = ::strtol (end+1, &real_end, 0);
-                                if(real_end && *real_end == ']')
+                                if (real_end && *real_end == ']')
                                 {
                                     // if the format given is [high-low], swap range
-                                    if(child_index > final_index)
+                                    if (child_index > final_index)
                                     {
                                         long temp = child_index;
                                         child_index = final_index;
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index 163322a..0760872 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -339,7 +339,7 @@
     
     // If our subplan knows why we stopped, even if it's done (which would forward the question to us)
     // we answer yes.
-    if(m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
+    if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
         return true;
     
     // Check if the breakpoint is one of ours.