aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-02 00:07:54 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-02 00:07:54 +0000
commite0329acf5c9437e2086a2fb2bf7a95ae2ac96505 (patch)
tree20eca64e62fe41b8664256fa556925769fc86c51 /tools/c-index-test/c-index-test.c
parentfcf431609769a9600c24618d1a33135caec4fef2 (diff)
Introduce a new libclang function,
clang_getSpecializedCursorTemplate(), which determines the template (or member thereof) that the given cursor specializes or from which it was instantiated. This routine can be used to establish a link between templates and their instantiations/specializations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/c-index-test/c-index-test.c')
-rw-r--r--tools/c-index-test/c-index-test.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index cdf0cd06b5..58eff97ef8 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -166,7 +166,8 @@ static void PrintCursor(CXCursor Cursor) {
CXString string, ks;
CXCursor Referenced;
unsigned line, column;
-
+ CXCursor SpecializationOf;
+
ks = clang_getCursorKindSpelling(Cursor.kind);
string = clang_getCursorSpelling(Cursor);
printf("%s=%s", clang_getCString(ks),
@@ -224,6 +225,16 @@ static void PrintCursor(CXCursor Cursor) {
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_getInstantiationLocation(Loc, 0, &line, &column, 0);
+ printf(" [Specialization of %s:%d:%d]",
+ clang_getCString(Name), line, column);
+ clang_disposeString(Name);
+ }
}
}