diff options
author | Shoaib Meenai <smeenai@fb.com> | 2018-05-01 20:45:25 +0000 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2018-05-01 20:45:25 +0000 |
commit | aec83b75b754818ec4c59784b39f7fc60bc43d54 (patch) | |
tree | 8cd061f0e23479b9d423576f3abb5c869108d325 /test/Index | |
parent | abedeb9109266238ab0a7546bfc4c298e32227a5 (diff) |
[libclang] Fix the type of 'int (Foo);'
libclang exposes the type of 'int (Foo);' (a global variable of type int
called Foo) as CXType_Unexposed. This is because Clang represents Foo's
type as ParenType{BuiltinType{Int}}, and libclang does not handle
ParenType.
Make libclang return CXType_Int as the type of 'int (Foo);' by
unwrapping ParenType transparently.
Patch by Matt Glazar.
Differential Revision: https://reviews.llvm.org/D45713
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Index')
-rw-r--r-- | test/Index/paren-type.c | 16 | ||||
-rw-r--r-- | test/Index/print-type.c | 4 |
2 files changed, 18 insertions, 2 deletions
diff --git a/test/Index/paren-type.c b/test/Index/paren-type.c new file mode 100644 index 0000000000..14a7785e05 --- /dev/null +++ b/test/Index/paren-type.c @@ -0,0 +1,16 @@ +// RUN: c-index-test -test-print-type %s | FileCheck --check-prefix=CHECK-TYPE %s +// RUN: c-index-test -test-print-type-declaration %s | FileCheck --check-prefix=CHECK-TYPEDECL %s + +// CHECK-TYPE: VarDecl=VariableWithParentheses: +// CHECK-TYPE-SAME: [type=int] [typekind=Int] +// CHECK-TYPE-NOT: canonicaltype +// CHECK-TYPE-SAME: isPOD +extern int (VariableWithParentheses); + +typedef int MyTypedef; +// CHECK-TYPE: VarDecl=VariableWithParentheses2: +// CHECK-TYPE-SAME: [type=MyTypedef] [typekind=Typedef] +// CHECK-TYPE-SAME: [canonicaltype=int] [canonicaltypekind=Int] +// CHECK-TYPEDECL: VarDecl=VariableWithParentheses2 +// CHECK-TYPEDECL-SAME: [typedeclaration=MyTypedef] [typekind=Typedef] +extern MyTypedef (VariableWithParentheses2); diff --git a/test/Index/print-type.c b/test/Index/print-type.c index ebe42970ee..13c7655437 100644 --- a/test/Index/print-type.c +++ b/test/Index/print-type.c @@ -23,11 +23,11 @@ struct Struct{}; struct Struct elaboratedStructType(); // CHECK: TypeRef=FooType:1:13 [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] // CHECK: ParmDecl=arr:3:40 (Definition) [type=int [5]] [typekind=ConstantArray] [isPOD=1] // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1] -// CHECK: ParmDecl=fn:3:55 (Definition) [type=void (*)(int)] [typekind=Pointer] [canonicaltype=void (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=void (int)] [pointeekind=Unexposed] +// CHECK: ParmDecl=fn:3:55 (Definition) [type=void (*)(int)] [typekind=Pointer] [canonicaltype=void (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=void (int)] [pointeekind=FunctionProto] // CHECK: ParmDecl=:3:62 (Definition) [type=int] [typekind=Int] [isPOD=1] // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0] // CHECK: CallExpr=fn:3:55 [type=void] [typekind=Void] [args= [int] [Int]] [isPOD=0] -// CHECK: DeclRefExpr=fn:3:55 [type=void (*)(int)] [typekind=Pointer] [canonicaltype=void (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=void (int)] [pointeekind=Unexposed] +// CHECK: DeclRefExpr=fn:3:55 [type=void (*)(int)] [typekind=Pointer] [canonicaltype=void (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=void (int)] [pointeekind=FunctionProto] // CHECK: UnaryOperator= [type=int] [typekind=Int] [isPOD=1] // CHECK: DeclRefExpr=p:3:13 [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] // CHECK: DeclStmt= [type=] [typekind=Invalid] [isPOD=0] |