[cfe-dev] Matching initializing operations inside a constructor

Manuel Klimek klimek at google.com
Sat Oct 5 06:40:46 PDT 2013


On Thu, Oct 3, 2013 at 12:45 PM, Daniel QuiƱones Lopez
<kaos09 at hotmail.com>wrote:

> Hello,
> I need to make a matcher that finds an initializing operation inside a
> constructor. In the following code is the underlined expression:
>
> class X {
>    int a;
>    X(int b) {*a=b;*}
> };
>
> What I have for now is the following matcher:
>
> DeclarationMatcher CID1_Matcher = constructorDecl(
>                   isDefinition(),
>                   forEachConstructorInitializer(
>
>
What you're trying to match is not a constructor initializer. It's an
assignment inside the definition of the constructor...

>                     (isWritten(),
>                     withInitializer(
>                       compoundStmt(
>                          binaryOperator(
>                             hasOperatorName("=")
>                          )
>                       ).bind("CID1")
>                     ))
>                   )
>                 );
>
>
> But it doesn't matches anything. What I'm doing wrong?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131005/3155a13f/attachment.html>


More information about the cfe-dev mailing list