[Lldb-commits] [lldb] r286093 - [lldb] Fix -Waggressive-loop-optimizations warning

Vedant Kumar via lldb-commits lldb-commits at lists.llvm.org
Sun Nov 6 18:39:37 PST 2016


Author: vedantk
Date: Sun Nov  6 20:39:37 2016
New Revision: 286093

URL: http://llvm.org/viewvc/llvm-project?rev=286093&view=rev
Log:
[lldb] Fix -Waggressive-loop-optimizations warning

We shouldn't access past the end of an array, even if we think that the
layout of the struct containing the array is always what we expect. The
compiler is free to optimize away the stores as undefined behavior, and
in fact, GCC 6.2.1 claims it will do exactly this.

Modified:
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=286093&r1=286092&r2=286093&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Sun Nov  6 20:39:37 2016
@@ -667,8 +667,12 @@ public:
         // x0-x29 + fp + lr + sp + pc (== 33 64-bit registers) plus cpsr (1
         // 32-bit register)
         if (count >= (33 * 2) + 1) {
-          for (uint32_t i = 0; i < 33; ++i)
+          for (uint32_t i = 0; i < 29; ++i)
             gpr.x[i] = data.GetU64(&offset);
+          gpr.fp = data.GetU64(&offset);
+          gpr.lr = data.GetU64(&offset);
+          gpr.sp = data.GetU64(&offset);
+          gpr.pc = data.GetU64(&offset);
           gpr.cpsr = data.GetU32(&offset);
           SetError(GPRRegSet, Read, 0);
         }




More information about the lldb-commits mailing list