[PATCH] D159436: [clang-tidy] Add support for optional parameters in config.

FĂ©lix-Antoine Constantin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 20:11:09 PDT 2023


felix642 added a comment.

Hi @PiotrZSL and @carlosgalvezp, I have updated my PR based on your comments. Let me know what you think.

  What if:
  
  "MinimumLength" is a boolean.
  It's default value (if not specified) is True.
  And a user wants to set it as "False" here
  
  Wouldn't that cause problems?

I have removed the "false" option to support optional for boolean types.

  this functionality should work only for integers...
  Idea is to have:
  
  template <typename T>
  std::enable_if_t<std::is_integral_v<T>, std::optional<T>>
  getLocalOrGlobal(StringRef LocalName, std::optional<T> Default) const;
  
   template <typename T>
   std::enable_if_t<std::is_integral_v<T>, std::optional<T>>
   get(StringRef LocalName, std::optional<T> Default) const;
  
  without impacting other functions... so that instead of doing tricks with -1 in code, we could simply create real optional options, and be able to 'store' them as optional, this mean that --dump-config should dump them as "none".

I have moved the declaration to a new method which works only on integral types where the default value is std::optional. Let me know what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159436



More information about the cfe-commits mailing list