Adding pre/post conditions for some Replacement handling functions
authorEdwin Vane <edwin.vane@intel.com>
Fri, 27 Sep 2013 17:52:45 +0000 (17:52 +0000)
committerEdwin Vane <edwin.vane@intel.com>
Fri, 27 Sep 2013 17:52:45 +0000 (17:52 +0000)
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

index 4868b5b..43ec9ac 100644 (file)
@@ -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<Replacement> &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<Replacement> &Replaces,
                  std::vector<Range> &Conflicts);