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

2015-12-14 Thread Milian Wolff via cfe-commits
milianw added a comment.

lgtm, but someone else should approve


http://reviews.llvm.org/D13001



___
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-14 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13001



___
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] D13001: [libclang] Handle AutoType in clang_getTypeDeclaration

2015-10-19 Thread Manuel Klimek via cfe-commits
klimek added a comment.

+1 to "not tested before" not implying "doesn't need tests" :)


http://reviews.llvm.org/D13001



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


[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