[cfe-commits] r113033 - in /cfe/trunk: include/clang/Sema/CodeCompleteConsumer.h lib/Sema/CodeCompleteConsumer.cpp lib/Sema/SemaCodeComplete.cpp test/Index/code-completion.cpp test/Index/complete-declarators.cpp test/Index/complete-memfunc-cvquals.cpp test/Index/complete-super.cpp test/Index/complete-templates.cpp tools/libclang/CXCursor.cpp

Douglas Gregor dgregor at apple.com
Fri Sep 3 16:30:36 PDT 2010


Author: dgregor
Date: Fri Sep  3 18:30:36 2010
New Revision: 113033

URL: http://llvm.org/viewvc/llvm-project?rev=113033&view=rev
Log:
Synchronize code-completion cursor kinds with indexing cursor
kinds. How shameful that this code was duplicated!

Added:
    cfe/trunk/test/Index/complete-templates.cpp
Modified:
    cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
    cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/code-completion.cpp
    cfe/trunk/test/Index/complete-declarators.cpp
    cfe/trunk/test/Index/complete-memfunc-cvquals.cpp
    cfe/trunk/test/Index/complete-super.cpp
    cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Fri Sep  3 18:30:36 2010
@@ -27,6 +27,8 @@
 
 namespace clang {
 
+class Decl;
+  
 /// \brief Default priority values for code-completion results based
 /// on their kind.
 enum {
@@ -122,6 +124,10 @@
 unsigned getMacroUsagePriority(llvm::StringRef MacroName, 
                                bool PreferredTypeIsPointer = false);
 
+/// \brief Determine the libclang cursor kind associated with the given
+/// declaration.
+CXCursorKind getCursorKindForDecl(Decl *D);
+  
 class FunctionDecl;
 class FunctionType;
 class FunctionTemplateDecl;

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Fri Sep  3 18:30:36 2010
@@ -510,95 +510,13 @@
     else if (Declaration->getAttr<DeprecatedAttr>())
       Availability = CXAvailability_Deprecated;
       
-    switch (Declaration->getKind()) {
-    case Decl::Record:
-    case Decl::CXXRecord:
-    case Decl::ClassTemplateSpecialization: {
-      RecordDecl *Record = cast<RecordDecl>(Declaration);
-      if (Record->isStruct())
-        CursorKind = CXCursor_StructDecl;
-      else if (Record->isUnion())
-        CursorKind = CXCursor_UnionDecl;
-      else
-        CursorKind = CXCursor_ClassDecl;
-      break;
-    }
-      
-    case Decl::ObjCMethod: {
-      ObjCMethodDecl *Method = cast<ObjCMethodDecl>(Declaration);
-      if (Method->isInstanceMethod())
-          CursorKind = CXCursor_ObjCInstanceMethodDecl;
-      else
-        CursorKind = CXCursor_ObjCClassMethodDecl;
-      break;
-    }
-      
-    case Decl::Typedef:
-      CursorKind = CXCursor_TypedefDecl;
-      break;
-        
-    case Decl::Enum:
-      CursorKind = CXCursor_EnumDecl;
-      break;
-        
-    case Decl::Field:
-      CursorKind = CXCursor_FieldDecl;
-      break;
-        
-    case Decl::EnumConstant:
-      CursorKind = CXCursor_EnumConstantDecl;
-      break;      
-        
-    case Decl::Function:
-    case Decl::CXXMethod:
-    case Decl::CXXConstructor:
-    case Decl::CXXDestructor:
-    case Decl::CXXConversion:
-      CursorKind = CXCursor_FunctionDecl;
-      if (cast<FunctionDecl>(Declaration)->isDeleted())
+    if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Declaration))
+      if (Function->isDeleted())
         Availability = CXAvailability_NotAvailable;
-      break;
-        
-    case Decl::Var:
-      CursorKind = CXCursor_VarDecl;
-      break;
-        
-    case Decl::ParmVar:
-      CursorKind = CXCursor_ParmDecl;
-      break;
-        
-    case Decl::ObjCInterface:
-      CursorKind = CXCursor_ObjCInterfaceDecl;
-      break;
-        
-    case Decl::ObjCCategory:
-      CursorKind = CXCursor_ObjCCategoryDecl;
-      break;
-        
-    case Decl::ObjCProtocol:
-      CursorKind = CXCursor_ObjCProtocolDecl;
-      break;
-
-    case Decl::ObjCProperty:
-      CursorKind = CXCursor_ObjCPropertyDecl;
-      break;
-        
-    case Decl::ObjCIvar:
-      CursorKind = CXCursor_ObjCIvarDecl;
-      break;
-        
-    case Decl::ObjCImplementation:
-      CursorKind = CXCursor_ObjCImplementationDecl;
-      break;
-        
-    case Decl::ObjCCategoryImpl:
-      CursorKind = CXCursor_ObjCCategoryImplDecl;
-      break;
-        
-    default:
+      
+    CursorKind = getCursorKindForDecl(Declaration);
+    if (CursorKind == CXCursor_UnexposedDecl)
       CursorKind = CXCursor_NotImplemented;
-      break;
-    }
     break;
 
   case RK_Macro:

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Sep  3 18:30:36 2010
@@ -2317,6 +2317,69 @@
   return Priority;
 }
 
