r288582 - [libclang] Fix python tests

2016-12-03 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Sat Dec  3 06:53:06 2016
New Revision: 288582

URL: http://llvm.org/viewvc/llvm-project?rev=288582=rev
Log:
[libclang] Fix python tests

It was broken in r286421

Modified:
cfe/trunk/bindings/python/tests/cindex/test_cursor.py
cfe/trunk/bindings/python/tests/cindex/test_tokens.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=288582=288581=288582=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Sat Dec  3 06:53:06 
2016
@@ -375,7 +375,7 @@ def test_get_tokens():
 foo = get_cursor(tu, 'foo')
 
 tokens = list(foo.get_tokens())
-assert len(tokens) == 7
+assert len(tokens) == 6
 assert tokens[0].spelling == 'int'
 assert tokens[1].spelling == 'foo'
 

Modified: cfe/trunk/bindings/python/tests/cindex/test_tokens.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_tokens.py?rev=288582=288581=288582=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_tokens.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_tokens.py Sat Dec  3 06:53:06 
2016
@@ -14,7 +14,7 @@ def test_token_to_cursor():
 r = tu.get_extent('t.c', (0, 9))
 tokens = list(tu.get_tokens(extent=r))
 
-assert len(tokens) == 5
+assert len(tokens) == 4
 assert tokens[1].spelling == 'i'
 assert tokens[1].kind == TokenKind.IDENTIFIER
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-05-03 Thread Sergey Kalinichev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268366: [libclang] Expose the ElaboratedType (authored by 
skalinichev).

Changed prior to commit:
  http://reviews.llvm.org/D11797?vs=51109=55953#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11797

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/print-type.c
  cfe/trunk/test/Index/print-type.cpp
  cfe/trunk/tools/libclang/CXType.cpp
  cfe/trunk/tools/libclang/libclang.exports

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -2950,7 +2950,14 @@
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
   CXType_MemberPointer = 117,
