[PATCH] D47944: Add support for arrays (and structure that use naked pointers for their iterator, like std::array) in performance-implicit-conversion-in-loop
Alex Pilkiewicz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 8 07:13:12 PDT 2018
pilki created this revision.
pilki added a reviewer: alexfh.
Herald added subscribers: cfe-commits, jkorous.
Add support for arrays (and structure that use naked pointers for their iterator, like std::array) in performance-implicit-conversion-in-loop.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D47944
Files:
clangd/CodeComplete.cpp
unittests/clangd/CodeCompleteTests.cpp
Index: unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -193,6 +193,7 @@
TEST(CompletionTest, Filter) {
std::string Body = R"cpp(
+ #define FooBarMacro
int Abracadabra;
int Alakazam;
struct S {
@@ -202,7 +203,8 @@
};
)cpp";
EXPECT_THAT(completions(Body + "int main() { S().Foba^ }").items,
- AllOf(Has("FooBar"), Has("FooBaz"), Not(Has("Qux"))));
+ AllOf(Has("FooBar"), Has("FooBaz"), Not(Has("FooBarMacro")),
+ Not(Has("Qux"))));
EXPECT_THAT(completions(Body + "int main() { S().FR^ }").items,
AllOf(Has("FooBar"), Not(Has("FooBaz")), Not(Has("Qux"))));
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1015,6 +1015,15 @@
return std::move(Top).items();
}
+ Optional<float> fuzzyScore(const CompletionCandidate &C) {
+ // Macros can be very spammy, so we only support prefix completion.
+ // We won't end up with underfull index results, as macros are sema-only.
+ if (C.SemaResult && C.SemaResult->Kind == CodeCompletionResult::RK_Macro &&
+ !C.Name.startswith_lower(Filter->pattern()))
+ return None;
+ return Filter->match(C.Name);
+ }
+
// Scores a candidate and adds it to the TopN structure.
void addCandidate(TopN<ScoredCandidate, ScoredCandidateGreater> &Candidates,
const CodeCompletionResult *SemaResult,
@@ -1027,7 +1036,7 @@
SymbolQualitySignals Quality;
SymbolRelevanceSignals Relevance;
Relevance.Query = SymbolRelevanceSignals::CodeComplete;
- if (auto FuzzyScore = Filter->match(C.Name))
+ if (auto FuzzyScore = fuzzyScore(C))
Relevance.NameMatch = *FuzzyScore;
else
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47944.150513.patch
Type: text/x-patch
Size: 1951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180608/3a6ccf51/attachment.bin>
More information about the cfe-commits
mailing list