[cfe-commits] r156352 - in /cfe/trunk: test/Index/print-typekind.m tools/libclang/CXType.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon May 7 18:22:12 PDT 2012


Author: akirtzidis
Date: Mon May  7 20:22:12 2012
New Revision: 156352

URL: http://llvm.org/viewvc/llvm-project?rev=156352&view=rev
Log:
[libclang] Map 'id'/'Class'/'SEL' to the corresponding CXType kinds.

rdar://11357807

Modified:
    cfe/trunk/test/Index/print-typekind.m
    cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/test/Index/print-typekind.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-typekind.m?rev=156352&r1=156351&r2=156352&view=diff
==============================================================================
--- cfe/trunk/test/Index/print-typekind.m (original)
+++ cfe/trunk/test/Index/print-typekind.m Mon May  7 20:22:12 2012
@@ -1,10 +1,10 @@
 @interface Foo
 @property (readonly) id x;
 -(int) mymethod;
--(int) mymethod2:(int)x blah:(float)y;
+-(int) mymethod2:(id)x blah:(Class)y boo:(SEL)z;
 @end
 
 // RUN: c-index-test -test-print-typekind %s | FileCheck %s
-// CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer]
+// CHECK: ObjCPropertyDecl=x:2:25 typekind=ObjCId [canonical=ObjCObjectPointer]
 // CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int]
-// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float]
+// CHECK: ObjCInstanceMethodDecl=mymethod2:blah:boo::4:8 typekind=Invalid [result=Int] [args= ObjCId ObjCClass ObjCSel]

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=156352&r1=156351&r2=156352&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Mon May  7 20:22:12 2012
@@ -94,7 +94,22 @@
 
 
 CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
-  CXTypeKind TK = GetTypeKind(T);
+  CXTypeKind TK = CXType_Invalid;
+
+  if (TU) {
+    ASTContext &Ctx = static_cast<ASTUnit *>(TU->TUData)->getASTContext();
+    if (Ctx.getLangOpts().ObjC1) {
+      if (Ctx.isObjCIdType(T))
+        TK = CXType_ObjCId;
+      else if (Ctx.isObjCClassType(T))
+        TK = CXType_ObjCClass;
+      else if (Ctx.isObjCSelType(T))
+        TK = CXType_ObjCSel;
+    }
+  }
+  if (TK == CXType_Invalid)
+    TK = GetTypeKind(T);
+
   CXType CT = { TK, { TK == CXType_Invalid ? 0 : T.getAsOpaquePtr(), TU }};
   return CT;
 }





More information about the cfe-commits mailing list