Changed the bool conversion operator on ConstString

to be explicit, to prevent horrid things like

std::string a = ConstString("foo")

from taking the path ConstString -> bool -> char
-> std::string.

This fixes, among other things, ClangFunction.

<rdar://problem/15137989>

llvm-svn: 191934
This commit is contained in:
Sean Callanan 2013-10-03 22:27:29 +00:00
parent 54e14615e7
commit ddd7a2a65b
13 changed files with 23 additions and 23 deletions

View File

@ -148,11 +148,11 @@ public:
/// /b True this object contains a valid non-empty C string, \b
/// false otherwise.
//------------------------------------------------------------------
operator bool() const
explicit operator bool() const
{
return m_string && m_string[0];
}
//------------------------------------------------------------------
/// Assignment operator
///

View File

@ -76,7 +76,7 @@ GetValidTypeName_Impl (const ConstString& type)
{
int strip_len = 0;
if (type == false)
if ((bool)type == false)
return type;
const char* type_cstr = type.AsCString();

View File

@ -319,7 +319,7 @@ bool
ConstString::GetMangledCounterpart (ConstString &counterpart) const
{
counterpart.m_string = StringPool().GetMangledCounterpart(m_string);
return counterpart;
return (bool)counterpart;
}
void

View File

@ -50,7 +50,7 @@ FileLineResolver::SearchCallback
{
CompileUnit *cu = context.comp_unit;
if (m_inlines || m_file_spec.Compare(*cu, m_file_spec, m_file_spec.GetDirectory()))
if (m_inlines || m_file_spec.Compare(*cu, m_file_spec, (bool)m_file_spec.GetDirectory()))
{
uint32_t start_file_idx = 0;
uint32_t file_idx = cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false);

View File

@ -614,7 +614,7 @@ Module::FindCompileUnits (const FileSpec &path,
const size_t num_compile_units = GetNumCompileUnits();
SymbolContext sc;
sc.module_sp = shared_from_this();
const bool compare_directory = path.GetDirectory();
const bool compare_directory = (bool)path.GetDirectory();
for (size_t i=0; i<num_compile_units; ++i)
{
sc.comp_unit = GetCompileUnitAtIndex(i).get();
@ -1509,14 +1509,14 @@ Module::MatchesModuleSpec (const ModuleSpec &module_ref)
const FileSpec &file_spec = module_ref.GetFileSpec();
if (file_spec)
{
if (!FileSpec::Equal (file_spec, m_file, file_spec.GetDirectory()))
if (!FileSpec::Equal (file_spec, m_file, (bool)file_spec.GetDirectory()))
return false;
}
const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
if (platform_file_spec)
{
if (!FileSpec::Equal (platform_file_spec, GetPlatformFileSpec (), platform_file_spec.GetDirectory()))
if (!FileSpec::Equal (platform_file_spec, GetPlatformFileSpec (), (bool)platform_file_spec.GetDirectory()))
return false;
}

View File

@ -361,7 +361,7 @@ bool
SearchFilterByModule::ModulePasses (const FileSpec &spec)
{
// Do a full match only if "spec" has a directory
const bool full_match = spec.GetDirectory();
const bool full_match = (bool)spec.GetDirectory();
return FileSpec::Equal(spec, m_module_spec, full_match);
}
@ -409,7 +409,7 @@ SearchFilterByModule::Search (Searcher &searcher)
for (size_t i = 0; i < num_modules; i++)
{
Module* module = target_modules.GetModulePointerAtIndexUnlocked(i);
const bool full_match = m_module_spec.GetDirectory();
const bool full_match = (bool)m_module_spec.GetDirectory();
if (FileSpec::Equal (m_module_spec, module->GetFileSpec(), full_match))
{
SymbolContext matchingContext(m_target_sp, module->shared_from_this());

View File

@ -162,14 +162,14 @@ ClangFunction::CompileFunction (Stream &errors)
if (trust_function)
{
type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName();
type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName().AsCString("");
}
else
{
ClangASTType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetClangType ();
if (clang_qual_type)
{
type_name = clang_qual_type.GetTypeName();
type_name = clang_qual_type.GetTypeName().AsCString("");
}
else
{

View File

@ -990,7 +990,7 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
g_lldb_so_dir = lldb_file_spec.GetDirectory();
}
file_spec.GetDirectory() = g_lldb_so_dir;
return file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
}
break;
@ -1021,7 +1021,7 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
}
}
file_spec.GetDirectory() = g_lldb_support_exe_dir;
return file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
}
break;
@ -1053,7 +1053,7 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
#endif
}
file_spec.GetDirectory() = g_lldb_headers_dir;
return file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
}
break;
@ -1098,7 +1098,7 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
}
}
file_spec.GetDirectory() = g_lldb_python_dir;
return file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
}
break;
#endif
@ -1165,7 +1165,7 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
}
}
file_spec.GetDirectory() = g_lldb_user_plugin_dir;
return file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
#elif defined (__linux__)
static ConstString g_lldb_user_plugin_dir;
if (!g_lldb_user_plugin_dir)
@ -1196,7 +1196,7 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
g_lldb_user_plugin_dir.SetCString(lldb_file_spec.GetPath().c_str());
}
file_spec.GetDirectory() = g_lldb_user_plugin_dir;
return file_spec.GetDirectory();
return (bool)file_spec.GetDirectory();
#endif
// TODO: where would user LLDB plug-ins be located on other systems?
return false;

