diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-08 01:22:12 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-08 01:22:12 +0000 |
commit | ae5ac1f5bdbcc5190b3867d16d0f41c2b10e0c65 (patch) | |
tree | d32577e1f0b9dfb73f7e68749d54f0ca8184377b | |
parent | 7032265efe50d7218312f1fc9f2b58829db49d1b (diff) |
[libclang] Map 'id'/'Class'/'SEL' to the corresponding CXType kinds.
rdar://11357807
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156352 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Index/print-typekind.m | 6 | ||||
-rw-r--r-- | tools/libclang/CXType.cpp | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/test/Index/print-typekind.m b/test/Index/print-typekind.m index 9db192938f..9eafd24fbe 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:(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] diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index 850fac129e..fcc13f6139 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -94,7 +94,22 @@ static CXTypeKind GetTypeKind(QualType T) { 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; } |