[cfe-dev] clang-tidy Negative Lookahead Support

Samuel Baxter via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 20 11:41:13 PST 2015


Hi all,

I wanted to gauge interest in a patch that would allow clang-tidy's
-header-filter option to accept std::regex expressions instead of its
current support of only the llvm::Regex.  I've been using this in a local
build of clang-tidy recently and have a patch ready to submit if people are
interested.

*Pros:*
    This would allow negative lookahead in -header-filter regular
expressions (something llvm::Regex doesn't support).  For example, I've
been working in a large repository with lots of subdirs/submodules,
including a ThirdPartyLibs subdir where we check in SHAs of all third
party, open source code we are using.  It's nice to be able to pass the
negative lookahead regex:

^(?!.*ThirdPartyLibs.*).*$

and filter out all third party headers when running clang-tidy.
    Other command line options (files, -checks, maybe others) accept glob
filters, which allow for negation, and this comes in handy.  I think we
should be consistent in allowing negation of some form in all filter
options. I can try to re-implement this with a glob filter if that's
preferable.

*Cons:*
    Some compilers may not support std::regex.  I'm not sure when that was
introduced in various compilers, or if clang still supports building on
those compilers. Any other drawbacks I'm not thinking off?

Let me know what you all think!
- Sam Baxter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151120/8ac19128/attachment.html>


More information about the cfe-dev mailing list