[Lldb-commits] [lldb] r362570 - Fix -Wsign-compare by explicit cast after r362557

Shafik Yaghmour via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 5 12:23:55 PDT 2019


abs(offset) is not the same as addr_t(-offset) AFAICT offset is positive so we are casting a small negative number to an unsigned type which will result in a really large value e.g. https://godbolt.org/z/B2Z7Ok

> On Jun 4, 2019, at 6:49 PM, Fangrui Song via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: maskray
> Date: Tue Jun  4 18:49:06 2019
> New Revision: 362570
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=362570&view=rev
> Log:
> Fix -Wsign-compare by explicit cast after r362557
> 
> Modified:
>    lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
> 
> Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp?rev=362570&r1=362569&r2=362570&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp (original)
> +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp Tue Jun  4 18:49:06 2019
> @@ -819,7 +819,7 @@ bool x86AssemblyInspectionEngine::local_
>   int offset;
>   if (pc_rel_branch_or_jump_p (instruction_length, offset) && offset != 0) {
>     addr_t next_pc_value = current_func_text_offset + instruction_length;
> -    if (offset < 0 && abs (offset) > current_func_text_offset) {
> +    if (offset < 0 && addr_t(-offset) > current_func_text_offset) {
>       // Branch target is before the start of this function
>       return false;
>     }
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list