summaryrefslogtreecommitdiffstats
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-10-23 14:22:18 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-10-23 14:22:18 +0000
commit5563df30b9c8d1fe87a54baae0d6bd86642563f4 (patch)
tree3fdd91eae574e32453a4baf462961c742df2691a /tools/c-index-test/c-index-test.c
parente5557c18e5d41b4b62f2af8a24af20eba40b0225 (diff)
downloadFreeBSD-src-5563df30b9c8d1fe87a54baae0d6bd86642563f4.zip
FreeBSD-src-5563df30b9c8d1fe87a54baae0d6bd86642563f4.tar.gz
Update clang to r84949.
Diffstat (limited to 'tools/c-index-test/c-index-test.c')
-rw-r--r--tools/c-index-test/c-index-test.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index c514b63..cf2a706 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -53,17 +53,23 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
unsigned curLine = startLine, curColumn = startColumn;
CXCursor Ref;
- while (startBuf <= endBuf) {
+ while (startBuf < endBuf) {
+ CXLookupHint hint;
if (*startBuf == '\n') {
startBuf++;
curLine++;
curColumn = 1;
} else if (*startBuf != '\t')
curColumn++;
+
+ clang_initCXLookupHint(&hint);
+ hint.decl = Cursor.decl;
- Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor),
- curLine, curColumn);
- if (Ref.kind != CXCursor_FunctionDecl) {
+ Ref = clang_getCursorWithHint(Unit, clang_getCursorSource(Cursor),
+ curLine, curColumn, &hint);
+ if (Ref.kind == CXCursor_NoDeclFound) {
+ /* Nothing found here; that's fine. */
+ } else if (Ref.kind != CXCursor_FunctionDecl) {
printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Ref)),
curLine, curColumn);
PrintCursor(Ref);
@@ -85,12 +91,23 @@ int main(int argc, char **argv) {
return 0;
}
{
- CXIndex Idx = clang_createIndex();
- CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]);
+ CXIndex Idx;
+ CXTranslationUnit TU;
enum CXCursorKind K = CXCursor_NotImplemented;
+
+ Idx = clang_createIndex(/* excludeDeclsFromPCH */ !strcmp(argv[2], "local") ? 1 : 0,
+ /* displayDiagnostics */ 1);
+
+ TU = clang_createTranslationUnit(Idx, argv[1]);
- if (!strcmp(argv[2], "all")) {
+ if (!TU) {
+ fprintf(stderr, "Unable to load translation unit!\n");
+ return 1;
+ }
+
+ if (!strcmp(argv[2], "all") || !strcmp(argv[2], "local")) {
clang_loadTranslationUnit(TU, TranslationUnitVisitor, 0);
+ clang_disposeTranslationUnit(TU);
return 1;
}
/* Perform some simple filtering. */
@@ -101,6 +118,7 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[2], "typedef")) K = CXCursor_TypedefDecl;
clang_loadTranslationUnit(TU, TranslationUnitVisitor, &K);
+ clang_disposeTranslationUnit(TU);
return 1;
}
}
OpenPOWER on IntegriCloud