aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2019-02-02 10:35:39 +0000
committerEric Liu <ioeric@google.com>2019-02-02 10:35:39 +0000
commit2a24769502cdd179f17d94fd650299bfd0e3d56b (patch)
tree2e5c7ad94512373f33f4c7aaa8b411f5faa72c4e
parentb5ed3914b4b13626cbbf7fda55e99c88a3c29b27 (diff)
downloadclang-tools-extra-2a24769502cdd179f17d94fd650299bfd0e3d56b.tar.gz
[clangd] Fix heap-use-after-free after r352868
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@352957 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--unittests/clangd/QualityTests.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/unittests/clangd/QualityTests.cpp b/unittests/clangd/QualityTests.cpp
index 5ae6dd57..e2fe8f3a 100644
--- a/unittests/clangd/QualityTests.cpp
+++ b/unittests/clangd/QualityTests.cpp
@@ -180,14 +180,17 @@ TEST(QualityTests, SymbolRelevanceSignalExtraction) {
EXPECT_TRUE(Relevance.InBaseClass);
auto Index = Test.index();
- Symbol X;
FuzzyFindRequest Req;
Req.Query = "X";
Req.AnyScope = true;
- Index->fuzzyFind(Req, [&X](const Symbol& S){ X = S; });
- Relevance = {};
- Relevance.merge(X);
- EXPECT_EQ(Relevance.Scope, SymbolRelevanceSignals::FileScope);
+ bool Matched = false;
+ Index->fuzzyFind(Req, [&](const Symbol &S) {
+ Matched = true;
+ Relevance = {};
+ Relevance.merge(S);
+ EXPECT_EQ(Relevance.Scope, SymbolRelevanceSignals::FileScope);
+ });
+ EXPECT_TRUE(Matched);
}
// Do the signals move the scores in the direction we expect?