libclang: New functions clang_Type_getNumTemplateArguments,
clang_Type_getTemplateArgument

Note that these functions don't handle variadic templates -- see tests.

Patch by Matthieu Nottale and Philippe Daouadi.

llvm-svn: 202406
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 3a47ae4..defc916 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -1263,11 +1263,11 @@
     }
     /* Print the argument types if they exist. */
     {
-      int numArgs = clang_Cursor_getNumArguments(cursor);
-      if (numArgs != -1 && numArgs != 0) {
+      int NumArgs = clang_Cursor_getNumArguments(cursor);
+      if (NumArgs != -1 && NumArgs != 0) {
         int i;
         printf(" [args=");
-        for (i = 0; i < numArgs; ++i) {
+        for (i = 0; i < NumArgs; ++i) {
           CXType T = clang_getCursorType(clang_Cursor_getArgument(cursor, i));
           if (T.kind != CXType_Invalid) {
             PrintTypeAndTypeKind(T, " [%s] [%s]");
@@ -1276,6 +1276,21 @@
         printf("]");
       }
     }
+    /* Print the template argument types if they exist. */
+    {
+      int NumTArgs = clang_Type_getNumTemplateArguments(T);
+      if (NumTArgs != -1 && NumTArgs != 0) {
+        int i;
+        printf(" [templateargs/%d=", NumTArgs);
+        for (i = 0; i < NumTArgs; ++i) {
+          CXType TArg = clang_Type_getTemplateArgumentAsType(T, i);
+          if (TArg.kind != CXType_Invalid) {
+            PrintTypeAndTypeKind(TArg, " [type=%s] [typekind=%s]");
+          }
+        }
+        printf("]");
+      }
+    }
     /* Print if this is a non-POD type. */
     printf(" [isPOD=%d]", clang_isPODType(T));