On 1 December 2016 at 16:42, Mads Ravn <madsr...@gmail.com> wrote: > I have now implemented your suggestions - all but the fixit one. If I have > added bindings for str1 and str2 in ast matcher, how would I go about > creating a replacement for the entire implicitCastExpr or binaryOperator? I > can't find any example in the code for clang-tidy to suggest how I would > build a new node for the AST. Or I am looking at it from a wrong direction?
You create insertions, removals and replacements that affect the source code. The AST is not changed. Fix-it hints are documented here: http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints Source locations and ranges are documented here: http://clang.llvm.org/docs/InternalsManual.html#sourcelocation To turn str1.compare(str2) into str1 == str2 you need to replace ".compare(" with " == " and remove ")". You can get the SourceLocation of the . by calling getOperatorLoc() on the MemberExpr. You can tell if you have a . or an -> by calling isArrow() on the MemberExpr. You can get the SourceLocation of the ) by calling getRParenLoc() on the CXXMemberCallExpr. -- Malcolm Parsons _______________________________________________ cfe-commits mailing list firstname.lastname@example.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits