[all-commits] [llvm/llvm-project] 43f433: [clang-tidy] Aliasing: Add support for captures.

NoQ via All-commits all-commits at lists.llvm.org
Mon May 10 14:00:55 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 43f4331edfb595979f6854351d24f9a9219595fa
      https://github.com/llvm/llvm-project/commit/43f4331edfb595979f6854351d24f9a9219595fa
  Author: Artem Dergachev <artem.dergachev at gmail.com>
  Date:   2021-05-10 (Mon, 10 May 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/utils/Aliasing.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

  Log Message:
  -----------
  [clang-tidy] Aliasing: Add support for captures.

The utility function clang::tidy::utils::hasPtrOrReferenceInFunc() scans the
function for pointer/reference aliases to a given variable. It currently scans
for operator & over that variable and for declarations of references to that
variable.

This patch makes it also scan for C++ lambda captures by reference
and for Objective-C block captures.

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


  Commit: 9b292e0edcd4e889dbcf4bbaad6c1cc80fffcfd1
      https://github.com/llvm/llvm-project/commit/9b292e0edcd4e889dbcf4bbaad6c1cc80fffcfd1
  Author: Artem Dergachev <artem.dergachev at gmail.com>
  Date:   2021-05-10 (Mon, 10 May 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/utils/Aliasing.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

  Log Message:
  -----------
  [clang-tidy] Aliasing: Add more support for captures.

D96215 takes care of the situation where the variable is captured into
a nearby lambda. This patch takes care of the situation where
the current function is the lambda and the variable is one of its captures
from an enclosing scope.

The analogous problem for ^{blocks} is already handled automagically
by D96215.

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


  Commit: 91ca3269a1b544db1303b496101fd9d6fe953277
      https://github.com/llvm/llvm-project/commit/91ca3269a1b544db1303b496101fd9d6fe953277
  Author: Artem Dergachev <artem.dergachev at gmail.com>
  Date:   2021-05-10 (Mon, 10 May 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/utils/Aliasing.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

  Log Message:
  -----------
  [clang-tidy] Aliasing: Add support for aggregates with references.

When a variable is used in an initializer of an aggregate
for its reference-type field this counts as aliasing.

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


Compare: https://github.com/llvm/llvm-project/compare/6a64c462eb82...91ca3269a1b5


More information about the All-commits mailing list