-  CXType_Auto = 118
+  CXType_Auto = 118,
+
+  /**
+   * \brief Represents a type that was referred to using an elaborated type keyword.
+   *
+   * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
+   */
+  CXType_Elaborated = 119
 };
 
 /**
@@ -3340,6 +3347,13 @@
 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
 
 /**
+ * \brief Retrieve the type named by the qualified-id.
+ *
+ * If a non-elaborated type is passed in, an invalid type is returned.
+ */
+CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
+
+/**
  * \brief List the possible error codes for \c clang_Type_getSizeOf,
  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
  *   \c clang_Cursor_getOffsetOf.
Index: cfe/trunk/test/Index/print-type.c
===
--- cfe/trunk/test/Index/print-type.c
+++ cfe/trunk/test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * sizeof(int int] [typekind=Vector] [isPOD=1]
 // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] [typekind=Typedef] [canonicaltype=__attribute__((__vector_size__(4 * sizeof(int int] [canonicaltypekind=Vector] [isPOD=1]
 // CHECK: ParmDecl=incompletearray:13:12 (Definition) [type=int []] [typekind=IncompleteArray] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedEnumType:15:25 [type=enum Enum ()] [typekind=FunctionNoProto] [canonicaltype=enum Enum ()] [canonicaltypekind=FunctionNoProto] [resulttype=enum Enum] [resulttypekind=Elaborated] [isPOD=0]
+// CHECK: TypeRef=enum Enum:15:6 [type=enum Enum] [typekind=Enum] [isPOD=1]
+// CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] [typekind=Record] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedStructType:16:32 [type=struct Struct ()] [typekind=FunctionNoProto] [canonicaltype=struct Struct ()] [canonicaltypekind=FunctionNoProto] [resulttype=struct Struct] [resulttypekind=Elaborated] [isPOD=0]
+// CHECK: TypeRef=struct Struct:16:8 [type=struct Struct] [typekind=Record] [isPOD=1]
Index: cfe/trunk/test/Index/print-type.cpp
===
--- cfe/trunk/test/Index/print-type.cpp
+++ cfe/trunk/test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(const NS::Type t);
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) (converting constructor) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: 

r268366 - [libclang] Expose the ElaboratedType

2016-05-03 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Tue May  3 01:58:29 2016
New Revision: 268366

URL: http://llvm.org/viewvc/llvm-project?rev=268366=rev
Log:
[libclang] Expose the ElaboratedType

Differential Revision: http://reviews.llvm.org/D11797

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-type.c
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/libclang/CXType.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=268366=268365=268366=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue May  3 01:58:29 2016
@@ -1750,6 +1750,7 @@ TypeKind.VARIABLEARRAY = TypeKind(115)
 TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
 TypeKind.MEMBERPOINTER = TypeKind(117)
 TypeKind.AUTO = TypeKind(118)
+TypeKind.ELABORATED = TypeKind(119)
 
 class RefQualifierKind(BaseEnumeration):
 """Describes a specific ref-qualifier of a type."""
@@ -1948,6 +1949,12 @@ class Type(Structure):
 """
 return conf.lib.clang_Type_getClassType(self)
 
+def get_named_type(self):
+"""
+Retrieve the type named by the qualified-id.
+"""
+return conf.lib.clang_Type_getNamedType(self)
+
 def get_align(self):
 """
 Retrieve the alignment of the record.
@@ -3565,6 +3572,11 @@ functionList = [
[Type],
c_uint),
 
+  ("clang_Type_getNamedType",
+   [Type],
+   Type,
+   Type.from_result),
+
   ("clang_Type_visitFields",
[Type, callbacks['fields_visit'], py_object],
c_uint),

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=268366=268365=268366=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue May  3 01:58:29 2016
@@ -2950,7 +2950,14 @@ enum CXTypeKind {
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
   CXType_MemberPointer = 117,
-  CXType_Auto = 118
+  CXType_Auto = 118,
+
+  /**
+   * \brief Represents a type that was referred to using an elaborated type 
keyword.
+   *
+   * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
+   */
+  CXType_Elaborated = 119
 };
 
 /**
@@ -3340,6 +3347,13 @@ CINDEX_LINKAGE CXType clang_getArrayElem
 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
 
 /**
+ * \brief Retrieve the type named by the qualified-id.
+ *
+ * If a non-elaborated type is passed in, an invalid type is returned.
+ */
+CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
+
+/**
  * \brief List the possible error codes for \c clang_Type_getSizeOf,
  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
  *   \c clang_Cursor_getOffsetOf.

Modified: cfe/trunk/test/Index/print-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.c?rev=268366=268365=268366=diff
==
--- cfe/trunk/test/Index/print-type.c (original)
+++ cfe/trunk/test/Index/print-type.c Tue May  3 01:58:29 2016
@@ -12,6 +12,9 @@ typedef int __attribute__((vector_size(1
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, 
int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, 
char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] 
[resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] 
[Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] 
[Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] 
[isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@ int f2(int incompletearray[]);
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * 
sizeof(int int] [typekind=Vector] [isPOD=1]
 // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] 
[typekind=Typedef] [canonicaltype=__attribute__((__vector_size__(4 * 
sizeof(int int] [canonicaltypekind=Vector] [isPOD=1]
 // CHECK: ParmDecl=incompletearray:13:12 (Definition) [type=int []] 
[typekind=IncompleteArray] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedEnumType:15:25 [type=enum Enum ()] 
[typekind=FunctionNoProto] [canonicaltype=enum Enum ()] 
[canonicaltypekind=FunctionNoProto] [resulttype=enum Enum] 
[resulttypekind=Elaborated] [isPOD=0]
+// CHECK: TypeRef=enum Enum:15:6 [type=enum Enum] [typekind=Enum] [isPOD=1]
+// CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] 
[typekind=Record] 

Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-04-12 Thread Sergey Kalinichev via cfe-commits
skalinichev accepted this revision.
skalinichev added a comment.

LGTM!



Comment at: bindings/python/tests/cindex/test_cursor.py:197
@@ +196,3 @@
+
+def test_is_deleted_method():
+"""Ensure Cursor.is_deleted_method works."""

You should remove it too.


http://reviews.llvm.org/D15469



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-03-26 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Ok, If there are no objections, I'll commit this revision next week then.


http://reviews.llvm.org/D11797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18462: Fix for clang_Cursor_getSpellingNameRange()

2016-03-26 Thread Sergey Kalinichev via cfe-commits
skalinichev added inline comments.


Comment at: tools/libclang/CIndex.cpp:4311
@@ -4311,1 +4310,3 @@
+  C.kind == CXCursor_ConversionFunction ||
+  C.kind == CXCursor_FunctionDecl) {
 if (pieceIndex > 0)

What about function templates?

E.g.: template  double operator "" _x();


http://reviews.llvm.org/D18462



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-03-19 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

I see. There were some changes recently in the indexing functionality. I'm not 
sure whether this change is intended or not, but since it's not your fault and 
we already have a lot of tests confirming that clang_CXXMethod_isDeleted is 
working as expected (e.g. c-index-test -test-print-type) I think it's ok to 
remove this part of the test then

But just in case please open a bug report about skipped deleted methods with 
clangIndex.



Comment at: tools/libclang/CIndex.cpp:7124
@@ +7123,3 @@
+
+unsigned clang_CXXMethod_isDeleted(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))

Just occurred to me: what about deleted "not member" functions? Maybe 
clang_CXXMethod_isDeleted should be renamed to something like 
clang_Cursor_isDeleted and there we can use FunctionDecl::isDeleted()


http://reviews.llvm.org/D15469



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17180: Fix failing python bindings test

2016-03-19 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

It reminded me http://reviews.llvm.org/D17278

So it seems like it should be already fixed, no?


Repository:
  rL LLVM

http://reviews.llvm.org/D17180



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-03-19 Thread Sergey Kalinichev via cfe-commits
skalinichev updated this revision to Diff 51109.
skalinichev added a comment.

Looking a bit more at the recent commits in libclang, it seems like all 
recently added functions follow this naming convention: 
clang_Cursor_*
clang_Type_*
e.t.c.

So I'm renaming the function to follow that style too.


http://reviews.llvm.org/D11797

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -82,6 +82,7 @@
 clang_Type_getTemplateArgumentAsType
 clang_Type_getCXXRefQualifier
 clang_Type_visitFields
+clang_Type_getNamedType
 clang_VerbatimBlockLineComment_getText
 clang_VerbatimLineComment_getText
 clang_HTMLTagComment_getAsString
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -91,6 +91,7 @@
 TKCASE(Vector);
 TKCASE(MemberPointer);
 TKCASE(Auto);
+TKCASE(Elaborated);
 default:
   return CXType_Unexposed;
   }
@@ -491,6 +492,7 @@
 TKIND(Vector);
 TKIND(MemberPointer);
 TKIND(Auto);
+TKIND(Elaborated);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -987,4 +989,14 @@
   return 0;
 }
 
+CXType clang_Type_getNamedType(CXType CT){
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP && TP->getTypeClass() == Type::Elaborated)
+return MakeCXType(cast(TP)->getNamedType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
+
 } // end: extern "C"
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(const NS::Type t);
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -127,6 +127,10 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type (const NS::Type)] [typekind=FunctionProto] [canonicaltype=NS::Type (NS::Type)] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [args= [const NS::Type] [Elaborated]] [isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1]
+// CHECK: ParmDecl=t:51:81 (Definition) [type=const NS::Type] [typekind=Elaborated] const [canonicaltype=const NS::Type] [canonicaltypekind=Record] [isPOD=1]
 // CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] 

Re: [PATCH] D17226: libclang python bindings: Fix for bug 26394

2016-03-08 Thread Sergey Kalinichev via cfe-commits
skalinichev accepted this revision.
skalinichev added a comment.
This revision is now accepted and ready to land.

Yes, I've seen that python tests segfaulted too, never had time to investigate 
it though.

LGTM, great work!


Repository:
  rL LLVM

http://reviews.llvm.org/D17226



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-03-08 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Generally looks pretty good to me. Maybe it's worth to factor out duplicating 
code, but I guess it's not so important.

Also the index-file.cpp test failing for me:
test/Index/index-file.cpp:57:11: error: expected string not found in input
// CHECK: [indexDeclaration]: kind: c++-instance-method | name: foo | {{.*}} 
(deleted) | loc: 36:8

@jbcoe, can you take a look?


http://reviews.llvm.org/D15469



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-03-08 Thread Sergey Kalinichev via cfe-commits
skalinichev updated the summary for this revision.
skalinichev added reviewers: milianw, kfunk.
skalinichev updated this revision to Diff 50027.
skalinichev added a comment.

Ok, after some more testing I found out that elaborated types can have cv 
specifiers attached, but after using ET->getNamedType() we lose that 
information. So obviously the previous solution was wrong. Therefore I'm 
falling back to the original idea here once again: exposing the elaborated 
type. Also extending tests to account for the found bug.


http://reviews.llvm.org/D11797

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -212,6 +212,7 @@
 clang_getLocation
 clang_getLocationForOffset
 clang_getModuleForFile
+clang_getNamedTypeUnderlyingElaboratedType
 clang_getNullCursor
 clang_getNullLocation
 clang_getNullRange
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -91,6 +91,7 @@
 TKCASE(Vector);
 TKCASE(MemberPointer);
 TKCASE(Auto);
+TKCASE(Elaborated);
 default:
   return CXType_Unexposed;
   }
@@ -491,6 +492,7 @@
 TKIND(Vector);
 TKIND(MemberPointer);
 TKIND(Auto);
+TKIND(Elaborated);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -985,4 +987,14 @@
   return 0;
 }
 
+CXType clang_getNamedTypeUnderlyingElaboratedType(CXType CT){
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP && TP->getTypeClass() == Type::Elaborated)
+return MakeCXType(cast(TP)->getNamedType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
+
 } // end: extern "C"
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(const NS::Type t);
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -127,6 +127,10 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type (const NS::Type)] [typekind=FunctionProto] [canonicaltype=NS::Type (NS::Type)] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [args= [const NS::Type] [Elaborated]] [isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1]
+// CHECK: ParmDecl=t:51:81 (Definition) [type=const NS::Type] [typekind=Elaborated] const [canonicaltype=const NS::Type] [canonicaltypekind=Record] [isPOD=1]
 // CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: 

r257043 - [libclang] Handle AutoType in clang_getTypeDeclaration

2016-01-07 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Thu Jan  7 03:20:40 2016
New Revision: 257043

URL: http://llvm.org/viewvc/llvm-project?rev=257043=rev
Log:
[libclang] Handle AutoType in clang_getTypeDeclaration

Differential Revision: http://reviews.llvm.org/D13001

Added:
cfe/trunk/test/Index/print-type-declaration.cpp
Modified:
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXType.cpp

Added: cfe/trunk/test/Index/print-type-declaration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-declaration.cpp?rev=257043=auto
==
--- cfe/trunk/test/Index/print-type-declaration.cpp (added)
+++ cfe/trunk/test/Index/print-type-declaration.cpp Thu Jan  7 03:20:40 2016
@@ -0,0 +1,12 @@
+
+class Test{};
+
+int main()
+{
+  auto a = Test();
+  auto b = a;
+}
+
+// RUN: c-index-test -test-print-type-declaration -std=c++11 %s | FileCheck %s
+// CHECK: VarDecl=a:6:8 (Definition) [typedeclaration=Test] [typekind=Record]
+// CHECK: VarDecl=b:7:8 (Definition) [typedeclaration=Test] [typekind=Record]

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=257043=257042=257043=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan  7 03:20:40 2016
@@ -1508,6 +1508,22 @@ static enum CXChildVisitResult PrintBitW
 }
 
 
/**/
+/* Type declaration testing   
*/
+/**/
+
+static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor 
p,
+ CXClientData d) {
+  CXCursor typeDeclaration = 
clang_getTypeDeclaration(clang_getCursorType(cursor));
+
+  if (clang_isDeclaration(typeDeclaration.kind)) {
+PrintCursor(cursor, NULL);
+PrintTypeAndTypeKind(clang_getCursorType(typeDeclaration), " 
[typedeclaration=%s] [typekind=%s]\n");
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Loading ASTs/source.   
*/
 
/**/
 
@@ -4137,6 +4153,7 @@ static void print_usage(void) {
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-type-declaration {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4230,6 +4247,9 @@ int cindextest_main(int argc, const char
   else if (argc > 2 && strcmp(argv[1], "-test-print-type-size") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintTypeSize, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-type-declaration") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintTypeDeclaration, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=257043=257042=257043=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Thu Jan  7 03:20:40 2016
@@ -412,6 +412,12 @@ try_again:
  .getAsTemplateDecl();
 break;
 
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13001: [libclang] Handle AutoType in clang_getTypeDeclaration

2015-12-13 Thread Sergey Kalinichev via cfe-commits
skalinichev updated the summary for this revision.
skalinichev updated this revision to Diff 42654.
skalinichev added a comment.

Added tests


http://reviews.llvm.org/D13001

Files:
  test/Index/print-type-declaration.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -412,6 +412,12 @@
  .getAsTemplateDecl();
 break;
 
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1506,6 +1506,22 @@
 }
 
 
/**/
+/* Type declaration testing   
*/
+/**/
+
+static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor 
p,
+ CXClientData d) {
+  CXCursor typeDeclaration = 
clang_getTypeDeclaration(clang_getCursorType(cursor));
+
+  if (clang_isDeclaration(typeDeclaration.kind)) {
+PrintCursor(cursor, NULL);
+PrintTypeAndTypeKind(clang_getCursorType(typeDeclaration), " 
[typedeclaration=%s] [typekind=%s]\n");
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Loading ASTs/source.   
*/
 
/**/
 
@@ -4114,6 +4130,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-type-declaration {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4207,6 +4224,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-type-size") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintTypeSize, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-type-declaration") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintTypeDeclaration, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
Index: test/Index/print-type-declaration.cpp
===
--- /dev/null
+++ test/Index/print-type-declaration.cpp
@@ -0,0 +1,12 @@
+
+class Test{};
+
+int main()
+{
+  auto a = Test();
+  auto b = a;
+}
+
+// RUN: c-index-test -test-print-type-declaration -std=c++11 %s | FileCheck %s
+// CHECK: VarDecl=a:6:8 (Definition) [typedeclaration=Test] [typekind=Record]
+// CHECK: VarDecl=b:7:8 (Definition) [typedeclaration=Test] [typekind=Record]


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -412,6 +412,12 @@
  .getAsTemplateDecl();
 break;
 
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1506,6 +1506,22 @@
 }
 
 /**/
+/* Type declaration testing   */
+/**/
+
+static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+  CXCursor typeDeclaration = clang_getTypeDeclaration(clang_getCursorType(cursor));
+
+  if (clang_isDeclaration(typeDeclaration.kind)) {
+PrintCursor(cursor, NULL);
+PrintTypeAndTypeKind(clang_getCursorType(typeDeclaration), " [typedeclaration=%s] [typekind=%s]\n");
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Loading ASTs/source.  

Re: [PATCH] D14329: Show inclusions from a preamble in clang_getInclusions.

2015-12-13 Thread Sergey Kalinichev via cfe-commits
skalinichev added a subscriber: skalinichev.
skalinichev added a comment.

I've seen this bug too. Generally this patch looks good to me.

Could you also add a test for includes half-way through a file case?



Comment at: tools/c-index-test/c-index-test.c:1567
@@ -1564,1 +1566,3 @@
 
+  if (getenv("CINDEXTEST_EDITING"))
+Repeats = 5;

This is not a very good idea to add this code here IMO. There are probably some 
tests that use this function with CINDEXTEST_EDITING set, which could  
potentially hide some parsing vs. reparsing bugs. I'd suggest to use something 
like perform_test_reparse_source instead.


http://reviews.llvm.org/D14329



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13844: [libclang] Visit TypeAliasTemplateDecl

2015-11-15 Thread Sergey Kalinichev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253166: [libclang] Visit TypeAliasTemplateDecl (authored by 
skalinichev).

Changed prior to commit:
  http://reviews.llvm.org/D13844?vs=37672=40234#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13844

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
  cfe/trunk/test/Index/index-templates.cpp
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/CursorVisitor.h

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -2296,8 +2296,9 @@
* \brief A module import declaration.
*/
   CXCursor_ModuleImportDecl  = 600,
+  CXCursor_TypeAliasTemplateDecl = 601,
   CXCursor_FirstExtraDecl= CXCursor_ModuleImportDecl,
-  CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl,
+  CXCursor_LastExtraDecl = CXCursor_TypeAliasTemplateDecl,
 
   /**
* \brief A code completion overload candidate.
Index: cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
===
--- cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
+++ cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
@@ -800,7 +800,7 @@
   template
   using comment_to_xml_conversion_09 = comment_to_xml_conversion_08;
 
-// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: UnexposedDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_09c:@S@comment_to_xml_conversion_01@comment_to_xml_conversion_09template typename T\nusing comment_to_xml_conversion_09 = comment_to_xml_conversion_08T, int Aaa.]
+// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: TypeAliasTemplateDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_09c:@S@comment_to_xml_conversion_01@comment_to_xml_conversion_09template typename T\nusing comment_to_xml_conversion_09 = comment_to_xml_conversion_08T, int Aaa.]
 };
 
 /// Aaa.
Index: cfe/trunk/test/Index/index-templates.cpp
===
--- cfe/trunk/test/Index/index-templates.cpp
+++ cfe/trunk/test/Index/index-templates.cpp
@@ -110,6 +110,9 @@
 template <>
 void foo(float Value);
 
+template 
+using alias = T;
+
 // RUN: c-index-test -test-load-source all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-LOAD %s
 // CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22]
 // CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:10 - 3:20]
@@ -189,6 +192,10 @@
 // CHECK-LOAD: index-templates.cpp:101:20: C++ base class specifier=Pair:98:16 [access=public isVirtual=false] Extent=[101:20 - 101:34]
 // CHECK-LOAD: index-templates.cpp:101:36: C++ base class specifier=Pair:76:8 [access=public isVirtual=false] Extent=[101:36 - 101:46]
 // CHECK-LOAD: index-templates.cpp:111:6: FunctionDecl=foo:111:6 [Specialization of foo:107:6] [Template arg 0: kind: 1, type: float] [Template arg 1: kind: 4, intval: 9] [Template arg 2: kind: 4, intval: 1] [Template arg 3: kind: 4, intval: 14] Extent=[110:1 - 111:64]
+// CHECK-LOAD: index-templates.cpp:114:1: TypeAliasTemplateDecl=alias:114:1 (Definition) Extent=[113:1 - 114:16]
+// CHECK-LOAD: index-templates.cpp:113:17: TemplateTypeParameter=T:113:17 (Definition) Extent=[113:11 - 113:18] [access=public]
+// CHECK-LOAD: index-templates.cpp:114:7: TypeAliasDecl=alias:114:7 (Definition) Extent=[114:1 - 114:16]
+// CHECK-LOAD: index-templates.cpp:114:15: TypeRef=T:113:17 Extent=[114:15 - 114:16]
 
 // RUN: c-index-test -test-load-source-usrs all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-USRS %s
 // CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22S0_#v# Extent=[3:1 - 4:22]
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -3036,6 +3036,7 @@
 case Decl::ParmVar:return CXCursor_ParmDecl;
 case Decl::Typedef:return CXCursor_TypedefDecl;
 case Decl::TypeAlias:  return CXCursor_TypeAliasDecl;
+case Decl::TypeAliasTemplate:  return CXCursor_TypeAliasTemplateDecl;
 case Decl::Var:return CXCursor_VarDecl;
 case Decl::Namespace:  return CXCursor_Namespace;
 case Decl::NamespaceAlias: return CXCursor_NamespaceAlias;
Index: cfe/trunk/tools/libclang/CIndex.cpp

r253166 - [libclang] Visit TypeAliasTemplateDecl

2015-11-15 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Sun Nov 15 07:48:32 2015
New Revision: 253166

URL: http://llvm.org/viewvc/llvm-project?rev=253166=rev
Log:
[libclang] Visit TypeAliasTemplateDecl

This makes TypeAliasTemplateDecl accessible via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13844

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
cfe/trunk/test/Index/index-templates.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CursorVisitor.h

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=253166=253165=253166=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sun Nov 15 07:48:32 2015
@@ -1114,7 +1114,8 @@ CursorKind.INCLUSION_DIRECTIVE = CursorK
 
 # A module import declaration.
 CursorKind.MODULE_IMPORT_DECL = CursorKind(600)
-
+# A type alias template declaration
+CursorKind.TYPE_ALIAS_TEMPLATE_DECL = CursorKind(601)
 
 ### Template Argument Kinds ###
 class TemplateArgumentKind(BaseEnumeration):

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py?rev=253166=253165=253166=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py Sun Nov 15 
07:48:32 2015
@@ -13,6 +13,7 @@ def test_get_all_kinds():
 assert CursorKind.OBJ_SELF_EXPR in kinds
 assert CursorKind.MS_ASM_STMT in kinds
 assert CursorKind.MODULE_IMPORT_DECL in kinds
+assert CursorKind.TYPE_ALIAS_TEMPLATE_DECL in kinds
 
 def test_kind_groups():
 """Check that every kind classifies to exactly one group."""

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=253166=253165=253166=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Sun Nov 15 07:48:32 2015
@@ -2296,8 +2296,9 @@ enum CXCursorKind {
* \brief A module import declaration.
*/
   CXCursor_ModuleImportDecl  = 600,
+  CXCursor_TypeAliasTemplateDecl = 601,
   CXCursor_FirstExtraDecl= CXCursor_ModuleImportDecl,
-  CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl,
+  CXCursor_LastExtraDecl = CXCursor_TypeAliasTemplateDecl,
 
   /**
* \brief A code completion overload candidate.

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=253166=253165=253166=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Sun Nov 15 07:48:32 2015
@@ -3036,6 +3036,7 @@ CXCursorKind clang::getCursorKindForDecl
 case Decl::ParmVar:return CXCursor_ParmDecl;
 case Decl::Typedef:return CXCursor_TypedefDecl;
 case Decl::TypeAlias:  return CXCursor_TypeAliasDecl;
+case Decl::TypeAliasTemplate:  return CXCursor_TypeAliasTemplateDecl;
 case Decl::Var:return CXCursor_VarDecl;
 case Decl::Namespace:  return CXCursor_Namespace;
 case Decl::NamespaceAlias: return CXCursor_NamespaceAlias;

Modified: cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp?rev=253166=253165=253166=diff
==
--- cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp (original)
+++ cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp Sun Nov 15 07:48:32 
2015
@@ -800,7 +800,7 @@ class comment_to_xml_conversion_01 {
   template
   using comment_to_xml_conversion_09 = comment_to_xml_conversion_08;
 
-// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: 
UnexposedDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_09c:@S@comment_to_xml_conversion_01@comment_to_xml_conversion_09template
 typename T\nusing comment_to_xml_conversion_09 = 
comment_to_xml_conversion_08T, int 
Aaa.]
+// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: 
TypeAliasTemplateDecl=comment_to_xml_conversion_09:{{.*}} 

r253164 - Remove some trailing whitespace

2015-11-15 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Sun Nov 15 06:37:01 2015
New Revision: 253164

URL: http://llvm.org/viewvc/llvm-project?rev=253164=rev
Log:
Remove some trailing whitespace


Modified:
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=253164=253163=253164=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Sun Nov 15 06:37:01 2015
@@ -144,7 +144,7 @@ extern "C" {
 
 CXType clang_getCursorType(CXCursor C) {
   using namespace cxcursor;
-  
+
   CXTranslationUnit TU = cxcursor::getCursorTU(C);
   if (!TU)
 return MakeCXType(QualType(), TU);
@@ -174,7 +174,7 @@ CXType clang_getCursorType(CXCursor C) {
   return MakeCXType(FTD->getTemplatedDecl()->getType(), TU);
 return MakeCXType(QualType(), TU);
   }
-  
+
   if (clang_isReference(C.kind)) {
 switch (C.kind) {
 case CXCursor_ObjCSuperClassRef: {
@@ -182,18 +182,18 @@ CXType clang_getCursorType(CXCursor C) {
 = Context.getObjCInterfaceType(getCursorObjCSuperClassRef(C).first);
   return MakeCXType(T, TU);
 }
-
+
 case CXCursor_ObjCClassRef: {
   QualType T = 
Context.getObjCInterfaceType(getCursorObjCClassRef(C).first);
   return MakeCXType(T, TU);
 }
-
+
 case CXCursor_TypeRef: {
   QualType T = Context.getTypeDeclType(getCursorTypeRef(C).first);
   return MakeCXType(T, TU);
 
 }
-  
+
 case CXCursor_CXXBaseSpecifier:
   return cxtype::MakeCXType(getCursorCXXBaseSpecifier(C)->getType(), TU);
 
@@ -210,7 +210,7 @@ CXType clang_getCursorType(CXCursor C) {
 default:
   break;
 }
-
+
 return MakeCXType(QualType(), TU);
   }
 
@@ -348,10 +348,10 @@ unsigned clang_isRestrictQualifiedType(C
 CXType clang_getPointeeType(CXType CT) {
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
-  
+
   if (!TP)
 return MakeCXType(QualType(), GetTU(CT));
-  
+
   switch (TP->getTypeClass()) {
 case Type::Pointer:
   T = cast(TP)->getPointeeType();
@@ -410,7 +410,7 @@ try_again:
   D = cast(TP)->getTemplateName()
  .getAsTemplateDecl();
 break;
-  
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;
@@ -420,7 +420,7 @@ try_again:
   case Type::Elaborated:
 TP = cast(TP)->getNamedType().getTypePtrOrNull();
 goto try_again;
-
+
   default:
 break;
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13000: [libclang] Expose AutoType

2015-11-15 Thread Sergey Kalinichev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253165: [libclang] Expose AutoType (authored by skalinichev).

Changed prior to commit:
  http://reviews.llvm.org/D13000?vs=35193=40232#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13000

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/print-type.cpp
  cfe/trunk/tools/libclang/CXType.cpp

Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1699,6 +1699,7 @@
 TypeKind.VARIABLEARRAY = TypeKind(115)
 TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
 TypeKind.MEMBERPOINTER = TypeKind(117)
+TypeKind.AUTO = TypeKind(118)
 
 class RefQualifierKind(BaseEnumeration):
 """Describes a specific ref-qualifier of a type."""
Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -2860,7 +2860,8 @@
   CXType_IncompleteArray = 114,
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
-  CXType_MemberPointer = 117
+  CXType_MemberPointer = 117,
+  CXType_Auto = 118
 };
 
 /**
Index: cfe/trunk/test/Index/print-type.cpp
===
--- cfe/trunk/test/Index/print-type.cpp
+++ cfe/trunk/test/Index/print-type.cpp
@@ -127,20 +127,20 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] 
[isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] 
[typekind=MemberPointer] [isPOD=1]
-// CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: CallExpr=tbar:35:3 [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [args= [int] [Int]] [isPOD=1]
 // CHECK: UnexposedExpr=tbar:35:3 [type=int (*)(int)] [typekind=Pointer] 
[canonicaltype=int (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] 
[pointeetype=int (int)] [pointeekind=FunctionProto]
 // CHECK: DeclRefExpr=tbar:35:3 RefName=[54:17 - 54:21] RefName=[54:21 - 
54:26] [type=int (int)] [typekind=FunctionProto] [canonicaltype=int (int)] 
[canonicaltypekind=FunctionProto] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoBlob:55:6 (Definition) [type=Blob *] 
[typekind=Unexposed] [canonicaltype=Blob *] [canonicaltypekind=Pointer] 
[isPOD=1]
+// CHECK: VarDecl=autoBlob:55:6 (Definition) [type=Blob *] [typekind=Auto] 
[canonicaltype=Blob *] [canonicaltypekind=Pointer] [isPOD=1]
 // CHECK: CXXNewExpr= [type=Blob *] [typekind=Pointer] [isPOD=1] 
[pointeetype=Blob] [pointeekind=Record]
 // CHECK: TypeRef=struct Blob:45:8 [type=Blob] [typekind=Record] [isPOD=1] 
[nbFields=2]
 // CHECK: CallExpr=Blob:45:8 [type=Blob] [typekind=Record] [isPOD=1] 
[nbFields=2]
-// CHECK: FunctionDecl=autoFunction:56:6 (Definition) [type=int ()] 
[typekind=FunctionProto] [canonicaltype=int ()] 
[canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Unexposed] 
[isPOD=0]
+// CHECK: FunctionDecl=autoFunction:56:6 (Definition) [type=int ()] 
[typekind=FunctionProto] [canonicaltype=int ()] 
[canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Auto] 
[isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ReturnStmt= [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: UnexposedExpr= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoInt:57:16 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoInt:57:16 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -90,6 +90,7 @@
 TKCASE(DependentSizedArray);
 TKCASE(Vector);
 TKCASE(MemberPointer);
+TKCASE(Auto);
 default:
   return CXType_Unexposed;
   }
@@ -483,6 +484,7 @@
 TKIND(DependentSizedArray);
 TKIND(Vector);
 TKIND(MemberPointer);
+TKIND(Auto);
   }
 #undef TKIND
   

r253165 - [libclang] Expose AutoType

2015-11-15 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Sun Nov 15 07:10:10 2015
New Revision: 253165

URL: http://llvm.org/viewvc/llvm-project?rev=253165=rev
Log:
[libclang] Expose AutoType

Expose the AutoType via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13000

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=253165=253164=253165=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sun Nov 15 07:10:10 2015
@@ -1699,6 +1699,7 @@ TypeKind.INCOMPLETEARRAY = TypeKind(114)
 TypeKind.VARIABLEARRAY = TypeKind(115)
 TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
 TypeKind.MEMBERPOINTER = TypeKind(117)
+TypeKind.AUTO = TypeKind(118)
 
 class RefQualifierKind(BaseEnumeration):
 """Describes a specific ref-qualifier of a type."""

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=253165=253164=253165=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Sun Nov 15 07:10:10 2015
@@ -2860,7 +2860,8 @@ enum CXTypeKind {
   CXType_IncompleteArray = 114,
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
-  CXType_MemberPointer = 117
+  CXType_MemberPointer = 117,
+  CXType_Auto = 118
 };
 
 /**

Modified: cfe/trunk/test/Index/print-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=253165=253164=253165=diff
==
--- cfe/trunk/test/Index/print-type.cpp (original)
+++ cfe/trunk/test/Index/print-type.cpp Sun Nov 15 07:10:10 2015
@@ -127,20 +127,20 @@ decltype(auto) autoInt = 5;
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] 
[isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] 
[typekind=MemberPointer] [isPOD=1]
-// CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: CallExpr=tbar:35:3 [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [args= [int] [Int]] [isPOD=1]
 // CHECK: UnexposedExpr=tbar:35:3 [type=int (*)(int)] [typekind=Pointer] 
[canonicaltype=int (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] 
[pointeetype=int (int)] [pointeekind=FunctionProto]
 // CHECK: DeclRefExpr=tbar:35:3 RefName=[54:17 - 54:21] RefName=[54:21 - 
54:26] [type=int (int)] [typekind=FunctionProto] [canonicaltype=int (int)] 
[canonicaltypekind=FunctionProto] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoBlob:55:6 (Definition) [type=Blob *] 
[typekind=Unexposed] [canonicaltype=Blob *] [canonicaltypekind=Pointer] 
[isPOD=1]
+// CHECK: VarDecl=autoBlob:55:6 (Definition) [type=Blob *] [typekind=Auto] 
[canonicaltype=Blob *] [canonicaltypekind=Pointer] [isPOD=1]
 // CHECK: CXXNewExpr= [type=Blob *] [typekind=Pointer] [isPOD=1] 
[pointeetype=Blob] [pointeekind=Record]
 // CHECK: TypeRef=struct Blob:45:8 [type=Blob] [typekind=Record] [isPOD=1] 
[nbFields=2]
 // CHECK: CallExpr=Blob:45:8 [type=Blob] [typekind=Record] [isPOD=1] 
[nbFields=2]
-// CHECK: FunctionDecl=autoFunction:56:6 (Definition) [type=int ()] 
[typekind=FunctionProto] [canonicaltype=int ()] 
[canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Unexposed] 
[isPOD=0]
+// CHECK: FunctionDecl=autoFunction:56:6 (Definition) [type=int ()] 
[typekind=FunctionProto] [canonicaltype=int ()] 
[canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Auto] 
[isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ReturnStmt= [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: UnexposedExpr= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoInt:57:16 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoInt:57:16 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: 

Re: [PATCH] D13388: Add support for querying the visibility of a cursor

2015-11-03 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Well, I think it's ok then. Still there is no test for visibility set from 
command line case. 
Also adding comment to clang_getCursorVisibility explaining that it also works 
with visibility set from command line would be very useful.



Comment at: test/Index/symbol-visibility.c:8
@@ +7,3 @@
+// CHECK: FunctionDecl=foo1:3:47visibility=Default
+// CHECK: FunctionDecl=foo2:4:49visibility=Protected
+// CHECK: FunctionDecl=foo3:5:46visibility=Hidden

Are you sure that this is correct?
Looking at r246931, it seems like the protected visibility is not supported on 
all platforms.


http://reviews.llvm.org/D13388



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13844: [libclang] Visit TypeAliasTemplateDecl

2015-11-03 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Yes, I have commit acces now (didn't test it yet though). I'll try to submit 
this patch soon.

Thanks!


http://reviews.llvm.org/D13844



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13388: Add support for querying the visibility of a cursor

2015-10-17 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Isn't r246931 what you're looking for?

> Index: expose visibility attribute

> 

> Expose the previously unexposed visibility attribute via the python and C 

>  bindings.


Can't you use/improve that API instead?


http://reviews.llvm.org/D13388



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13000: [libclang] Expose AutoType

2015-09-20 Thread Sergey Kalinichev via cfe-commits
skalinichev created this revision.
skalinichev added a subscriber: cfe-commits.

This exposes the AutoType through LibClang interface

http://reviews.llvm.org/D13000

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -90,6 +90,7 @@
 TKCASE(DependentSizedArray);
 TKCASE(Vector);
 TKCASE(MemberPointer);
+TKCASE(Auto);
 default:
   return CXType_Unexposed;
   }
@@ -483,6 +484,7 @@
 TKIND(DependentSizedArray);
 TKIND(Vector);
 TKIND(MemberPointer);
+TKIND(Auto);
   }
 #undef TKIND
   return cxstring::createRef(s);
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -127,20 +127,20 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] 
[isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] 
[typekind=MemberPointer] [isPOD=1]
-// CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: CallExpr=tbar:35:3 [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [args= [int] [Int]] [isPOD=1]
 // CHECK: UnexposedExpr=tbar:35:3 [type=int (*)(int)] [typekind=Pointer] 
[canonicaltype=int (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] 
[pointeetype=int (int)] [pointeekind=FunctionProto]
 // CHECK: DeclRefExpr=tbar:35:3 RefName=[54:17 - 54:21] RefName=[54:21 - 
54:26] [type=int (int)] [typekind=FunctionProto] [canonicaltype=int (int)] 
[canonicaltypekind=FunctionProto] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoBlob:55:6 (Definition) [type=Blob *] 
[typekind=Unexposed] [canonicaltype=Blob *] [canonicaltypekind=Pointer] 
[isPOD=1]
+// CHECK: VarDecl=autoBlob:55:6 (Definition) [type=Blob *] [typekind=Auto] 
[canonicaltype=Blob *] [canonicaltypekind=Pointer] [isPOD=1]
 // CHECK: CXXNewExpr= [type=Blob *] [typekind=Pointer] [isPOD=1] 
[pointeetype=Blob] [pointeekind=Record]
 // CHECK: TypeRef=struct Blob:45:8 [type=Blob] [typekind=Record] [isPOD=1] 
[nbFields=2]
 // CHECK: CallExpr=Blob:45:8 [type=Blob] [typekind=Record] [isPOD=1] 
[nbFields=2]
-// CHECK: FunctionDecl=autoFunction:56:6 (Definition) [type=int ()] 
[typekind=FunctionProto] [canonicaltype=int ()] 
[canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Unexposed] 
[isPOD=0]
+// CHECK: FunctionDecl=autoFunction:56:6 (Definition) [type=int ()] 
[typekind=FunctionProto] [canonicaltype=int ()] 
[canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Auto] 
[isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ReturnStmt= [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: UnexposedExpr= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: VarDecl=autoInt:57:16 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
+// CHECK: VarDecl=autoInt:57:16 (Definition) [type=int] [typekind=Auto] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -2860,7 +2860,8 @@
   CXType_IncompleteArray = 114,
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
-  CXType_MemberPointer = 117
+  CXType_MemberPointer = 117,
+  CXType_Auto = 118
 };
 
 /**
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1675,6 +1675,7 @@
 TypeKind.VARIABLEARRAY = TypeKind(115)
 TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
 TypeKind.MEMBERPOINTER = TypeKind(117)
+TypeKind.AUTO = TypeKind(118)
 
 class RefQualifierKind(BaseEnumeration):
 """Describes a specific ref-qualifier of a type."""


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -90,6 +90,7 @@
 TKCASE(DependentSizedArray);
 TKCASE(Vector);
 

[PATCH] D13001: [libclang] Handle AutoType in clang_getTypeDeclaration

2015-09-20 Thread Sergey Kalinichev via cfe-commits
skalinichev created this revision.
skalinichev added a subscriber: cfe-commits.

Now that auto type is fixed by D11976, it also makes sense to support it in 
clang_getTypeDeclaration.

I couldn't find any existing tests for this method, so no tests added...

http://reviews.llvm.org/D13001

Files:
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -411,7 +411,13 @@
   D = cast(TP)->getTemplateName()
  .getAsTemplateDecl();
 break;
-  
+
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -411,7 +411,13 @@
   D = cast(TP)->getTemplateName()
  .getAsTemplateDecl();
 break;
-  
+
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2015-09-09 Thread Sergey Kalinichev via cfe-commits
skalinichev updated this revision to Diff 34350.
skalinichev added a comment.

Yes, I've noticed that inconsistency too. But, seems like, this is an unrelated 
issue: TemplateSpecializationType type for some reasons uses id instead of qid 
(See also all other tests with templates in print-type.cpp, e.g. 
FieldDecl=baz). To get the type with nested name specifiers for the 
TemplateSpecializationType c-index-test should use the clang_getCanonicalType. 
But it doesn't  use it for pointers. (Compare c-index-test.c:1289 and 
c-index-test.c:1335)

Here I'm also adding an another test to show that nested name specifiers are 
not lost.


http://reviews.llvm.org/D11797

Files:
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -121,6 +121,11 @@
 if (const DecayedType *DT = T->getAs()) {
   return MakeCXType(DT->getOriginalType(), TU);
 }
+
+/* Handle elaborated types as the original type */
+if (const auto *ET = T->getAs()) {
+  return MakeCXType(ET->getNamedType(), TU);
+}
   }
   if (TK == CXType_Invalid)
 TK = GetTypeKind(T);
@@ -388,7 +393,6 @@
 
   Decl *D = nullptr;
 
-try_again:
   switch (TP->getTypeClass()) {
   case Type::Typedef:
 D = cast(TP)->getDecl();
@@ -417,10 +421,6 @@
 
   // FIXME: Template type parameters!  
 
-  case Type::Elaborated:
-TP = cast(TP)->getNamedType().getTypePtrOrNull();
-goto try_again;
-
   default:
 break;
   }
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -1,5 +1,7 @@
 namespace outer {
 
+struct NonTemplateStruct {};
+
 template
 struct Foo {
   T t;
@@ -15,6 +17,7 @@
 
 struct Bar {
   Bar(outer::Foo* foo) { }
+  Bar(outer::NonTemplateStruct* foo) { }
 
   typedef int FooType;
   int *p;
@@ -48,7 +51,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType();
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -58,89 +61,105 @@
 
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: TemplateTypeParameter=T:3:19 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
-// CHECK: FieldDecl=t:5:5 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
-// CHECK: TypeRef=T:3:19 [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
-// CHECK: ClassTemplate=Baz:9:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: TemplateTypeParameter=T:8:20 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
-// CHECK: NonTypeTemplateParameter=U:8:32 (Definition) [type=unsigned int] [typekind=UInt] [isPOD=1]
-// CHECK: TemplateTemplateParameter=W:8:60 (Definition) [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
-// CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: StructDecl=NonTemplateStruct:3:8 (Definition) [type=outer::NonTemplateStruct] [typekind=Record] [isPOD=1]
+// CHECK: ClassTemplate=Foo:6:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TemplateTypeParameter=T:5:19 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
+// CHECK: FieldDecl=t:7:5 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
+// CHECK: TypeRef=T:5:19 [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
+// CHECK: ClassTemplate=Baz:11:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TemplateTypeParameter=T:10:20 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
+// CHECK: NonTypeTemplateParameter=U:10:32 (Definition) [type=unsigned int] [typekind=UInt] [isPOD=1]
+// CHECK: TemplateTemplateParameter=W:10:60 

[PATCH] D12666: [LibClang] Fix clang_getCursorAvailability

2015-09-06 Thread Sergey Kalinichev via cfe-commits
skalinichev created this revision.
skalinichev added a subscriber: cfe-commits.

Make it report correct availability kind for deleted methods



http://reviews.llvm.org/D12666

Files:
  test/Index/availability.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6400,7 +6400,7 @@
 
 static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
   if (isa(D) && cast(D)->isDeleted())
-return CXAvailability_Available;
+return CXAvailability_NotAvailable;
   
   switch (D->getAvailability()) {
   case AR_Available:
Index: test/Index/availability.cpp
===
--- /dev/null
+++ test/Index/availability.cpp
@@ -0,0 +1,13 @@
+void foo() = delete;
+
+struct Foo {
+  int foo() = delete;
+  Foo() = delete;
+};
+
+
+// RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
+// CHECK: FunctionDecl=foo:1:6 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
+// CHECK: StructDecl=Foo:3:8 (Definition) [type=Foo] [typekind=Record] 
[isPOD=1]
+// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int ()] 
[typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
+// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6400,7 +6400,7 @@
 
 static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
   if (isa(D) && cast(D)->isDeleted())
-return CXAvailability_Available;
+return CXAvailability_NotAvailable;
   
   switch (D->getAvailability()) {
   case AR_Available:
Index: test/Index/availability.cpp
===
--- /dev/null
+++ test/Index/availability.cpp
@@ -0,0 +1,13 @@
+void foo() = delete;
+
+struct Foo {
+  int foo() = delete;
+  Foo() = delete;
+};
+
+
+// RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
+// CHECK: FunctionDecl=foo:1:6 (unavailable) [type=void ()] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
+// CHECK: StructDecl=Foo:3:8 (Definition) [type=Foo] [typekind=Record] [isPOD=1]
+// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int ()] [typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
+// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void ()] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2015-09-04 Thread Sergey Kalinichev via cfe-commits
skalinichev updated this revision to Diff 34019.
skalinichev added a comment.

Rebased.

Yes, now it's ready.


http://reviews.llvm.org/D11797

Files:
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -121,6 +121,11 @@
 if (const DecayedType *DT = T->getAs()) {
   return MakeCXType(DT->getOriginalType(), TU);
 }
+
+/* Handle elaborated types as the original type */
+if (const auto *ET = T->getAs()) {
+  return MakeCXType(ET->getNamedType(), TU);
+}
   }
   if (TK == CXType_Invalid)
 TK = GetTypeKind(T);
@@ -388,7 +393,6 @@
 
   Decl *D = nullptr;
 
-try_again:
   switch (TP->getTypeClass()) {
   case Type::Typedef:
 D = cast(TP)->getDecl();
@@ -417,10 +421,6 @@
 
   // FIXME: Template type parameters!  
 
-  case Type::Elaborated:
-TP = cast(TP)->getNamedType().getTypePtrOrNull();
-goto try_again;
-
   default:
 break;
   }
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType();
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] 
[typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo 
*){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo 
*){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] 
[resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] 
[typekind=Pointer] [canonicaltype=outer::Foo *] 
[canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] 
[pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] 
[typekind=Pointer] [canonicaltype=outer::Foo *] 
[canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Foo] 
[pointeekind=Unexposed]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -127,6 +127,9 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] 
[isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] 
[typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type ()] 
[typekind=FunctionProto] [canonicaltype=NS::Type ()] 
[canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Record] 
[isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] 
[isPOD=1]
 // CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Unexposed] 
[canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, 
int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, 
char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] 
[resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] 
[Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] 
[Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] 
[isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * 
sizeof(int int] [typekind=Vector] [isPOD=1]
 // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] 
[typekind=Typedef] [canonicaltype=__attribute__((__vector_size__(4 * 
sizeof(int int] [canonicaltypekind=Vector] [isPOD=1]
 // CHECK: ParmDecl=incompletearray:13:12 (Definition) [type=int []] 
[typekind=IncompleteArray] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedEnumType:15:25 [type=enum Enum ()] 
[typekind=FunctionNoProto] [canonicaltype=enum Enum ()] 
[canonicaltypekind=FunctionNoProto] 

Re: [PATCH] D11976: [libclang] Return deduced type for auto type, not the one written in the source.

2015-08-31 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Yes, please submit it.


http://reviews.llvm.org/D11976



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11976: [libclang] Return deduced type for auto type, not the one written in the source.

2015-08-22 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

This is actually an unrelated issue (clang_getTypeDeclaration doesn't handle 
the auto type)

Using c-index-test -test-print-type --std=c++14 on your example I get:
VarDecl=z ... [type=std::basic_stringchar] ...

So, as you can see, z has correct type.

Anyway here is a quick fix for clang_getTypeDeclaration (will create a review 
request for it later on): https://paste.kde.org/p1fiwhery


http://reviews.llvm.org/D11976



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11797: [libclang] Expose the ElaboratedType

2015-08-08 Thread Sergey Kalinichev via cfe-commits
skalinichev updated this revision to Diff 31576.
skalinichev marked 6 inline comments as done.
skalinichev added a comment.

Address raised issues.

modocache, great review btw, thanks!


http://reviews.llvm.org/D11797

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -208,6 +208,7 @@
 clang_getLocation
 clang_getLocationForOffset
 clang_getModuleForFile
+clang_getNamedTypeUnderlyingElaboratedType
 clang_getNullCursor
 clang_getNullLocation
 clang_getNullRange
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -90,6 +90,7 @@
 TKCASE(DependentSizedArray);
 TKCASE(Vector);
 TKCASE(MemberPointer);
+TKCASE(Elaborated);
 default:
   return CXType_Unexposed;
   }
@@ -484,6 +485,7 @@
 TKIND(DependentSizedArray);
 TKIND(Vector);
 TKIND(MemberPointer);
+TKIND(Elaborated);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -977,4 +979,14 @@
   return 0;
 }
 
+CXType clang_getNamedTypeUnderlyingElaboratedType(CXType CT){
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP  TP-getTypeClass() == Type::Elaborated)
+return MakeCXType(castElaboratedType(TP)-getNamedType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
+
 } // end: extern C
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,6 +48,8 @@
 };
 int Blob::*member_pointer;
 
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType();
+
 // RUN: c-index-test -test-print-type %s -std=c++11 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
@@ -61,7 +63,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foobool *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foobool *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foobool *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foobool *] [typekind=Pointer] [canonicaltype=outer::Foobool *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foobool] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foobool *] [typekind=Pointer] [canonicaltype=outer::Foobool *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foobool] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -119,3 +121,6 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type ()] [typekind=FunctionProto] [canonicaltype=NS::Type ()] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * sizeof(int int] [typekind=Vector] [isPOD=1]