[cfe-commits] r82962 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/member-access.cpp test/CodeCompletion/ordinary-name.c
Douglas Gregor
dgregor at apple.com
Sun Sep 27 20:51:45 PDT 2009
Author: dgregor
Date: Sun Sep 27 22:51:44 2009
New Revision: 82962
URL: http://llvm.org/viewvc/llvm-project?rev=82962&view=rev
Log:
Determinism is for wimps. <Wimper>
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/member-access.cpp
cfe/trunk/test/CodeCompletion/ordinary-name.c
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=82962&r1=82961&r2=82962&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Sun Sep 27 22:51:44 2009
@@ -14,6 +14,7 @@
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/AST/ExprCXX.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/StringExtras.h"
#include <list>
#include <map>
#include <vector>
@@ -948,6 +949,14 @@
struct SortCodeCompleteResult {
typedef CodeCompleteConsumer::Result Result;
+ bool isEarlierDeclarationName(DeclarationName X, DeclarationName Y) const {
+ if (X.getNameKind() != Y.getNameKind())
+ return X.getNameKind() < Y.getNameKind();
+
+ return llvm::LowercaseString(X.getAsString())
+ < llvm::LowercaseString(Y.getAsString());
+ }
+
bool operator()(const Result &X, const Result &Y) const {
// Sort first by rank.
if (X.Rank < Y.Rank)
@@ -973,7 +982,8 @@
switch (X.Kind) {
case Result::RK_Declaration:
// Order based on the declaration names.
- return X.Declaration->getDeclName() < Y.Declaration->getDeclName();
+ return isEarlierDeclarationName(X.Declaration->getDeclName(),
+ Y.Declaration->getDeclName());
case Result::RK_Keyword:
return strcmp(X.Keyword, Y.Keyword) == -1;
Modified: cfe/trunk/test/CodeCompletion/member-access.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=82962&r1=82961&r2=82962&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/member-access.cpp (original)
+++ cfe/trunk/test/CodeCompletion/member-access.cpp Sun Sep 27 22:51:44 2009
@@ -27,7 +27,7 @@
void test(const Proxy &p) {
p->
- // RUN: clang-cc -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CC1 %s &&
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s &&
// CHECK-CC1: member1 : 0 : [#Base1::#]member1
// CHECK-CC1: member1 : 0 : [#Base2::#]member1
// CHECK-CC1: member2 : 0 : [#Base1::#]member2
@@ -37,7 +37,7 @@
// CHECK-CC1: memfun1 : 0 : [#Base3::#]memfun1(<#double#>)
// CHECK-CC1: memfun2 : 0 : [#Base3::#]memfun2(<#int#>)
// CHECK-CC1: memfun3 : 0 : memfun3(<#int#>)
- // CHECK-CC1-NEXT: Base1 : 0 : Base1::
+ // CHECK-CC1: Base1 : 0 : Base1::
// CHECK-CC1: memfun1 : 0 (Hidden) : Base2::memfun1(<#int#>)
// RUN: true
Modified: cfe/trunk/test/CodeCompletion/ordinary-name.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name.c?rev=82962&r1=82961&r2=82962&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/ordinary-name.c (original)
+++ cfe/trunk/test/CodeCompletion/ordinary-name.c Sun Sep 27 22:51:44 2009
@@ -1,12 +1,12 @@
struct X { int x; };
-typedef struct X TYPEDEF;
+typedef struct t TYPEDEF;
void foo() {
int y;
- // RUN: clang-cc -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CC1 %s &&
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s &&
// CHECK-CC1: y : 0
- // CHECK-CC1-NEXT: TYPEDEF : 2
- // CHECK-CC1-NOT: X
// CHECK-CC1: foo : 2
+ // CHECK-NOT-CC1: y : 2
+ // CHECK-CC1-NEXT: TYPEDEF : 2
// RUN: true
More information about the cfe-commits
mailing list