[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

Douglas Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 8 09:05:40 PDT 2021


dougpuob added a comment.

Hi @njames93

I tried to create a class, `HungarianNotation`, and put all related functions into the class. Then I can call `configurationDiag()` in `HungarianNotation::checkOptionValid()` function.
How about this way?

The new class.

  struct HungarianNotation {
  public:
    HungarianNotation(ClangTidyContext *Context = nullptr);
  
    bool checkOptionValid(int StyleKindIndex, StringRef StyleString,
                          bool HasValue);
    ...

Use the configurationDiag() in checkOptionValid() function

  bool HungarianNotation::checkOptionValid(int StyleKindIndex,
                                           StringRef StyleString, bool HasValue) {
    ..
    if (HasValue)
      Context->configurationDiag("invalid identifier naming option '%0'")
          << StyleString;
  
    return false;
  }

Call the checkOptionValid() here in getFileStyleFromOptions().

  static IdentifierNamingCheck::FileStyle
  getFileStyleFromOptions(const ClangTidyCheck::OptionsView &Options,
                          ClangTidyContext &Context) {
      ...
      StyleString.append("HungarianPrefix");
      auto HPTOpt =
          Options.get<IdentifierNamingCheck::HungarianPrefixType>(StyleString);
      HN.checkOptionValid(I, StyleString, HPTOpt.hasValue());
      ...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86671/new/

https://reviews.llvm.org/D86671



More information about the cfe-commits mailing list