r235286 - Fix bug in Replacement's toString on Windows (missing flush).

Will Wilson will at indefiant.com
Mon Apr 20 07:34:18 PDT 2015


Minor nit: Couldn't you just scope the ostream & move the stack allocated
string rather than allocating a new one from the std::string reference
returned by str()?

On 20 April 2015 at 07:58, Manuel Klimek <klimek at google.com> wrote:

> Author: klimek
> Date: Mon Apr 20 01:58:56 2015
> New Revision: 235286
>
> URL: http://llvm.org/viewvc/llvm-project?rev=235286&view=rev
> Log:
> Fix bug in Replacement's toString on Windows (missing flush).
>
> Adapt function to LLVM coding style.
>
> Modified:
>     cfe/trunk/lib/Tooling/Core/Replacement.cpp
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=235286&r1=235285&r2=235286&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Apr 20 01:58:56 2015
> @@ -77,11 +77,11 @@ bool Replacement::apply(Rewriter &Rewrit
>  }
>
>  std::string Replacement::toString() const {
> -  std::string result;
> -  llvm::raw_string_ostream stream(result);
> -  stream << FilePath << ": " << ReplacementRange.getOffset() << ":+"
> +  std::string Result;
> +  llvm::raw_string_ostream Stream(Result);
> +  Stream << FilePath << ": " << ReplacementRange.getOffset() << ":+"
>           << ReplacementRange.getLength() << ":\"" << ReplacementText <<
> "\"";
> -  return result;
> +  return Stream.str();
>  }
>
>  bool operator<(const Replacement &LHS, const Replacement &RHS) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



-- 
*Indefiant *: http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150420/4ece1f5e/attachment.html>


More information about the cfe-commits mailing list