summaryrefslogtreecommitdiffstats
path: root/tools/c-index-test
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-12-16 21:40:16 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-12-16 21:40:16 +0000
commit559be57f7aef4446004906e2c3796474fabf1664 (patch)
tree0e1eacc3ace7aa3645b51643ec0ea3abfe967c1e /tools/c-index-test
parent7fdb98e4e14616ecbea0439380888091d45174cf (diff)
[libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType
Patch by Emilio Cobos Álvarez! See https://reviews.llvm.org/D26907 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/c-index-test')
-rw-r--r--tools/c-index-test/c-index-test.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index de87351059..dfb4b27bce 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1316,6 +1316,25 @@ static enum CXVisitorResult FieldVisitor(CXCursor C,
return CXVisit_Continue;
}
+static void PrintTypeTemplateArgs(CXType T, const char *Format) {
+ int NumTArgs = clang_Type_getNumTemplateArguments(T);
+ if (NumTArgs != -1 && NumTArgs != 0) {
+ int i;
+ CXType TArg;
+ printf(Format, NumTArgs);
+ for (i = 0; i < NumTArgs; ++i) {
+ TArg = clang_Type_getTemplateArgumentAsType(T, i);
+ if (TArg.kind != CXType_Invalid) {
+ PrintTypeAndTypeKind(TArg, " [type=%s] [typekind=%s]");
+ }
+ }
+ /* Ensure that the returned type is invalid when indexing off-by-one. */
+ TArg = clang_Type_getTemplateArgumentAsType(T, i);
+ assert(TArg.kind == CXType_Invalid);
+ printf("]");
+ }
+}
+
static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p,
CXClientData d) {
if (!clang_isInvalid(clang_getCursorKind(cursor))) {
@@ -1333,11 +1352,14 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p,
printf(" lvalue-ref-qualifier");
if (RQ == CXRefQualifier_RValue)
printf(" rvalue-ref-qualifier");
+ /* Print the template argument types if they exist. */
+ PrintTypeTemplateArgs(T, " [templateargs/%d=");
/* Print the canonical type if it is different. */
{
CXType CT = clang_getCanonicalType(T);
if (!clang_equalTypes(T, CT)) {
PrintTypeAndTypeKind(CT, " [canonicaltype=%s] [canonicaltypekind=%s]");
+ PrintTypeTemplateArgs(CT, " [canonicaltemplateargs/%d=");
}
}
/* Print the return type if it exists. */
@@ -1362,21 +1384,6 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p,
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));
/* Print the pointee type. */