From 88ef9ad84e9c1cb55d4953afb4fd82f0a9dae65f Mon Sep 17 00:00:00 2001 From: Edwin Vane Date: Fri, 27 Sep 2013 17:52:45 +0000 Subject: [PATCH] Adding pre/post conditions for some Replacement handling functions The vector version of shiftedCodePosition() requires Replacements to be in sorted order. Turned existing comment about sorting for deduplicate() into an exact post condition. llvm-svn: 191536 --- clang/include/clang/Tooling/Refactoring.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Tooling/Refactoring.h b/clang/include/clang/Tooling/Refactoring.h index 4868b5bfc4f5..43ec9acdb3bf 100644 --- a/clang/include/clang/Tooling/Refactoring.h +++ b/clang/include/clang/Tooling/Refactoring.h @@ -164,14 +164,18 @@ unsigned shiftedCodePosition(const Replacements& Replaces, unsigned Position); /// \brief Calculates how a code \p Position is shifted when \p Replaces are /// applied. +/// +/// \pre Replaces[i].getOffset() <= Replaces[i+1].getOffset(). unsigned shiftedCodePosition(const std::vector &Replaces, unsigned Position); /// \brief Removes duplicate Replacements and reports if Replacements conflict /// with one another. /// -/// This function will sort \p Replaces so that conflicts can be reported simply -/// by offset into \p Replaces and number of elements in the conflict. +/// \post Replaces[i].getOffset() <= Replaces[i+1].getOffset(). +/// +/// This function sorts \p Replaces so that conflicts can be reported simply by +/// offset into \p Replaces and number of elements in the conflict. void deduplicate(std::vector &Replaces, std::vector &Conflicts);