[all-commits] [llvm/llvm-project] 068da2: [clang-tidy] Allow `TransformerClangTidyCheck` cli...

Yitzhak Mandelbaum via All-commits all-commits at lists.llvm.org
Wed Nov 18 10:27:32 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 068da2c749a58b46bd59381890a6a137d6e3128e
      https://github.com/llvm/llvm-project/commit/068da2c749a58b46bd59381890a6a137d6e3128e
  Author: Yitzhak Mandelbaum <yitzhakm at google.com>
  Date:   2020-11-18 (Wed, 18 Nov 2020)

  Changed paths:
    M clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
    M clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h

  Log Message:
  -----------
  [clang-tidy] Allow `TransformerClangTidyCheck` clients to set the rule directly.

Adds support for setting the `Rule` field. In the process, refactors the code that accesses that field and adds a constructor that doesn't require a rule argument.

This feature is needed by checks that must set the rule *after* the check class
is constructed. For example, any check that maintains state to be accessed from
the rule needs this support. Since the object's fields are not initialized when
the superclass constructor is called, they can't be (safely) captured by a rule
passed to the existing constructor.  This patch allows constructing the check
superclass fully before setting the rule.

As a driveby fix, removed the "optional" from the rule, since rules are just a
set of cases, so empty rules are evident.

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




More information about the All-commits mailing list