[all-commits] [llvm/llvm-project] 7b90cd: [lldb/DataExtractor] Fix UB shift in GetMaxS64Bitf...

Vedant Kumar via All-commits all-commits at lists.llvm.org
Mon Feb 3 15:57:49 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7b90cdedd1d3f743eeb2b7654d65386672d0f1a9
      https://github.com/llvm/llvm-project/commit/7b90cdedd1d3f743eeb2b7654d65386672d0f1a9
  Author: Vedant Kumar <vsk at apple.com>
  Date:   2020-02-03 (Mon, 03 Feb 2020)

  Changed paths:
    M lldb/include/lldb/Utility/DataExtractor.h
    M lldb/source/Utility/DataExtractor.cpp
    M lldb/unittests/Utility/DataExtractorTest.cpp

  Log Message:
  -----------
  [lldb/DataExtractor] Fix UB shift in GetMaxS64Bitfield

DataExtractor::GetMaxS64Bitfield performs a shift with UB in order to
construct a bitmask when bitfield_bit_size is 64. The current
implementation actually does “work” in this case, because the assumption
that the shift result is 0 holds, and 0 minus 1 gives the all-ones value
(the correct mask). However, the more readable/maintainable approach
might be to use an off-the-shelf UB-free helper.

Fixes a UBSan issue:

  "col" : 37,
  "description" : "invalid-shift-exponent",
  "filename" : "/Users/vsk/src/llvm-project-master/lldb/source/Utility/DataExtractor.cpp",
  "instrumentation_class" : "UndefinedBehaviorSanitizer",
  "line" : 615,
  "memory_address" : 0,
  "summary" : "Shift exponent 64 is too large for 64-bit type 'uint64_t' (aka 'unsigned long long')",

rdar://59117758

Differential Revision: https://reviews.llvm.org/D73913


  Commit: bb6646ce0a2e59eda682f63696915d2dc7db40db
      https://github.com/llvm/llvm-project/commit/bb6646ce0a2e59eda682f63696915d2dc7db40db
  Author: Vedant Kumar <vsk at apple.com>
  Date:   2020-02-03 (Mon, 03 Feb 2020)

  Changed paths:
    M lldb/source/Utility/DataExtractor.cpp

  Log Message:
  -----------
  [lldb/DataExtractor] Use an early return in GetMaxS64Bitfield, NFC

Shafik suggested this cleanup in https://reviews.llvm.org/D73913.


  Commit: 63e65082219983f1dba4faf273bad311715da14e
      https://github.com/llvm/llvm-project/commit/63e65082219983f1dba4faf273bad311715da14e
  Author: Vedant Kumar <vsk at apple.com>
  Date:   2020-02-03 (Mon, 03 Feb 2020)

  Changed paths:
    M lldb/include/lldb/DataFormatters/StringPrinter.h
    M lldb/source/DataFormatters/StringPrinter.cpp

  Log Message:
  -----------
  [lldb/StringPrinter] Simplify StringPrinterBufferPointer, NFC

Remove its template arguments and delete its copy/assign methods.


Compare: https://github.com/llvm/llvm-project/compare/ac430336318a...63e650822199


More information about the All-commits mailing list