aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2014-10-10 20:01:05 +0000
committerEli Bendersky <eliben@google.com>2014-10-10 20:01:05 +0000
commitc27a0c490c70c700475b25f29fa1142c44faf0da (patch)
treefeee97596434562ea1befd0e4b440a2e4c0adcdb /clang/tools/c-index-test/c-index-test.c
parentf42585fd96a1cb486b800925008031db80919de9 (diff)
downloadllvm-c27a0c490c70c700475b25f29fa1142c44faf0da.zip
llvm-c27a0c490c70c700475b25f29fa1142c44faf0da.tar.gz
llvm-c27a0c490c70c700475b25f29fa1142c44faf0da.tar.bz2
Add libclang capabilities to retriete template arguments from specializations.
Includes Python bindings. Reviewed in http://reviews.llvm.org/D5621 Patch by Rob Springer llvm-svn: 219529
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index d7c28dd..56e4101 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -796,15 +796,42 @@ static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) {
printf(" [access=%s isVirtual=%s]", accessStr,
isVirtual ? "true" : "false");
}
-
+
SpecializationOf = clang_getSpecializedCursorTemplate(Cursor);
if (!clang_equalCursors(SpecializationOf, clang_getNullCursor())) {
CXSourceLocation Loc = clang_getCursorLocation(SpecializationOf);
CXString Name = clang_getCursorSpelling(SpecializationOf);
clang_getSpellingLocation(Loc, 0, &line, &column, 0);
- printf(" [Specialization of %s:%d:%d]",
+ printf(" [Specialization of %s:%d:%d]",
clang_getCString(Name), line, column);
clang_disposeString(Name);
+
+ if (Cursor.kind == CXCursor_FunctionDecl) {
+ /* Collect the template parameter kinds from the base template. */
+ unsigned NumTemplateArgs = clang_Cursor_getNumTemplateArguments(Cursor);
+ unsigned I;
+ for (I = 0; I < NumTemplateArgs; I++) {
+ enum CXTemplateArgumentKind TAK =
+ clang_Cursor_getTemplateArgumentKind(Cursor, I);
+ switch(TAK) {
+ case CXTemplateArgumentKind_Type:
+ {
+ CXType T = clang_Cursor_getTemplateArgumentType(Cursor, I);
+ CXString S = clang_getTypeSpelling(T);
+ printf(" [Template arg %d: kind: %d, type: %s]",
+ I, TAK, clang_getCString(S));
+ clang_disposeString(S);
+ }
+ break;
+ case CXTemplateArgumentKind_Integral:
+ printf(" [Template arg %d: kind: %d, intval: %lld]",
+ I, TAK, clang_Cursor_getTemplateArgumentValue(Cursor, I));
+ break;
+ default:
+ printf(" [Template arg %d: kind: %d]\n", I, TAK);
+ }
+ }
+ }
}
clang_getOverriddenCursors(Cursor, &overridden, &num_overridden);