[cfe-dev] Matching assigment operations on a class attribute

Daniel QuiƱones Lopez kaos09 at hotmail.com
Wed Oct 9 04:29:52 PDT 2013


Hello, i'm trying to match assigment operations on a class attribute inside a class constructor. I'm doing the following:

DeclarationMatcher CID_Matcher =  constructorDecl(
                                                              isDefinition(),
                                                                 has(
                                                                    compoundStmt(
                                                                       forEach(
                                                                          stmt(
                                                                             binaryOperator(
                                                                                isAssignmentOp(),
                                                                                 hasLHS(
                                                                                    declRefExpr(to(fieldDecl()))
                                                                                 )
                                                                              )
                                                                          ).bind("CID1")
                                                                        )
                                                                      )
                                                                   )
                                                                );

Being the left operand of the assignment a class attribute and isAssigmentOp() defined as follows:

AST_MATCHER(clang::BinaryOperator, isAssignmentOp) {
        return Node.isAssignmentOp();
      }

The problem is that it doesn't match anything this way, but if i left "declRefExpr()" without nothing within it, it only matches variables which were declared inside the constructor, instead of the attributes. So my question is about how is supposed to work "declRefExpr()", beacuse in the AST_MATCHER reference it doesn't give much information, or if it is another way to do this. 
Thank you.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131009/c583991a/attachment.html>


More information about the cfe-dev mailing list