View File

@ -2849,7 +2849,7 @@ SymbolFileDWARF::ResolveSymbolContext(const FileSpec& file_spec, uint32_t line,
for (cu_idx = 0; (dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL; ++cu_idx)
{
CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
const bool full_match = file_spec.GetDirectory();
const bool full_match = (bool)file_spec.GetDirectory();
bool file_spec_matches_cu_file_spec = dc_cu != NULL && FileSpec::Equal(file_spec, *dc_cu, full_match);
if (check_inlines || file_spec_matches_cu_file_spec)
{

View File

@ -847,7 +847,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext (const FileSpec& file_spec, uint32
if (GetFileSpecForSO (i, so_file_spec))
{
// Match the full path if the incoming file_spec has a directory (not just a basename)
const bool full_match = file_spec.GetDirectory();
const bool full_match = (bool)file_spec.GetDirectory();
resolve = FileSpec::Equal (file_spec, so_file_spec, full_match);
}
}

View File

@ -2987,7 +2987,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
// Base classes should be a multiple of 8 bits in size
child_byte_offset = bit_offset/8;
ClangASTType base_class_clang_type(m_ast, base_class->getType());
child_name = base_class_clang_type.GetTypeName();
child_name = base_class_clang_type.GetTypeName().AsCString("");
uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize();
// Base classes bit sizes should be a multiple of 8 bits in size

View File

@ -324,7 +324,7 @@ CompileUnit::ResolveSymbolContext
// "file_spec" has an empty directory, then only compare the basenames
// when finding file indexes
std::vector<uint32_t> file_indexes;
const bool full_match = file_spec.GetDirectory();
const bool full_match = (bool)file_spec.GetDirectory();
bool file_spec_matches_cu_file_spec = FileSpec::Equal(file_spec, *this, full_match);
// If we are not looking for inlined functions and our file spec doesn't

View File

@ -363,7 +363,7 @@ TargetList::FindTargetWithExecutableAndArchitecture
{
Mutex::Locker locker (m_target_list_mutex);
TargetSP target_sp;
bool full_match = exe_file_spec.GetDirectory();
bool full_match = (bool)exe_file_spec.GetDirectory();
collection::const_iterator pos, end = m_target_list.end();
for (pos = m_target_list.begin(); pos != end; ++pos)