[all-commits] [llvm/llvm-project] 3e0140: [analyzer] Improve underflow handling in ArrayBoundV2

DonatNagyE via All-commits all-commits at lists.llvm.org
Mon Aug 21 08:19:00 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3e014038b373e5a4a96d89d46cea17e4d2456a04
      https://github.com/llvm/llvm-project/commit/3e014038b373e5a4a96d89d46cea17e4d2456a04
  Author: DonĂ¡t Nagy <donat.nagy at ericsson.com>
  Date:   2023-08-21 (Mon, 21 Aug 2023)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
    M clang/test/Analysis/out-of-bounds.c

  Log Message:
  -----------
  [analyzer] Improve underflow handling in ArrayBoundV2

This minor change ensures that underflow errors are reported on memory
regions that are in unknown space but have a well-defined beginning.

As a concrete example, the following test case did not produce a warning
previously, but will produce a warning after this patch:

  typedef struct {
    int id;
    char name[256];
  } user_t;

  user_t *get_symbolic_user(void);
  char test_underflow_symbolic_2() {
    user_t *user = get_symbolic_user();
    return user->name[-1];
  }

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




More information about the All-commits mailing list