]> granicus.if.org Git - clang/commitdiff
[clang] Expose orderedString from CodeCompletionResult. NFC
authorSam McCall <sam.mccall@gmail.com>
Wed, 15 Nov 2017 09:15:06 +0000 (09:15 +0000)
committerSam McCall <sam.mccall@gmail.com>
Wed, 15 Nov 2017 09:15:06 +0000 (09:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318286 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/CodeCompleteConsumer.h
lib/Sema/CodeCompleteConsumer.cpp

index dee53dc14a8caf6c95c4116f5ca2cfdca1ba2f52..d99d8c5867bcf0d087d41f85c99c321771626514 100644 (file)
@@ -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);
 };
index f5b0104462f7864cef3586b7d8be165910c087cd..542b65327b7d2668dc65ce5faaba5ccb32494043 100644 (file)
@@ -613,24 +613,20 @@ void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) {
 ///
 /// 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 CodeCompletionResult &R,
 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;