зеркало из https://github.com/microsoft/clang-1.git
Add '-test-print-linkage-source' option to c-index-test
to test clang_getCursorLinkage() git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97648 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
5b6493696c
Коммит
3bed527b10
|
@ -0,0 +1,23 @@
|
|||
// RUN: c-index-test -test-print-linkage-source %s | FileCheck %s
|
||||
|
||||
enum Baz { Qux = 0 };
|
||||
int x;
|
||||
void foo();
|
||||
static int w;
|
||||
void bar(int y) {
|
||||
static int z;
|
||||
int k;
|
||||
}
|
||||
extern int n;
|
||||
|
||||
// CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External
|
||||
// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=External
|
||||
// CHECK: VarDecl=x:4:5linkage=External
|
||||
// CHECK: FunctionDecl=foo:5:6linkage=External
|
||||
// CHECK: VarDecl=w:6:12linkage=External
|
||||
// CHECK: FunctionDecl=bar:7:6 (Definition)linkage=External
|
||||
// CHECK: ParmDecl=y:7:14 (Definition)linkage=External
|
||||
// CHECK: VarDecl=z:8:14 (Definition)linkage=External
|
||||
// CHECK: VarDecl=k:9:7 (Definition)linkage=External
|
||||
// CHECK: VarDecl=n:11:12
|
||||
|
|
@ -418,6 +418,33 @@ void PrintInclusionStack(CXTranslationUnit TU) {
|
|||
clang_getInclusions(TU, InclusionVisitor, NULL);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Linkage testing. */
|
||||
/******************************************************************************/
|
||||
|
||||
static enum CXChildVisitResult PrintLinkage(CXCursor cursor, CXCursor p,
|
||||
CXClientData d) {
|
||||
const char *linkage = 0;
|
||||
|
||||
if (clang_isInvalid(clang_getCursorKind(cursor)))
|
||||
return CXChildVisit_Recurse;
|
||||
|
||||
switch (clang_getCursorLinkage(cursor)) {
|
||||
case CXLinkage_Invalid: break;
|
||||
case CXLinkage_NoLinkage: linkage = "NoLinkage";
|
||||
case CXLinkage_Internal: linkage = "Internal";
|
||||
case CXLinkage_UniqueExternal: linkage = "UniqueExternal";
|
||||
case CXLinkage_External: linkage = "External";
|
||||
}
|
||||
|
||||
if (linkage) {
|
||||
PrintCursor(cursor);
|
||||
printf("linkage=%s\n", linkage);
|
||||
}
|
||||
|
||||
return CXChildVisit_Recurse;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Loading ASTs/source. */
|
||||
/******************************************************************************/
|
||||
|
@ -978,7 +1005,8 @@ static void print_usage(void) {
|
|||
fprintf(stderr,
|
||||
" c-index-test -test-annotate-tokens=<range> {<args>}*\n"
|
||||
" c-index-test -test-inclusion-stack-source {<args>}*\n"
|
||||
" c-index-test -test-inclusion-stack-tu <AST file>\n\n"
|
||||
" c-index-test -test-inclusion-stack-tu <AST file>\n"
|
||||
" c-index-test -test-print-linkage-source {<args>}*\n\n"
|
||||
" <symbol filter> values:\n%s",
|
||||
" all - load all symbols, including those from PCH\n"
|
||||
" local - load all symbols except those in PCH\n"
|
||||
|
@ -1018,6 +1046,9 @@ int main(int argc, const char **argv) {
|
|||
else if (argc > 2 && strcmp(argv[1], "-test-inclusion-stack-tu") == 0)
|
||||
return perform_test_load_tu(argv[2], "all", NULL, NULL,
|
||||
PrintInclusionStack);
|
||||
else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0)
|
||||
return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage,
|
||||
NULL);
|
||||
|
||||
print_usage();
|
||||
return 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче