[Lldb-commits] [lldb] r165269 - in /lldb/trunk: include/lldb/Core/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/
Jason Molenda
jmolenda at apple.com
Thu Oct 4 15:47:07 PDT 2012
Author: jmolenda
Date: Thu Oct 4 17:47:07 2012
New Revision: 165269
URL: http://llvm.org/viewvc/llvm-project?rev=165269&view=rev
Log:
Ran the sources through the compiler with -Wshadow warnings
enabled after we'd found a few bugs that were caused by shadowed
local variables; the most important issue this turned up was
a common mistake of trying to obtain a mutex lock for the scope
of a code block by doing
Mutex::Locker(m_map_mutex);
This doesn't assign the lock object to a local variable; it is
a temporary that has its dtor called immediately. Instead,
Mutex::Locker locker(m_map_mutex);
does what is intended. For some reason -Wshadow happened to
highlight these as shadowed variables.
I also fixed a few obivous and easy shadowed variable issues
across the code base but there are a couple dozen more that
should be fixed when someone has a free minute.
<rdar://problem/12437585>
Modified:
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/Core/FormatNavigator.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Communication.cpp
lldb/trunk/source/Core/DataBufferMemoryMap.cpp
lldb/trunk/source/Core/FormatManager.cpp
lldb/trunk/source/Core/StreamCallback.cpp
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp
lldb/trunk/source/Interpreter/OptionValuePathMappings.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/StopInfo.cpp
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Oct 4 17:47:07 2012
@@ -294,7 +294,7 @@
Enable (bool value,
uint32_t position)
{
- Mutex::Locker(m_mutex);
+ Mutex::Locker locker(m_mutex);
m_enabled = value;
m_enabled_position = position;
if (m_change_listener)
@@ -358,7 +358,7 @@
Add (KeyType name,
const ValueSP& entry)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
m_map[name] = entry;
if (listener)
listener->Changed();
@@ -367,7 +367,7 @@
bool
Delete (KeyType name)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
return false;
@@ -382,7 +382,7 @@
Enable (KeyType category_name,
Position pos = Default)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
ValueSP category;
if (!Get(category_name,category))
return false;
@@ -392,7 +392,7 @@
bool
Disable (KeyType category_name)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
ValueSP category;
if (!Get(category_name,category))
return false;
@@ -403,7 +403,7 @@
Enable (ValueSP category,
Position pos = Default)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
if (category.get())
{
Position pos_w = pos;
@@ -432,7 +432,7 @@
bool
Disable (ValueSP category)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
if (category.get())
{
m_active_categories.remove_if(delete_matching_categories(category));
@@ -445,7 +445,7 @@
void
Clear ()
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
m_map.clear();
m_active_categories.clear();
if (listener)
@@ -456,7 +456,7 @@
Get (KeyType name,
ValueSP& entry)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
return false;
@@ -468,7 +468,7 @@
Get (uint32_t pos,
ValueSP& entry)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.begin();
MapIterator end = m_map.end();
while (pos > 0)
Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/Core/FormatNavigator.h Thu Oct 4 17:47:07 2012
@@ -129,7 +129,7 @@
else
entry->GetRevision() = 0;
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
m_map[name] = entry;
if (listener)
listener->Changed();
@@ -138,7 +138,7 @@
bool
Delete (KeyType name)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
return false;
@@ -151,7 +151,7 @@
void
Clear ()
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
m_map.clear();
if (listener)
listener->Changed();
@@ -161,7 +161,7 @@
Get(KeyType name,
ValueSP& entry)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
return false;
@@ -174,7 +174,7 @@
{
if (callback)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator pos, end = m_map.end();
for (pos = m_map.begin(); pos != end; pos++)
{
@@ -194,7 +194,7 @@
ValueSP
GetValueAtIndex (uint32_t index)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.begin();
MapIterator end = m_map.end();
while (index > 0)
@@ -210,7 +210,7 @@
KeyType
GetKeyAtIndex (uint32_t index)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.begin();
MapIterator end = m_map.end();
while (index > 0)
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Oct 4 17:47:07 2012
@@ -1086,7 +1086,7 @@
bool
HasChildAtIndex (uint32_t idx)
{
- Mutex::Locker(m_mutex);
+ Mutex::Locker locker(m_mutex);
ChildrenIterator iter = m_children.find(idx);
ChildrenIterator end = m_children.end();
return (iter != end);
@@ -1095,7 +1095,7 @@
ValueObject*
GetChildAtIndex (uint32_t idx)
{
- Mutex::Locker(m_mutex);
+ Mutex::Locker locker(m_mutex);
ChildrenIterator iter = m_children.find(idx);
ChildrenIterator end = m_children.end();
if (iter == end)
@@ -1108,7 +1108,7 @@
SetChildAtIndex (uint32_t idx, ValueObject* valobj)
{
ChildrenPair pair(idx,valobj); // we do not need to be mutex-protected to make a pair
- Mutex::Locker(m_mutex);
+ Mutex::Locker locker(m_mutex);
m_children.insert(pair);
}
@@ -1128,7 +1128,7 @@
Clear()
{
m_children_count = 0;
- Mutex::Locker(m_mutex);
+ Mutex::Locker locker(m_mutex);
m_children.clear();
}
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Thu Oct 4 17:47:07 2012
@@ -555,7 +555,6 @@
if (m_opaque_sp)
{
FileSpec file_spec (filename, true);
- TargetSP target_sp;
const bool add_dependent_modules = true;
Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
file_spec,
Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Thu Oct 4 17:47:07 2012
@@ -1078,7 +1078,6 @@
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
sb_error.SetError(process_sp->GetWatchpointSupportInfo (num));
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
process_sp.get(), num);
Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Thu Oct 4 17:47:07 2012
@@ -168,9 +168,9 @@
if (context.module_sp)
{
size_t num_names = m_func_names.size();
- for (int i = 0; i < num_names; i++)
+ for (int j = 0; j < num_names; j++)
{
- uint32_t num_functions = context.module_sp->FindFunctions (m_func_names[i],
+ uint32_t num_functions = context.module_sp->FindFunctions (m_func_names[j],
NULL,
m_func_name_type_mask,
include_symbols,
@@ -183,7 +183,7 @@
if (num_functions == 0 && !filter_by_cu)
{
if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeAuto))
- context.module_sp->FindSymbolsWithNameAndType (m_func_names[i], eSymbolTypeCode, sym_list);
+ context.module_sp->FindSymbolsWithNameAndType (m_func_names[j], eSymbolTypeCode, sym_list);
}
}
}
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Oct 4 17:47:07 2012
@@ -3855,9 +3855,9 @@
const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, false);
if (num_matches > 0)
{
- for (size_t i=0; i<num_matches; ++i)
+ for (size_t j=0; j<num_matches; ++j)
{
- Module *module = module_list.GetModulePointerAtIndex(i);
+ Module *module = module_list.GetModulePointerAtIndex(j);
if (module)
{
if (LookupInModule (m_interpreter, module, result, syntax_error))
Modified: lldb/trunk/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Core/Communication.cpp (original)
+++ lldb/trunk/source/Core/Communication.cpp Thu Oct 4 17:47:07 2012
@@ -208,7 +208,7 @@
{
lldb::ConnectionSP connection_sp (m_connection_sp);
- Mutex::Locker (m_write_mutex);
+ Mutex::Locker locker(m_write_mutex);
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
"%p Communication::Write (src = %p, src_len = %llu) connection = %p",
this,
Modified: lldb/trunk/source/Core/DataBufferMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataBufferMemoryMap.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataBufferMemoryMap.cpp (original)
+++ lldb/trunk/source/Core/DataBufferMemoryMap.cpp Thu Oct 4 17:47:07 2012
@@ -97,15 +97,15 @@
// offset.
//----------------------------------------------------------------------
size_t
-DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* file,
+DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
off_t offset,
size_t length,
bool writeable)
{
- if (file != NULL)
+ if (filespec != NULL)
{
char path[PATH_MAX];
- if (file->GetPath(path, sizeof(path)))
+ if (filespec->GetPath(path, sizeof(path)))
{
uint32_t options = File::eOpenOptionRead;
if (writeable)
Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Thu Oct 4 17:47:07 2012
@@ -413,7 +413,7 @@
const char** matching_category,
TypeCategoryImpl::FormatCategoryItems* matching_type)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
MapIterator pos, end = m_map.end();
for (pos = m_map.begin(); pos != end; pos++)
@@ -432,7 +432,7 @@
CategoryMap::GetSummaryFormat (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
@@ -548,7 +548,7 @@
CategoryMap::GetSyntheticChildren (ValueObject& valobj,
lldb::DynamicValueType use_dynamic)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
uint32_t reason_why;
@@ -571,7 +571,7 @@
{
if (callback)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
// loop through enabled categories in respective order
{
@@ -603,7 +603,7 @@
TypeCategoryImplSP
CategoryMap::GetAtIndex (uint32_t index)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
if (index < m_map.size())
{
Modified: lldb/trunk/source/Core/StreamCallback.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StreamCallback.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Core/StreamCallback.cpp (original)
+++ lldb/trunk/source/Core/StreamCallback.cpp Thu Oct 4 17:47:07 2012
@@ -35,7 +35,7 @@
StreamString &
StreamCallback::FindStreamForThread(lldb::tid_t cur_tid)
{
- Mutex::Locker (m_collection_mutex);
+ Mutex::Locker locker(m_collection_mutex);
collection::iterator iter = m_accumulated_data.find (cur_tid);
if (iter == m_accumulated_data.end())
{
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Oct 4 17:47:07 2012
@@ -301,9 +301,7 @@
context);
if (!user_type.GetOpaqueQualType())
- {
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
+ {
if (log)
log->Printf("ClangExpressionDeclMap::BuildCastVariable - Couldn't export the type for a constant cast result");
Modified: lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp Thu Oct 4 17:47:07 2012
@@ -150,9 +150,9 @@
{
// Sort and then erase in reverse so indexes are always valid
std::sort(remove_indexes.begin(), remove_indexes.end());
- for (int i=num_remove_indexes-1; i<num_remove_indexes; ++i)
+ for (int j=num_remove_indexes-1; j<num_remove_indexes; ++j)
{
- m_current_value.Remove (i);
+ m_current_value.Remove (j);
}
}
}
Modified: lldb/trunk/source/Interpreter/OptionValuePathMappings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValuePathMappings.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValuePathMappings.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValuePathMappings.cpp Thu Oct 4 17:47:07 2012
@@ -151,9 +151,9 @@
{
// Sort and then erase in reverse so indexes are always valid
std::sort(remove_indexes.begin(), remove_indexes.end());
- for (int i=num_remove_indexes-1; i<num_remove_indexes; ++i)
+ for (int j=num_remove_indexes-1; j<num_remove_indexes; ++j)
{
- m_path_mappings.Remove (i, m_notify_changes);
+ m_path_mappings.Remove (j, m_notify_changes);
}
}
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Oct 4 17:47:07 2012
@@ -117,7 +117,7 @@
AppleObjCRuntimeV2::RunFunctionToFindClassName(addr_t object_addr, Thread *thread, char *name_dst, size_t max_name_len)
{
// Since we are going to run code we have to make sure only one thread at a time gets to try this.
- Mutex::Locker (m_get_class_name_args_mutex);
+ Mutex::Locker locker(m_get_class_name_args_mutex);
StreamString errors;
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Oct 4 17:47:07 2012
@@ -3131,7 +3131,6 @@
if (state != eStateStopped)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
log->Printf("Process::Destroy() Halt failed to stop, state is: %s", StateAsCString(state));
// If we really couldn't stop the process then we should just error out here, but if the
@@ -3147,7 +3146,6 @@
}
else
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
log->Printf("Process::Destroy() Halt got error: %s", error.AsCString());
return error;
Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=165269&r1=165268&r2=165269&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Thu Oct 4 17:47:07 2012
@@ -316,10 +316,10 @@
{
m_should_stop = true;
m_should_stop_is_valid = true;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ LogSP log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
+ if (log_process)
+ log_process->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
}
if (log)
log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
@@ -676,10 +676,10 @@
}
else
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ LogSP log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf ("Process::%s could not find watchpoint id: %lld...", __FUNCTION__, m_value);
+ if (log_process)
+ log_process->Printf ("Process::%s could not find watchpoint id: %lld...", __FUNCTION__, m_value);
}
if (log)
log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
More information about the lldb-commits
mailing list