+CXCursorKind clang::getCursorKindForDecl(Decl *D) {
+  if (!D)
+    return CXCursor_UnexposedDecl;
+  
+  switch (D->getKind()) {
+    case Decl::Enum:               return CXCursor_EnumDecl;
+    case Decl::EnumConstant:       return CXCursor_EnumConstantDecl;
+    case Decl::Field:              return CXCursor_FieldDecl;
+    case Decl::Function:  
+      return CXCursor_FunctionDecl;
+    case Decl::ObjCCategory:       return CXCursor_ObjCCategoryDecl;
+    case Decl::ObjCCategoryImpl:   return CXCursor_ObjCCategoryImplDecl;
+    case Decl::ObjCClass:
+      // FIXME
+      return CXCursor_UnexposedDecl;
+    case Decl::ObjCForwardProtocol:
+      // FIXME
+      return CXCursor_UnexposedDecl;      
+    case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl;
+    case Decl::ObjCInterface:      return CXCursor_ObjCInterfaceDecl;
+    case Decl::ObjCIvar:           return CXCursor_ObjCIvarDecl; 
+    case Decl::ObjCMethod:
+      return cast<ObjCMethodDecl>(D)->isInstanceMethod()
+      ? CXCursor_ObjCInstanceMethodDecl : CXCursor_ObjCClassMethodDecl;
+    case Decl::CXXMethod:          return CXCursor_CXXMethod;
+    case Decl::CXXConstructor:     return CXCursor_Constructor;
+    case Decl::CXXDestructor:      return CXCursor_Destructor;
+    case Decl::CXXConversion:      return CXCursor_ConversionFunction;
+    case Decl::ObjCProperty:       return CXCursor_ObjCPropertyDecl;
+    case Decl::ObjCProtocol:       return CXCursor_ObjCProtocolDecl;
+    case Decl::ParmVar:            return CXCursor_ParmDecl;
+    case Decl::Typedef:            return CXCursor_TypedefDecl;
+    case Decl::Var:                return CXCursor_VarDecl;
+    case Decl::Namespace:          return CXCursor_Namespace;
+    case Decl::NamespaceAlias:     return CXCursor_NamespaceAlias;
+    case Decl::TemplateTypeParm:   return CXCursor_TemplateTypeParameter;
+    case Decl::NonTypeTemplateParm:return CXCursor_NonTypeTemplateParameter;
+    case Decl::TemplateTemplateParm:return CXCursor_TemplateTemplateParameter;
+    case Decl::FunctionTemplate:   return CXCursor_FunctionTemplate;
+    case Decl::ClassTemplate:      return CXCursor_ClassTemplate;
+    case Decl::ClassTemplatePartialSpecialization:
+      return CXCursor_ClassTemplatePartialSpecialization;
+    case Decl::UsingDirective:     return CXCursor_UsingDirective;
+      
+    case Decl::Using:
+    case Decl::UnresolvedUsingValue:
+    case Decl::UnresolvedUsingTypename: 
+      return CXCursor_UsingDeclaration;
+      
+    default:
+      if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
+        switch (TD->getTagKind()) {
+          case TTK_Struct: return CXCursor_StructDecl;
+          case TTK_Class:  return CXCursor_ClassDecl;
+          case TTK_Union:  return CXCursor_UnionDecl;
+          case TTK_Enum:   return CXCursor_EnumDecl;
+        }
+      }
+  }
+  
+  return CXCursor_UnexposedDecl;
+}
+
 static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results,
                             bool TargetTypeIsPointer = false) {
   typedef CodeCompletionResult Result;

Modified: cfe/trunk/test/Index/code-completion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/code-completion.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/test/Index/code-completion.cpp (original)
+++ cfe/trunk/test/Index/code-completion.cpp Fri Sep  3 18:30:36 2010
@@ -40,18 +40,18 @@
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
-// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
-// CHECK-MEMBER: FunctionDecl:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative  const}
-// CHECK-MEMBER: FunctionDecl:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )}
-// CHECK-MEMBER: FunctionDecl:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )}
-// CHECK-MEMBER: FunctionDecl:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )}
+// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
+// CHECK-MEMBER: CXXConversion:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative  const}
+// CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )}
+// CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )}
+// CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )}
 // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
 // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
 // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
 // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
-// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
-// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
-// CHECK-MEMBER: FunctionDecl:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
 
 // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
 // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
@@ -63,5 +63,5 @@
 // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10)
 // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5)
 // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11)
-// CHECK-EXPR: FunctionDecl:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22)
-// CHECK-EXPR: NotImplemented:{TypedText N}{Text ::} (75)
+// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22)
+// CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)

Modified: cfe/trunk/test/Index/complete-declarators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-declarators.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-declarators.cpp (original)
+++ cfe/trunk/test/Index/complete-declarators.cpp Fri Sep  3 18:30:36 2010
@@ -16,22 +16,22 @@
 
 // RUN: c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText const} (30)
-// CHECK-CC1: NotImplemented:{TypedText N}{Text ::} (75)
+// CHECK-CC1: Namespace:{TypedText N}{Text ::} (75)
 // CHECK-CC1: NotImplemented:{TypedText operator} (30)
 // CHECK-CC1: NotImplemented:{TypedText volatile} (30)
 // RUN: c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: NotImplemented:{TypedText const} (30)
-// CHECK-CC2-NOT: NotImplemented:{TypedText N}{Text ::} (75)
+// CHECK-CC2-NOT: Namespace:{TypedText N}{Text ::} (75)
 // CHECK-CC2-NOT: NotImplemented:{TypedText operator} (30)
 // CHECK-CC2: NotImplemented:{TypedText volatile} (30)
 // RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: NotImplemented:{TypedText const} (30)
-// CHECK-CC3-NOT: NotImplemented:{TypedText N}{Text ::} (75)
+// CHECK-CC3-NOT: Namespace:{TypedText N}{Text ::} (75)
 // CHECK-CC3: NotImplemented:{TypedText operator} (30)
 // CHECK-CC3: NotImplemented:{TypedText volatile} (30)
 // RUN: c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: NotImplemented:{TypedText const} (30)
-// CHECK-CC4: NotImplemented:{TypedText N}{Text ::} (75)
+// CHECK-CC4: Namespace:{TypedText N}{Text ::} (75)
 // CHECK-CC4: NotImplemented:{TypedText operator} (30)
 // CHECK-CC4: NotImplemented:{TypedText volatile} (30)
 // CHECK-CC4: StructDecl:{TypedText Y} (65)

Modified: cfe/trunk/test/Index/complete-memfunc-cvquals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-memfunc-cvquals.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-memfunc-cvquals.cpp (original)
+++ cfe/trunk/test/Index/complete-memfunc-cvquals.cpp Fri Sep  3 18:30:36 2010
@@ -41,41 +41,41 @@
 // RUN: c-index-test -code-completion-at=%s:19:5 %s | FileCheck -check-prefix=CHECK-NOQUALS %s
 // RUN: c-index-test -code-completion-at=%s:20:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s
 // RUN: c-index-test -code-completion-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s
-// CHECK-NOQUALS: FunctionDecl:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (20)
-// CHECK-NOQUALS: FunctionDecl:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (19)
-// CHECK-NOQUALS: FunctionDecl:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (20)
-// CHECK-NOQUALS: FunctionDecl:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (20)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (20)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (19)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (20)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (20)
 // RUN: c-index-test -code-completion-at=%s:21:6 %s | FileCheck -check-prefix=CHECK-CONST %s
 // RUN: c-index-test -code-completion-at=%s:22:8 %s | FileCheck -check-prefix=CHECK-CONST %s
 // RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CONST %s
-// CHECK-CONST: FunctionDecl:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (20)
+// CHECK-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (20)
 // CHECK-CONST-NOT: bar
-// CHECK-CONST: FunctionDecl:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (19)
+// CHECK-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (19)
 // CHECK-CONST-NOT: bingo
 // CHECK-CONST: theend
 // RUN: c-index-test -code-completion-at=%s:25:8 %s | FileCheck -check-prefix=CHECK-VOLATILE %s
-// CHECK-VOLATILE: FunctionDecl:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (20)
+// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (20)
 // CHECK-VOLATILE-NOT: baz
-// CHECK-VOLATILE: FunctionDecl:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (19)
+// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (19)
 
 // Check implicit member access expressions.
 // RUN: c-index-test -code-completion-at=%s:29:2 %s | FileCheck -check-prefix=CHECK-IMPLICIT-NOQUALS %s
-// CHECK-IMPLICIT-NOQUALS: FunctionDecl:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (15)
-// CHECK-IMPLICIT-NOQUALS: FunctionDecl:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (14)
-// CHECK-IMPLICIT-NOQUALS: FunctionDecl:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (15)
-// CHECK-IMPLICIT-NOQUALS: FunctionDecl:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (15)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (15)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (14)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (15)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (15)
 
 // RUN: c-index-test -code-completion-at=%s:33:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-CONST %s
-// CHECK-IMPLICIT-CONST: FunctionDecl:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (15)
+// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (15)
 // CHECK-IMPLICIT-CONST-NOT: bar
-// CHECK-IMPLICIT-CONST: FunctionDecl:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (14)
+// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative  const} (14)
 // CHECK-IMPLICIT-CONST-NOT: bingo
 // CHECK-IMPLICIT-CONST: theend
 
 // RUN: c-index-test -code-completion-at=%s:37:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-VOLATILE %s
-// CHECK-IMPLICIT-VOLATILE: FunctionDecl:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (15)
+// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative  const volatile} (15)
 // CHECK-IMPLICIT-VOLATILE-NOT: baz
-// CHECK-IMPLICIT-VOLATILE: FunctionDecl:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (14)
+// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative  volatile} (14)
 
 // RUN: c-index-test -code-completion-at=%s:4:17 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER %s
 // CHECK-CVQUAL-AFTER: NotImplemented:{TypedText const} (30)

Modified: cfe/trunk/test/Index/complete-super.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-super.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-super.cpp (original)
+++ cfe/trunk/test/Index/complete-super.cpp Fri Sep  3 18:30:36 2010
@@ -25,8 +25,8 @@
 
 // RUN: c-index-test -code-completion-at=%s:20:3 %s | FileCheck -check-prefix=CHECK-BAR-UNQUAL %s
 // CHECK-BAR-UNQUAL: CXXMethod:{Text A::}{TypedText bar}{LeftParen (}{Placeholder real}{RightParen )} (8)
-// CHECK-BAR-UNQUAL: FunctionDecl:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (14)
-// CHECK-BAR-UNQUAL: FunctionDecl:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (16)
+// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (14)
+// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (16)
 
 // RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s
 // CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (8)

Added: cfe/trunk/test/Index/complete-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-templates.cpp?rev=113033&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-templates.cpp (added)
+++ cfe/trunk/test/Index/complete-templates.cpp Fri Sep  3 18:30:36 2010
@@ -0,0 +1,19 @@
+// Tests are line- and column-sensive, so run lines are below.
+
+template<typename T>
+class X {
+  X();
+  X(const X&);
+  
+  template<typename U> X(U);
+};
+
+template<typename T> void f(T);
+
+void test() {
+  
+}
+
+// RUN: c-index-test -code-completion-at=%s:14:2 %s | FileCheck %s
+// CHECK: FunctionTemplate:{ResultType void}{TypedText f}{LeftParen (}{Placeholder T}{RightParen )} (45)
+// CHECK: ClassTemplate:{TypedText X}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=113033&r1=113032&r2=113033&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Fri Sep  3 18:30:36 2010
@@ -29,70 +29,6 @@
   return C;
 }
 
