r318286 - [clang] Expose orderedString from CodeCompletionResult. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 15 01:15:06 PST 2017
Author: sammccall
Date: Wed Nov 15 01:15:06 2017
New Revision: 318286
URL: http://llvm.org/viewvc/llvm-project?rev=318286&view=rev
Log:
[clang] Expose orderedString from CodeCompletionResult. NFC
Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=318286&r1=318285&r2=318286&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Wed Nov 15 01:15:06 2017
@@ -777,6 +777,12 @@ public:
CodeCompletionTUInfo &CCTUInfo,
bool IncludeBriefComments);
+ /// \brief Retrieve the name that should be used to order a result.
+ ///
+ /// If the name needs to be constructed as a string, that string will be
+ /// saved into Saved and the returned StringRef will refer to it.
+ StringRef getOrderedName(std::string &Saved) const;
+
private:
void computeCursorKindAndAvailability(bool Accessible = true);
};
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=318286&r1=318285&r2=318286&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Nov 15 01:15:06 2017
@@ -613,24 +613,20 @@ void CodeCompletionResult::computeCursor
///
/// If the name needs to be constructed as a string, that string will be
/// saved into Saved and the returned StringRef will refer to it.
-static StringRef getOrderedName(const CodeCompletionResult &R,
- std::string &Saved) {
- switch (R.Kind) {
- case CodeCompletionResult::RK_Keyword:
- return R.Keyword;
-
- case CodeCompletionResult::RK_Pattern:
- return R.Pattern->getTypedText();
-
- case CodeCompletionResult::RK_Macro:
- return R.Macro->getName();
-
- case CodeCompletionResult::RK_Declaration:
+StringRef CodeCompletionResult::getOrderedName(std::string &Saved) const {
+ switch (Kind) {
+ case RK_Keyword:
+ return Keyword;
+ case RK_Pattern:
+ return Pattern->getTypedText();
+ case RK_Macro:
+ return Macro->getName();
+ case RK_Declaration:
// Handle declarations below.
break;
}
- DeclarationName Name = R.Declaration->getDeclName();
+ DeclarationName Name = Declaration->getDeclName();
// If the name is a simple identifier (by far the common case), or a
// zero-argument selector, just return a reference to that identifier.
@@ -648,8 +644,8 @@ static StringRef getOrderedName(const Co
bool clang::operator<(const CodeCompletionResult &X,
const CodeCompletionResult &Y) {
std::string XSaved, YSaved;
- StringRef XStr = getOrderedName(X, XSaved);
- StringRef YStr = getOrderedName(Y, YSaved);
+ StringRef XStr = X.getOrderedName(XSaved);
+ StringRef YStr = Y.getOrderedName(YSaved);
int cmp = XStr.compare_lower(YStr);
if (cmp)
return cmp < 0;
More information about the cfe-commits
mailing list