r261574 - [ASTMatchers] Add matcher hasAnyName.

Samuel Benzaquen via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 14:46:12 PST 2016


On Mon, Feb 22, 2016 at 5:27 PM, Hans Wennborg <hans at chromium.org> wrote:

> On Mon, Feb 22, 2016 at 1:13 PM, Samuel Benzaquen via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: sbenza
> > Date: Mon Feb 22 15:13:02 2016
> > New Revision: 261574
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=261574&view=rev
> > Log:
> > [ASTMatchers] Add matcher hasAnyName.
> >
> > Summary: Add matcher hasAnyName as an optimization over
> anyOf(hasName(),...)
> >
> > Reviewers: alexfh
> >
> > Subscribers: klimek, cfe-commits
> >
> > Differential Revision: http://reviews.llvm.org/D17163
>
> I've tried to fix the Visual Studio build in r261583. Please take a
> look to make sure the fixes seem reasonable.
>

Sorry about that. I always forget that we can't use brace init lists in
LLVM yet.
Yes. That fix is correct. It would be better to move the vector to avoid an
extra copy.


>
>
> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 22
> 15:13:02 2016
> > @@ -1844,11 +1844,24 @@ inline internal::Matcher<Stmt> sizeOfExp
> >  /// \code
> >  ///   namespace a { namespace b { class X; } }
> >  /// \endcode
> > -inline internal::Matcher<NamedDecl> hasName(std::string Name) {
> > -  return internal::Matcher<NamedDecl>(
> > -      new internal::HasNameMatcher(std::move(Name)));
> > +inline internal::Matcher<NamedDecl> hasName(const std::string &Name) {
> > +  return internal::Matcher<NamedDecl>(new
> internal::HasNameMatcher({Name}));
>
> That doesn't compile with Visual Studio 2013:
>
>
> C:\b\build\slave\ClangToTWin\build\src\third_party\llvm\tools\clang\include\clang/ASTMatchers/ASTMatchers.h(1848)
> : error C2440: 'initializing' : cannot convert from 'initializer-list'
> to 'clang::ast_matchers::internal::HasNameMatcher'
>         Constructor for class
> 'clang::ast_matchers::internal::HasNameMatcher' is declared 'explicit'
>
> > +private:
> > +  struct Pattern {
> > +    StringRef Pattern;
>
>
> C:\b\build\slave\ClangToTWin\build\src\third_party\llvm\tools\clang\lib\ASTMatchers\ASTMatchersInternal.cpp(394)
> : error C2380: type(s) preceding 'Pattern' (constructor with return
> type, or illegal redefinition of current class-name?)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160222/3dce99d5/attachment.html>


More information about the cfe-commits mailing list