-static CXCursorKind GetCursorKind(Decl *D) {
-  assert(D && "Invalid arguments!");
-  switch (D->getKind()) {
-    case Decl::Enum:               return CXCursor_EnumDecl;
-    case Decl::EnumConstant:       return CXCursor_EnumConstantDecl;
-    case Decl::Field:              return CXCursor_FieldDecl;
-    case Decl::Function:  
-      return CXCursor_FunctionDecl;
-    case Decl::ObjCCategory:       return CXCursor_ObjCCategoryDecl;
-    case Decl::ObjCCategoryImpl:   return CXCursor_ObjCCategoryImplDecl;
-    case Decl::ObjCClass:
-      // FIXME
-      return CXCursor_UnexposedDecl;
-    case Decl::ObjCForwardProtocol:
-      // FIXME
-      return CXCursor_UnexposedDecl;      
-    case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl;
-    case Decl::ObjCInterface:      return CXCursor_ObjCInterfaceDecl;
-    case Decl::ObjCIvar:           return CXCursor_ObjCIvarDecl; 
-    case Decl::ObjCMethod:
-      return cast<ObjCMethodDecl>(D)->isInstanceMethod()
-              ? CXCursor_ObjCInstanceMethodDecl : CXCursor_ObjCClassMethodDecl;
-    case Decl::CXXMethod:          return CXCursor_CXXMethod;
-    case Decl::CXXConstructor:     return CXCursor_Constructor;
-    case Decl::CXXDestructor:      return CXCursor_Destructor;
-    case Decl::CXXConversion:      return CXCursor_ConversionFunction;
-    case Decl::ObjCProperty:       return CXCursor_ObjCPropertyDecl;
-    case Decl::ObjCProtocol:       return CXCursor_ObjCProtocolDecl;
-    case Decl::ParmVar:            return CXCursor_ParmDecl;
-    case Decl::Typedef:            return CXCursor_TypedefDecl;
-    case Decl::Var:                return CXCursor_VarDecl;
-    case Decl::Namespace:          return CXCursor_Namespace;
-    case Decl::NamespaceAlias:     return CXCursor_NamespaceAlias;
-    case Decl::TemplateTypeParm:   return CXCursor_TemplateTypeParameter;
-    case Decl::NonTypeTemplateParm:return CXCursor_NonTypeTemplateParameter;
-    case Decl::TemplateTemplateParm:return CXCursor_TemplateTemplateParameter;
-    case Decl::FunctionTemplate:   return CXCursor_FunctionTemplate;
-    case Decl::ClassTemplate:      return CXCursor_ClassTemplate;
-    case Decl::ClassTemplatePartialSpecialization:
-      return CXCursor_ClassTemplatePartialSpecialization;
-    case Decl::UsingDirective:     return CXCursor_UsingDirective;
-      
-    case Decl::Using:
-    case Decl::UnresolvedUsingValue:
-    case Decl::UnresolvedUsingTypename: 
-      return CXCursor_UsingDeclaration;
-      
-    default:
-      if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
-        switch (TD->getTagKind()) {
-        case TTK_Struct: return CXCursor_StructDecl;
-        case TTK_Class:  return CXCursor_ClassDecl;
-        case TTK_Union:  return CXCursor_UnionDecl;
-        case TTK_Enum:   return CXCursor_EnumDecl;
-        }
-      }
-
-      return CXCursor_UnexposedDecl;
-  }
-  
-  llvm_unreachable("Invalid Decl");
-  return CXCursor_NotImplemented;  
-}
-
 static CXCursorKind GetCursorKind(const Attr *A) {
   assert(A && "Invalid arguments!");
   switch (A->getKind()) {
@@ -113,7 +49,7 @@
 
 CXCursor cxcursor::MakeCXCursor(Decl *D, ASTUnit *TU) {
   assert(D && TU && "Invalid arguments!");
-  CXCursor C = { GetCursorKind(D), { D, 0, TU } };
+  CXCursor C = { getCursorKindForDecl(D), { D, 0, TU } };
   return C;
 }
 





More information about the cfe-commits mailing list