Index: include/clang/Tooling/ASTDiff/ASTDiff.h =================================================================== --- include/clang/Tooling/ASTDiff/ASTDiff.h +++ include/clang/Tooling/ASTDiff/ASTDiff.h @@ -36,6 +36,24 @@ using NodeRef = const Node &; +struct ComparisonOptions { + /// During top-down matching, only consider nodes of at least this height. + int MinHeight = 2; + + /// During bottom-up matching, match only nodes with at least this value as + /// the ratio of their common descendants. + double MinSimilarity = 0.5; + + /// Whenever two subtrees are matched in the bottom-up phase, the optimal + /// mapping is computed, unless the size of either subtrees exceeds this. + int MaxSize = 100; + + bool StopAfterTopDown = false; + + /// Returns false if the nodes should never be matched. + bool isMatchingAllowed(NodeRef N1, NodeRef N2) const; +}; + class ASTDiff { public: ASTDiff(SyntaxTree &Src, SyntaxTree &Dst, const ComparisonOptions &Options); @@ -123,26 +141,6 @@ bool operator!=(const NodeRefIterator &Other) const; }; -struct ComparisonOptions { - /// During top-down matching, only consider nodes of at least this height. - int MinHeight = 2; - - /// During bottom-up matching, match only nodes with at least this value as - /// the ratio of their common descendants. - double MinSimilarity = 0.5; - - /// Whenever two subtrees are matched in the bottom-up phase, the optimal - /// mapping is computed, unless the size of either subtrees exceeds this. - int MaxSize = 100; - - bool StopAfterTopDown = false; - - /// Returns false if the nodes should never be matched. - bool isMatchingAllowed(NodeRef N1, NodeRef N2) const { - return N1.getType().isSame(N2.getType()); - } -}; - } // end namespace diff } // end namespace clang Index: lib/Tooling/ASTDiff/ASTDiff.cpp =================================================================== --- lib/Tooling/ASTDiff/ASTDiff.cpp +++ lib/Tooling/ASTDiff/ASTDiff.cpp @@ -27,6 +27,10 @@ namespace clang { namespace diff { +bool ComparisonOptions::isMatchingAllowed(NodeRef N1, NodeRef N2) const { + return N1.getType().isSame(N2.getType()); +} + class ASTDiff::Impl { private: std::unique_ptr SrcToDst, DstToSrc;