[libclang] Report CXType_ObjCId for 'const id', not CXType_Typedef.

rdar://11357807

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157356 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Index/print-typekind.m b/test/Index/print-typekind.m
index 9eafd24..565c5e3 100644
--- a/test/Index/print-typekind.m
+++ b/test/Index/print-typekind.m
@@ -1,10 +1,10 @@
 @interface Foo
 @property (readonly) id x;
 -(int) mymethod;
--(int) mymethod2:(id)x blah:(Class)y boo:(SEL)z;
+-(const id) 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=ObjCId [canonical=ObjCObjectPointer]
 // CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int]
-// CHECK: ObjCInstanceMethodDecl=mymethod2:blah:boo::4:8 typekind=Invalid [result=Int] [args= ObjCId ObjCClass ObjCSel]
+// CHECK: ObjCInstanceMethodDecl=mymethod2:blah:boo::4:13 typekind=Invalid [result=ObjCId] [args= ObjCId ObjCClass ObjCSel]
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index fcc13f6..15f818a 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -96,14 +96,15 @@
 CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
   CXTypeKind TK = CXType_Invalid;
 
-  if (TU) {
+  if (TU && !T.isNull()) {
     ASTContext &Ctx = static_cast<ASTUnit *>(TU->TUData)->getASTContext();
     if (Ctx.getLangOpts().ObjC1) {
-      if (Ctx.isObjCIdType(T))
+      QualType UnqualT = T.getUnqualifiedType();
+      if (Ctx.isObjCIdType(UnqualT))
         TK = CXType_ObjCId;
-      else if (Ctx.isObjCClassType(T))
+      else if (Ctx.isObjCClassType(UnqualT))
         TK = CXType_ObjCClass;
-      else if (Ctx.isObjCSelType(T))
+      else if (Ctx.isObjCSelType(UnqualT))
         TK = CXType_ObjCSel;
     }
   }