[lldb-dev] [PATCH] Fixing some compile warnings

Steve Pucci spucci at google.com
Thu Jan 16 15:00:07 PST 2014


Here are some fixes (patch attached) to remove compile warnings with gcc
4.8.2.  Notes:

1.  The change to Iterable.h with the template parameters is to avoid the
gcc warning -Wno-non-template-friend that friend declarations inside
template classes must be declared as templates:
http://stackoverflow.com/questions/4039817/friend-declaration-declares-a-non-template-function

2.  The rename of Platform::GetFile (the three-argument version) to
GetFileWithUUID was suggested by gclayton as a way to silence gcc warnings;
the warning is emitted when there is an overloaded function in a base class
(Platform) for which a derived class redefines one of the overloads but not
the other (because doing so hides the other overload from users of the
derived class).  By giving the two methods different names, the situation
is avoided.

3.  Rest are simple adds of const in appropriate places to silence warnings
about casting away constness.

 - Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140116/321fb3af/attachment.html>
-------------- next part --------------

project llvm/tools/lldb/
diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h
index 80d249d..4b77ff1 100644
--- a/include/lldb/Core/MappedHash.h
+++ b/include/lldb/Core/MappedHash.h
@@ -382,9 +382,9 @@ public:
             lldb::offset_t offset = m_header.Read (data, 0);
             if (offset != LLDB_INVALID_OFFSET && IsValid ())
             {
-                m_hash_indexes = (uint32_t *)data.GetData (&offset, m_header.bucket_count * sizeof(uint32_t));
-                m_hash_values  = (uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
-                m_hash_offsets = (uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
+                m_hash_indexes = (const uint32_t *)data.GetData (&offset, m_header.bucket_count * sizeof(uint32_t));
+                m_hash_values  = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
+                m_hash_offsets = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
             }
         }
         
@@ -542,9 +542,9 @@ public:
     protected:
         // Implementation agnostic information
         HeaderType m_header;
-        uint32_t *m_hash_indexes;
-        uint32_t *m_hash_values;
-        uint32_t *m_hash_offsets;
+        const uint32_t *m_hash_indexes;
+        const uint32_t *m_hash_values;
+        const uint32_t *m_hash_offsets;
     };
     
 };
diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h
index 355c052..be54df9 100644
--- a/include/lldb/Target/Platform.h
+++ b/include/lldb/Target/Platform.h
@@ -314,9 +314,9 @@ namespace lldb_private {
         ///     An error object.
         //------------------------------------------------------------------
         virtual Error
-        GetFile (const FileSpec &platform_file, 
-                 const UUID *uuid_ptr,
-                 FileSpec &local_file);
+        GetFileWithUUID (const FileSpec &platform_file, 
+                         const UUID *uuid_ptr,
+                         FileSpec &local_file);
 
         //----------------------------------------------------------------------
         // Locate the scripting resource given a module specification.
diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h
index 9b91cae..1733537 100644
--- a/include/lldb/Utility/Iterable.h
+++ b/include/lldb/Utility/Iterable.h
@@ -147,9 +147,14 @@ public:
         return m_iter >= rhs.m_iter;
     }
     
-    friend AdaptedConstIterator operator+(typename BackingIterator::difference_type, AdaptedConstIterator &);
-    friend typename BackingIterator::difference_type operator-(AdaptedConstIterator &, AdaptedConstIterator &);
-    friend void swap(AdaptedConstIterator &, AdaptedConstIterator &);
+    template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
+    friend AdaptedConstIterator<C1, E1, A1> operator+(typename C1::const_iterator::difference_type, AdaptedConstIterator<C1, E1, A1> &);
+
+    template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
+    friend typename C1::const_iterator::difference_type operator-(AdaptedConstIterator<C1, E1, A1> &, AdaptedConstIterator<C1, E1, A1> &);
+
+    template <typename C1, typename E1, E1 (*A1)(typename C1::const_iterator &)>
+    friend void swap(AdaptedConstIterator<C1, E1, A1> &, AdaptedConstIterator<C1, E1, A1> &);
 };
     
 template <typename C, typename E, E (*A)(typename C::const_iterator &)>
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index da29c16..10449ff 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -571,14 +571,14 @@ PlatformFreeBSD::GetGroupName (uint32_t gid)
 
 // From PlatformMacOSX only
 Error
