summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2012-10-04 22:47:07 +0000
committerJason Molenda <jmolenda@apple.com>2012-10-04 22:47:07 +0000
commitccd41e55f1cd1a2a99bd357076638954f419429a (patch)
tree7093042eeeef422e29e4448976973272005341ca
parentbfeb28087ae76b6c241a6dc1727429fe8f6f76a7 (diff)
downloadbcm5719-llvm-ccd41e55f1cd1a2a99bd357076638954f419429a.tar.gz
bcm5719-llvm-ccd41e55f1cd1a2a99bd357076638954f419429a.zip
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> llvm-svn: 165269
-rw-r--r--lldb/include/lldb/Core/FormatManager.h20
-rw-r--r--lldb/include/lldb/Core/FormatNavigator.h14
-rw-r--r--lldb/include/lldb/Core/ValueObject.h8
-rw-r--r--lldb/source/API/SBDebugger.cpp1
-rw-r--r--lldb/source/API/SBProcess.cpp1
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverName.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp4
-rw-r--r--lldb/source/Core/Communication.cpp2
-rw-r--r--lldb/source/Core/DataBufferMemoryMap.cpp6
-rw-r--r--lldb/source/Core/FormatManager.cpp10
-rw-r--r--lldb/source/Core/StreamCallback.cpp2
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueFileSpecLIst.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValuePathMappings.cpp4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp2
-rw-r--r--lldb/source/Target/Process.cpp2
-rw-r--r--lldb/source/Target/StopInfo.cpp12
17 files changed, 48 insertions, 54 deletions
diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h
index faa64e18fc7..26d19e7ea79 100644
--- a/lldb/include/lldb/Core/FormatManager.h
+++ b/lldb/include/lldb/Core/FormatManager.h
@@ -294,7 +294,7 @@ private:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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)
diff --git a/lldb/include/lldb/Core/FormatNavigator.h b/lldb/include/lldb/Core/FormatNavigator.h
index b51fd390453..4c0af74ff5c 100644
--- a/lldb/include/lldb/Core/FormatNavigator.h
+++ b/lldb/include/lldb/Core/FormatNavigator.h
@@ -129,7 +129,7 @@ public:
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 @@ public:
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 @@ public:
void
Clear ()
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
m_map.clear();
if (listener)
listener->Changed();
@@ -161,7 +161,7 @@ public:
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 @@ public:
{
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 @@ public:
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 @@ public:
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)
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index c2f33a545f2..ccf11feea50 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -1086,7 +1086,7 @@ protected:
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 @@ protected:
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 @@ protected:
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 @@ protected:
Clear()
{
m_children_count = 0;
- Mutex::Locker(m_mutex);
+ Mutex::Locker locker(m_mutex);
m_children.clear();
}
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index ca39d2a80d6..3540b28a64c 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -555,7 +555,6 @@ SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename,
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,
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index f2613dd08ed..ea2638c4d84 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -1078,7 +1078,6 @@ SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
{
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);
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 86a536cf2c6..0f0e06d80fe 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -168,9 +168,9 @@ BreakpointResolverName::SearchCallback
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 @@ BreakpointResolverName::SearchCallback
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);
}
}
}
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 226c00ff9d5..82f7cf3f4f9 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3855,9 +3855,9 @@ protected:
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))
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index 64cc2f97ebd..0c7a8901f6f 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -208,7 +208,7 @@ Communication::Write (const void *src, size_t src_len, ConnectionStatus &status,
{
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,
diff --git a/lldb/source/Core/DataBufferMemoryMap.cpp b/lldb/source/Core/DataBufferMemoryMap.cpp
index 1668b566162..8f9b56d3539 100644
--- a/lldb/source/Core/DataBufferMemoryMap.cpp
+++ b/lldb/source/Core/DataBufferMemoryMap.cpp
@@ -97,15 +97,15 @@ DataBufferMemoryMap::Clear()
// 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)
diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp
index ef0e719a428..deb1169eb99 100644
--- a/lldb/source/Core/FormatManager.cpp
+++ b/lldb/source/Core/FormatManager.cpp
@@ -413,7 +413,7 @@ CategoryMap::AnyMatches (ConstString type_name,
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 @@ lldb::TypeSummaryImplSP
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 @@ lldb::SyntheticChildrenSP
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 @@ CategoryMap::LoopThrough(CallbackType callback, void* param)
{
if (callback)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
// loop through enabled categories in respective order
{
@@ -603,7 +603,7 @@ CategoryMap::LoopThrough(CallbackType callback, void* param)
TypeCategoryImplSP
CategoryMap::GetAtIndex (uint32_t index)
{
- Mutex::Locker(m_map_mutex);
+ Mutex::Locker locker(m_map_mutex);
if (index < m_map.size())
{
diff --git a/lldb/source/Core/StreamCallback.cpp b/lldb/source/Core/StreamCallback.cpp
index edce04e8ed8..63f3c9f8b2d 100644
--- a/lldb/source/Core/StreamCallback.cpp
+++ b/lldb/source/Core/StreamCallback.cpp
@@ -35,7 +35,7 @@ StreamCallback::~StreamCallback ()
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())
{
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index f4bdfc04549..5166300083d 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -301,9 +301,7 @@ ClangExpressionDeclMap::BuildCastVariable (const ConstString &name,
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");
diff --git a/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp b/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
index 3328dc6e1ca..325460f50a2 100644
--- a/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpecLIst.cpp
@@ -150,9 +150,9 @@ OptionValueFileSpecList::SetValueFromCString (const char *value, VarSetOperation
{
// 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);
}
}
}
diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp
index d507b146747..b5949382c5b 100644
--- a/lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp
@@ -151,9 +151,9 @@ OptionValuePathMappings::SetValueFromCString (const char *value, VarSetOperation
{
// 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);
}
}
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index ba29279b343..a72fe582e13 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -117,7 +117,7 @@ bool
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;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 5858f9972f2..2dbe88f76dd 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -3131,7 +3131,6 @@ Process::Destroy ()
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 @@ Process::Destroy ()
}
else
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
log->Printf("Process::Destroy() Halt got error: %s", error.AsCString());
return error;
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index b9c70d97c09..26c2cf5e663 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -316,10 +316,10 @@ public:
{
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 @@ public:
}
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);
OpenPOWER on IntegriCloud