[cfe-commits] r112161 - in /cfe/trunk: include/clang-c/Index.h lib/Frontend/ASTUnit.cpp lib/Sema/CodeCompleteConsumer.cpp lib/Sema/SemaCodeComplete.cpp tools/c-index-test/c-index-test.c tools/libclang/CIndexCodeCompletion.cpp tools/libclang/libclang.darwin.exports tools/libclang/libclang.exports
Daniel Dunbar
daniel at zuster.org
Wed Aug 25 20:53:50 PDT 2010
Author: ddunbar
Date: Wed Aug 25 22:53:50 2010
New Revision: 112161
URL: http://llvm.org/viewvc/llvm-project?rev=112161&view=rev
Log:
Revert r112149, "Move the sorting of code-completion results out of the main
path and ...", it is failing tests.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/libclang.darwin.exports
cfe/trunk/tools/libclang/libclang.exports
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Aug 25 22:53:50 2010
@@ -2350,17 +2350,6 @@
unsigned options);
/**
- * \brief Sort the code-completion results in case-insensitive alphabetical
- * order.
- *
- * \param Results The set of results to sort.
- * \param NumResults The number of results in \p Results.
- */
-CINDEX_LINKAGE
-void clang_sortCodeCompletionResults(CXCompletionResult *Results,
- unsigned NumResults);
-
-/**
* \brief Free the given set of code-completion results.
*/
CINDEX_LINKAGE
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Aug 25 22:53:50 2010
@@ -1678,7 +1678,9 @@
Next.ProcessCodeCompleteResults(S, Context, Results, NumResults);
return;
}
-
+
+ // Sort the completion results before passing them on to the actual consumer.
+ std::stable_sort(AllResults.begin(), AllResults.end());
Next.ProcessCodeCompleteResults(S, Context, AllResults.data(),
AllResults.size());
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Aug 25 22:53:50 2010
@@ -443,8 +443,6 @@
CodeCompletionContext Context,
CodeCompletionResult *Results,
unsigned NumResults) {
- std::stable_sort(Results, Results + NumResults);
-
// Print the results.
for (unsigned I = 0; I != NumResults; ++I) {
OS << "COMPLETION: ";
@@ -662,11 +660,6 @@
if (cmp)
return cmp < 0;
- // If case-insensitive comparison fails, try case-sensitive comparison.
- cmp = XStr.compare(YStr);
- if (cmp)
- return cmp < 0;
-
// Non-hidden names precede hidden names.
if (X.Hidden != Y.Hidden)
return !X.Hidden;
@@ -702,7 +695,7 @@
unsigned NumCandidates) {
for (unsigned I = 0; I != NumCandidates; ++I) {
WriteUnsigned(OS, CXCursor_NotImplemented);
- WriteUnsigned(OS, /*Priority=*/I);
+ WriteUnsigned(OS, /*Priority=*/0);
WriteUnsigned(OS, /*Availability=*/CXAvailability_Available);
CodeCompletionString *CCS
= Candidates[I].CreateSignatureString(CurrentArg, SemaRef);
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Aug 25 22:53:50 2010
@@ -2277,6 +2277,8 @@
CodeCompletionContext Context,
CodeCompletionResult *Results,
unsigned NumResults) {
+ std::stable_sort(Results, Results + NumResults);
+
if (CodeCompleter)
CodeCompleter->ProcessCodeCompleteResults(*S, Context, Results, NumResults);
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Aug 25 22:53:50 2010
@@ -1,7 +1,6 @@
/* c-index-test.c */
#include "clang-c/Index.h"
-#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -904,25 +903,6 @@
fprintf(file, "\n");
}
-int my_stricmp(const char *s1, const char *s2) {
- while (*s1 && *s2) {
- int c1 = tolower(*s1), c2 = tolower(*s2);
- if (c1 < c2)
- return -1;
- else if (c1 > c2)
- return 1;
-
- ++s1;
- ++s2;
- }
-
- if (*s1)
- return 1;
- else if (*s2)
- return -1;
- return 0;
-}
-
int perform_code_completion(int argc, const char **argv, int timing_only) {
const char *input = argv[1];
char *filename = 0;
@@ -978,13 +958,9 @@
if (results) {
unsigned i, n = results->NumResults;
- if (!timing_only) {
- /* Sort the code-completion results based on the typed text. */
- clang_sortCodeCompletionResults(results->Results, results->NumResults);
-
+ if (!timing_only)
for (i = 0; i != n; ++i)
print_completion_result(results->Results + i, stdout);
- }
n = clang_codeCompleteGetNumDiagnostics(results);
for (i = 0; i != n; ++i) {
CXDiagnostic diag = clang_codeCompleteGetDiagnostic(results, i);
Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Wed Aug 25 22:53:50 2010
@@ -582,8 +582,6 @@
AllocatedResults.Results[I].CompletionString = StoredCompletion;
}
}
-
- // FIXME: Add ProcessOverloadCandidates?
};
}
@@ -786,36 +784,3 @@
} // end extern "C"
-
-namespace {
- struct OrderCompletionResults {
- bool operator()(const CXCompletionResult &XR,
- const CXCompletionResult &YR) const {
- CXStoredCodeCompletionString *X
- = (CXStoredCodeCompletionString *)XR.CompletionString;
- CXStoredCodeCompletionString *Y
- = (CXStoredCodeCompletionString *)YR.CompletionString;
-
- const char *XText = X->getTypedText();
- const char *YText = Y->getTypedText();
- if (!XText || !YText)
- return XText != 0;
-
- int result = llvm::StringRef(XText).compare_lower(YText);
- if (result < 0)
- return true;
- if (result > 0)
- return false;
-
- result = llvm::StringRef(XText).compare(YText);
- return result;
- }
- };
-}
-
-extern "C" {
- void clang_sortCodeCompletionResults(CXCompletionResult *Results,
- unsigned NumResults) {
- std::stable_sort(Results, Results + NumResults, OrderCompletionResults());
- }
-}
\ No newline at end of file
Modified: cfe/trunk/tools/libclang/libclang.darwin.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.darwin.exports?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.darwin.exports (original)
+++ cfe/trunk/tools/libclang/libclang.darwin.exports Wed Aug 25 22:53:50 2010
@@ -99,6 +99,5 @@
_clang_reparseTranslationUnit
_clang_saveTranslationUnit
_clang_setUseExternalASTGeneration
-_clang_sortCodeCompletionResults
_clang_tokenize
_clang_visitChildren
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=112161&r1=112160&r2=112161&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Wed Aug 25 22:53:50 2010
@@ -99,6 +99,5 @@
clang_reparseTranslationUnit
clang_saveTranslationUnit
clang_setUseExternalASTGeneration
-clang_sortCodeCompletionResults
clang_tokenize
clang_visitChildren
More information about the cfe-commits
mailing list