[all-commits] [llvm/llvm-project] 817f94: tsan: introduce New/Alloc/Free helpers

Dmitry Vyukov via All-commits all-commits at lists.llvm.org
Fri Jul 30 02:52:09 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 817f942a287725e758798f5b639e7ca1ccf0e83f
      https://github.com/llvm/llvm-project/commit/817f942a287725e758798f5b639e7ca1ccf0e83f
  Author: Dmitry Vyukov <dvyukov at google.com>
  Date:   2021-07-30 (Fri, 30 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/go/tsan_go.cpp
    M compiler-rt/lib/tsan/rtl/tsan_external.cpp
    M compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
    M compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
    M compiler-rt/lib/tsan/rtl/tsan_mman.cpp
    M compiler-rt/lib/tsan/rtl/tsan_mman.h
    M compiler-rt/lib/tsan/rtl/tsan_report.cpp
    M compiler-rt/lib/tsan/rtl/tsan_report.h
    M compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
    M compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
    M compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
    M compiler-rt/lib/tsan/rtl/tsan_stack_trace.cpp
    M compiler-rt/lib/tsan/rtl/tsan_symbolize.cpp
    M compiler-rt/lib/tsan/tests/unit/tsan_mman_test.cpp

  Log Message:
  -----------
  tsan: introduce New/Alloc/Free helpers

We frequenty allocate sizeof(T) memory and call T ctor on that memory
(C++ new keyword effectively). Currently it's quite verbose and
usually takes 2 lines of code.
Add New<T>() helper that does it much more concisely.

Rename internal_free to Free that also sets the pointer to nullptr.
Shorter and safer.

Rename internal_alloc to Alloc, just shorter.

Reviewed By: vitalybuka, melver

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




More information about the All-commits mailing list