On Sat, 2019-01-19 at 20:32 +0100, Miguel Ojeda wrote:
> Hi Joe,
> 
> On Sat, Jan 19, 2019 at 8:06 PM Joe Perches <[email protected]> wrote:
> > This misses all the directory/file specific #defines
> > outside of include/ with for_each
> 
> Indeed, the command only searches the include/ directory, but when
> searching for the entire tree, it returns ~500 more entries (vs. the
> ~300 original ones). I cannot recall if there was a reason to search
> only inside include/, though.
> 
> > $ git grep "#define.*for_each" | grep -v '^include' | wc -l
> > 619
> > 
> > Is it possible to make this generic somehow instead?
> > Perhaps extend .clang_format with regexes?
> > 
> > (?:[a-z0-9_]+_)?for_each(?:_[a-z_]+)
> > [a-z0-9_]+_for_each
> 
> What do you mean?

Documentation for .clang-format shows
https://clang.llvm.org/docs/ClangFormatStyleOptions.html

   ForEachMacros (std::vector<std::string>)

       A vector of macros that should be interpreted as foreach loops instead 
of as function calls.

       These are expected to be macros of the form:

       FOREACH(<variable-declaration>, ...)
         <loop-body>

       In the .clang-format configuration file, this can be configured like:

       ForEachMacros: ['RANGES_FOR', 'FOREACH']

       For example: BOOST_FOREACH.

I suggest clang-format's ForEachMacros statement vector
be expanded to support regexes ala

ForEachMacros:
  - Regex:           
'\b(?:(?:[a-z0-9_]+_)?for_each(?:_[a-z_]+)|[a-z0-9_]+_for_each)\b'


Reply via email to