From e9a88b6178d3a30123394d1fef6b51140f79d03a Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Tue, 21 Feb 2023 03:22:59 -0500 Subject: [PATCH] [clangd] Fix a bug in TweakTest::decorate() The second argument to string::substr() is a count, not an end position. Differential Revision: https://reviews.llvm.org/D144453 --- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp b/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp index ee93436..51071d8 100644 --- a/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp +++ b/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp @@ -157,7 +157,8 @@ std::string TweakTest::decorate(llvm::StringRef Code, unsigned Point) { std::string TweakTest::decorate(llvm::StringRef Code, llvm::Annotations::Range Range) { return (Code.substr(0, Range.Begin) + "[[" + - Code.substr(Range.Begin, Range.End) + "]]" + Code.substr(Range.End)) + Code.substr(Range.Begin, Range.End - Range.Begin) + "]]" + + Code.substr(Range.End)) .str(); } -- 2.7.4