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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to