-PlatformFreeBSD::GetFile (const FileSpec &platform_file,
-                          const UUID *uuid_ptr,
-                          FileSpec &local_file)
+PlatformFreeBSD::GetFileWithUUID (const FileSpec &platform_file,
+                                  const UUID *uuid_ptr,
+                                  FileSpec &local_file)
 {
     if (IsRemote())
     {
         if (m_remote_platform_sp)
-            return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file);
+            return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
     }
 
     // Default to the local case
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index 11d1cd6..d09557d 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -144,8 +144,8 @@ public:
 
     // Only on PlatformMacOSX:
     virtual lldb_private::Error
-    GetFile (const lldb_private::FileSpec &platform_file,
-             const lldb_private::UUID* uuid, lldb_private::FileSpec &local_file);
+    GetFileWithUUID (const lldb_private::FileSpec &platform_file,
+                     const lldb_private::UUID* uuid, lldb_private::FileSpec &local_file);
 
     lldb_private::Error
     GetSharedModule (const lldb_private::ModuleSpec &module_spec,
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 7ffb30e..be3b0a9 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -285,13 +285,13 @@ PlatformLinux::ResolveExecutable (const FileSpec &exe_file,
 }
 
 Error
-PlatformLinux::GetFile (const FileSpec &platform_file, 
-                        const UUID *uuid_ptr, FileSpec &local_file)
+PlatformLinux::GetFileWithUUID (const FileSpec &platform_file, 
+                                const UUID *uuid_ptr, FileSpec &local_file)
 {
     if (IsRemote())
     {
         if (m_remote_platform_sp)
-            return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file);
+            return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
     }
 
     // Default to the local case
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h
index a77780d..91010b9 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -73,8 +73,8 @@ namespace lldb_private {
         GetStatus (Stream &strm);
 
         virtual Error
-        GetFile (const FileSpec &platform_file,
-                 const UUID* uuid, FileSpec &local_file);
+        GetFileWithUUID (const FileSpec &platform_file,
+                         const UUID* uuid, FileSpec &local_file);
 
         virtual bool
         GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 9ffd68d..74b4f35 100644
--- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -249,7 +249,7 @@ PlatformMacOSX::GetSymbolFile (const FileSpec &platform_file,
     if (IsRemote())
     {
         if (m_remote_platform_sp)
-            return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file);
+            return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
     }
 
     // Default to the local case
@@ -258,9 +258,9 @@ PlatformMacOSX::GetSymbolFile (const FileSpec &platform_file,
 }
 
 lldb_private::Error
-PlatformMacOSX::GetFile (const lldb_private::FileSpec &platform_file,
-                         const lldb_private::UUID *uuid_ptr,
-                         lldb_private::FileSpec &local_file)
+PlatformMacOSX::GetFileWithUUID (const lldb_private::FileSpec &platform_file,
+                                 const lldb_private::UUID *uuid_ptr,
+                                 lldb_private::FileSpec &local_file)
 {
     if (IsRemote() && m_remote_platform_sp)
     {
diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
index 2354e6f..57e57e7 100644
--- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
+++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
@@ -87,9 +87,9 @@ public:
     }
     
     virtual lldb_private::Error
-    GetFile (const lldb_private::FileSpec &platform_file, 
-             const lldb_private::UUID *uuid_ptr,
-             lldb_private::FileSpec &local_file);
+    GetFileWithUUID (const lldb_private::FileSpec &platform_file, 
+                     const lldb_private::UUID *uuid_ptr,
+                     lldb_private::FileSpec &local_file);
     
     virtual bool
     GetSupportedArchitectureAtIndex (uint32_t idx, 
diff --git a/source/Plugins/Platform/Windows/PlatformWindows.cpp b/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 361e910..a362ffa 100644
--- a/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -542,14 +542,14 @@ PlatformWindows::GetGroupName (uint32_t gid)
 }
 
 Error
-PlatformWindows::GetFile (const FileSpec &platform_file,
-                          const UUID *uuid_ptr,
-                          FileSpec &local_file)
+PlatformWindows::GetFileWithUUID (const FileSpec &platform_file,
+                                  const UUID *uuid_ptr,
+                                  FileSpec &local_file)
 {
     if (IsRemote())
     {
         if (m_remote_platform_sp)
-            return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file);
+            return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
     }
 
     // Default to the local case
diff --git a/source/Plugins/Platform/Windows/PlatformWindows.h b/source/Plugins/Platform/Windows/PlatformWindows.h
index 67d3e88..7d3a167 100644
--- a/source/Plugins/Platform/Windows/PlatformWindows.h
+++ b/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -125,8 +125,8 @@ public:
            lldb_private::Error &error);
 
     virtual lldb_private::Error
-    GetFile(const lldb_private::FileSpec &platform_file,
-            const lldb_private::UUID* uuid, lldb_private::FileSpec &local_file);
+    GetFileWithUUID(const lldb_private::FileSpec &platform_file,
+                    const lldb_private::UUID* uuid, lldb_private::FileSpec &local_file);
 
     lldb_private::Error
     GetSharedModule(const lldb_private::ModuleSpec &module_spec,
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index cd2433d..80421ad 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -119,9 +119,9 @@ PlatformRemoteGDBServer::ResolveExecutable (const FileSpec &exe_file,
 }
 
 Error
-PlatformRemoteGDBServer::GetFile (const FileSpec &platform_file, 
-                                  const UUID *uuid_ptr,
-                                  FileSpec &local_file)
+PlatformRemoteGDBServer::GetFileWithUUID (const FileSpec &platform_file, 
+                                          const UUID *uuid_ptr,
+                                          FileSpec &local_file)
 {
     // Default to the local case
     local_file = platform_file;
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 808fb5e..91e1e7c 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -73,9 +73,9 @@ public:
     GetDescription ();
 
     virtual lldb_private::Error
-    GetFile (const lldb_private::FileSpec &platform_file, 
-             const lldb_private::UUID *uuid_ptr,
-             lldb_private::FileSpec &local_file);
+    GetFileWithUUID (const lldb_private::FileSpec &platform_file, 
+                     const lldb_private::UUID *uuid_ptr,
+                     lldb_private::FileSpec &local_file);
 
     virtual bool
     GetProcessInfo (lldb::pid_t pid, 
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
index fce995e..d6c580c 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -53,7 +53,7 @@ public:
     bool                ExtractValue(const lldb_private::DWARFDataExtractor& data,
                                      lldb::offset_t* offset_ptr,
                                      const DWARFCompileUnit* cu);
-    bool                IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (uint8_t*)m_value.value.cstr; }
+    bool                IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (const uint8_t*)m_value.value.cstr; }
     const uint8_t*      BlockData() const;
     uint64_t            Reference(const DWARFCompileUnit* cu) const;
     uint64_t            Reference (dw_offset_t offset) const;
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 66f9c0e..dc80b4a 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -81,9 +81,9 @@ Platform::SetDefaultPlatform (const lldb::PlatformSP &platform_sp)
 }
 
 Error
-Platform::GetFile (const FileSpec &platform_file, 
-                   const UUID *uuid_ptr,
-                   FileSpec &local_file)
+Platform::GetFileWithUUID (const FileSpec &platform_file, 
+                           const UUID *uuid_ptr,
+                           FileSpec &local_file)
 {
     // Default to the local case
     local_file = platform_file;
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index a34d53e..c53c1e3 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -1067,7 +1067,7 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
                 FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
                 FileSpec platform_dependent_file_spec;
                 if (m_platform_sp)
-                    m_platform_sp->GetFile (dependent_file_spec, NULL, platform_dependent_file_spec);
+                    m_platform_sp->GetFileWithUUID (dependent_file_spec, NULL, platform_dependent_file_spec);
                 else
                     platform_dependent_file_spec = dependent_file_spec;
 


More information about the lldb-dev mailing list