[Lldb-commits] [lldb] r191934 - Changed the bool conversion operator on ConstString

Sean Callanan scallanan at apple.com
Thu Oct 3 15:27:29 PDT 2013


Author: spyffe
Date: Thu Oct  3 17:27:29 2013
New Revision: 191934

URL: http://llvm.org/viewvc/llvm-project?rev=191934&view=rev
Log:
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>

Modified:
    lldb/trunk/include/lldb/Core/ConstString.h
    lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
    lldb/trunk/source/Core/ConstString.cpp
    lldb/trunk/source/Core/FileLineResolver.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Core/SearchFilter.cpp
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp
    lldb/trunk/source/Symbol/CompileUnit.cpp
    lldb/trunk/source/Target/TargetList.cpp

Modified: lldb/trunk/include/lldb/Core/ConstString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConstString.h?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConstString.h (original)
+++ lldb/trunk/include/lldb/Core/ConstString.h Thu Oct  3 17:27:29 2013
@@ -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
     ///

Modified: lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h Thu Oct  3 17:27:29 2013
@@ -76,7 +76,7 @@ GetValidTypeName_Impl (const ConstString
 {
     int strip_len = 0;
     
-    if (type == false)
+    if ((bool)type == false)
         return type;
     
     const char* type_cstr = type.AsCString();

Modified: lldb/trunk/source/Core/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConstString.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConstString.cpp (original)
+++ lldb/trunk/source/Core/ConstString.cpp Thu Oct  3 17:27:29 2013
@@ -319,7 +319,7 @@ bool
 ConstString::GetMangledCounterpart (ConstString &counterpart) const
 {
     counterpart.m_string = StringPool().GetMangledCounterpart(m_string);
-    return counterpart;
+    return (bool)counterpart;
 }
 
 void

Modified: lldb/trunk/source/Core/FileLineResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileLineResolver.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Core/FileLineResolver.cpp (original)
+++ lldb/trunk/source/Core/FileLineResolver.cpp Thu Oct  3 17:27:29 2013
@@ -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);

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Oct  3 17:27:29 2013
@@ -614,7 +614,7 @@ Module::FindCompileUnits (const FileSpec
     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 ModuleS
     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;
     }
     

Modified: lldb/trunk/source/Core/SearchFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Core/SearchFilter.cpp (original)
+++ lldb/trunk/source/Core/SearchFilter.cpp Thu Oct  3 17:27:29 2013
@@ -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 &
     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());

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Thu Oct  3 17:27:29 2013
@@ -162,14 +162,14 @@ ClangFunction::CompileFunction (Stream &
 
         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
             {   

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Thu Oct  3 17:27:29 2013
@@ -990,7 +990,7 @@ Host::GetLLDBPath (PathType path_type, F
                 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, F
                 }
             }
             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, F
 #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, F
                 }
             }
             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, F
                 }
             }
             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, F
                     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;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Oct  3 17:27:29 2013
@@ -2849,7 +2849,7 @@ SymbolFileDWARF::ResolveSymbolContext(co
             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)
                 {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Thu Oct  3 17:27:29 2013
@@ -847,7 +847,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolCo
             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);
             }
         }

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Thu Oct  3 17:27:29 2013
@@ -2987,7 +2987,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                             // 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

Modified: lldb/trunk/source/Symbol/CompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompileUnit.cpp (original)
+++ lldb/trunk/source/Symbol/CompileUnit.cpp Thu Oct  3 17:27:29 2013
@@ -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

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=191934&r1=191933&r2=191934&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Thu Oct  3 17:27:29 2013
@@ -363,7 +363,7 @@ TargetList::FindTargetWithExecutableAndA
 {
     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)





More information about the lldb-commits mailing list