[all-commits] [llvm/llvm-project] dfc1e3: Produce warning for performing pointer arithmetic ...

jamieschmeiser via All-commits all-commits at lists.llvm.org
Tue May 11 08:31:22 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dfc1e31d49fe1380c9bab43373995df5fed15e6d
      https://github.com/llvm/llvm-project/commit/dfc1e31d49fe1380c9bab43373995df5fed15e6d
  Author: Jamie Schmeiser <schmeise at ca.ibm.com>
  Date:   2021-05-11 (Tue, 11 May 2021)

  Changed paths:
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/Sema/pointer-addition.c
    A clang/test/Sema/pointer-addition.cpp

  Log Message:
  -----------
  Produce warning for performing pointer arithmetic on a null pointer.

Summary:
Test and produce warning for subtracting a pointer from null or subtracting
null from a pointer.  Reuse existing warning that this is undefined
behaviour.  Also add unit test for both warnings.

Reformat to satisfy clang-format.

Respond to review comments:  add additional test.

Respond to review comments:  Do not issue warning for nullptr - nullptr
in C++.

Fix indenting to satisfy clang-format.

Respond to review comments:  Add C++ tests.

Author: Jamie Schmeiser <schmeise at ca.ibm.com>
Reviewed By: efriedma (Eli Friedman), nickdesaulniers (Nick Desaulniers)
Differential Revision: https://reviews.llvm.org/D98798




More information about the All-commits mailing list