ki.stfu created this revision.
ki.stfu added reviewers: clayborg, jingham, zturner.
ki.stfu added a subscriber: lldb-commits.

It fixes the following compile warnings:
1. '0' flag ignored with precision and ‘%d’ gnu_printf format
2. enumeral and non-enumeral type in conditional expression
3. format ‘%d’ expects argument of type ‘int’, but argument 4 has type ...
4. enumeration value ‘...’ not handled in switch
5. cast from type ‘const uint64_t* {aka ...}’ to type ‘int64_t* {aka ...}’ 
casts away qualifiers
6. extra ‘;’
7. comparison between signed and unsigned integer expressions
8. variable ‘register_operand’ set but not used
9. control reaches end of non-void function

https://reviews.llvm.org/D24331

Files:
  source/Core/Log.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  source/Target/StackFrame.cpp

Index: source/Target/StackFrame.cpp
===================================================================
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -1279,6 +1279,9 @@
       return std::make_pair(nullptr, 0);
     }
   }
+  default:
+    // Make compiler happy with adding default case
+    return std::make_pair(nullptr, 0);
   }
 }
 
@@ -1292,7 +1295,7 @@
   }
   return std::make_pair(nullptr, 0);
 }
-};
+}
 
 lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) {
   TargetSP target_sp = CalculateTarget();
@@ -1421,7 +1424,7 @@
   Error error;
   ValueObjectSP pointee = base->Dereference(error);
 
-  if (offset >= pointee->GetByteSize()) {
+  if (offset > 0 && uint64_t(offset) >= pointee->GetByteSize()) {
     int64_t index = offset / pointee->GetByteSize();
     offset = offset % pointee->GetByteSize();
     const bool can_create = true;
@@ -1602,6 +1605,9 @@
       continue;
     }
 
+    // Ignore an unused-variable warning for a register operand.
+    (void)register_operand;
+
     // We have an origin operand.  Can we track its value down?
     switch (origin_operand->m_type) {
     default:
Index: source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===================================================================
--- source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -518,7 +518,7 @@
       // 0xffffffffffffffff. If we use the unsigned long long
       // it will work as expected.
       const uint64_t uval = PyLong_AsUnsignedLongLong(m_py_obj);
-      result = *((int64_t *)&uval);
+      result = *((const int64_t *)&uval);
     }
     return result;
   }
Index: source/Plugins/Process/minidump/MinidumpParser.cpp
===================================================================
--- source/Plugins/Process/minidump/MinidumpParser.cpp
+++ source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -138,6 +138,8 @@
   case MinidumpCPUArchitecture::ARM64:
     arch_spec.GetTriple().setArch(llvm::Triple::ArchType::aarch64);
     break;
+  default:
+    break;
   }
 
   return arch_spec;
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -3567,7 +3567,7 @@
     error.SetErrorStringWithFormat("configuring StructuredData feature %s "
                                    "failed when sending packet: "
                                    "PacketResult=%d",
-                                   type_name.AsCString(), result);
+                                   type_name.AsCString(), (int)result);
   }
   return error;
 }
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===================================================================
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -139,9 +139,9 @@
   // Keep a separate map of permissions that that isn't coalesced so all ranges
   // are maintained.
   const uint32_t permissions =
-      ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0) |
-      ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0) |
-      ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0);
+      ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0u) |
+      ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0u) |
+      ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0u);
 
   m_core_range_infos.Append(
       VMRangeToPermissions::Entry(addr, header->p_memsz, permissions));
Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1460,11 +1460,11 @@
           if (m_data.GetU32(&offset, &load_cmd.maxprot, 4)) {
             const uint32_t segment_permissions =
                 ((load_cmd.initprot & VM_PROT_READ) ? ePermissionsReadable
-                                                    : 0) |
+                                                    : 0u) |
                 ((load_cmd.initprot & VM_PROT_WRITE) ? ePermissionsWritable
-                                                     : 0) |
+                                                     : 0u) |
                 ((load_cmd.initprot & VM_PROT_EXECUTE) ? ePermissionsExecutable
-                                                       : 0);
+                                                       : 0u);
 
             const bool segment_is_encrypted =
                 (load_cmd.flags & SG_PROTECTED_VERSION_1) != 0;
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1938,9 +1938,9 @@
         sect_type = eSectionTypeGoSymtab;
 
       const uint32_t permissions =
-          ((header.sh_flags & SHF_ALLOC) ? ePermissionsReadable : 0) |
-          ((header.sh_flags & SHF_WRITE) ? ePermissionsWritable : 0) |
-          ((header.sh_flags & SHF_EXECINSTR) ? ePermissionsExecutable : 0);
+          ((header.sh_flags & SHF_ALLOC) ? ePermissionsReadable : 0u) |
+          ((header.sh_flags & SHF_WRITE) ? ePermissionsWritable : 0u) |
+          ((header.sh_flags & SHF_EXECINSTR) ? ePermissionsExecutable : 0u);
       switch (header.sh_type) {
       case SHT_SYMTAB:
         assert(sect_type == eSectionTypeOther);
Index: source/Core/Log.cpp
===================================================================
--- source/Core/Log.cpp
+++ source/Core/Log.cpp
@@ -82,7 +82,7 @@
     // Timestamp if requested
     if (m_options.Test(LLDB_LOG_OPTION_PREPEND_TIMESTAMP)) {
       TimeValue now = TimeValue::Now();
-      header.Printf("%9d.%09.9d ", now.seconds(), now.nanoseconds());
+      header.Printf("%9d.%9.9d ", now.seconds(), now.nanoseconds());
     }
 
     // Add the process and thread if requested
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to