Disable variable PrettyPrint #if CINDEX_VERSION >= 47 and allow trunk libclang in tests

This commit is contained in:
Fangrui Song 2018-02-12 19:13:21 -08:00
parent ef5db9b3fe
commit 10437aa642
2 changed files with 12 additions and 7 deletions

View File

@ -309,9 +309,13 @@ struct IndexParam {
print_policy = clang_getCursorPrintingPolicy(cursor); print_policy = clang_getCursorPrintingPolicy(cursor);
clang_PrintingPolicy_setProperty(print_policy, clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_TerseOutput, 1); CXPrintingPolicy_TerseOutput, 1);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_FullyQualifiedName, 1);
clang_PrintingPolicy_setProperty(print_policy, clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_SuppressInitializers, 1); CXPrintingPolicy_SuppressInitializers, 1);
print_policy_more = clang_getCursorPrintingPolicy(cursor); print_policy_more = clang_getCursorPrintingPolicy(cursor);
clang_PrintingPolicy_setProperty(print_policy_more,
CXPrintingPolicy_FullyQualifiedName, 1);
clang_PrintingPolicy_setProperty(print_policy_more, clang_PrintingPolicy_setProperty(print_policy_more,
CXPrintingPolicy_TerseOutput, 1); CXPrintingPolicy_TerseOutput, 1);
} }
@ -566,8 +570,9 @@ void SetVarDetail(IndexVar* var,
def.comments = cursor.get_comments(); def.comments = cursor.get_comments();
def.storage = GetStorageClass(clang_Cursor_getStorageClass(cursor.cx_cursor)); def.storage = GetStorageClass(clang_Cursor_getStorageClass(cursor.cx_cursor));
// TODO how to make PrettyPrint'ed variable name qualified?
std::string qualified_name = std::string qualified_name =
#if CINDEX_HAVE_PRETTY #if 0 && CINDEX_HAVE_PRETTY
cursor.get_kind() != CXCursor_EnumConstantDecl cursor.get_kind() != CXCursor_EnumConstantDecl
? param->PrettyPrintCursor(cursor.cx_cursor) ? param->PrettyPrintCursor(cursor.cx_cursor)
: :
@ -587,9 +592,8 @@ void SetVarDetail(IndexVar* var,
def.detailed_name = std::move(qualified_name); def.detailed_name = std::move(qualified_name);
def.hover = hover; def.hover = hover;
} else { } else {
#if CINDEX_HAVE_PRETTY #if 0 && CINDEX_HAVE_PRETTY
def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor, false); //def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor, false);
def.hover = std::move(qualified_name);
#else #else
ConcatTypeAndName(type_name, qualified_name); ConcatTypeAndName(type_name, qualified_name);
def.detailed_name = type_name; def.detailed_name = type_name;
@ -1349,7 +1353,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
SetUse(db, &ref_index->def.spell, ref_cursor.get_spelling_range(), parent, Role::Definition); SetUse(db, &ref_index->def.spell, ref_cursor.get_spelling_range(), parent, Role::Definition);
SetUse(db, &ref_index->def.extent, ref_cursor.get_extent(), parent, Role::None); SetUse(db, &ref_index->def.extent, ref_cursor.get_extent(), parent, Role::None);
#if CINDEX_HAVE_PRETTY #if CINDEX_HAVE_PRETTY
ref_index->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor); ref_index->def.detailed_name = param->PrettyPrintCursor(ref_cursor.cx_cursor);
#else #else
ref_index->def.detailed_name = ref_cursor.get_spelling(); ref_index->def.detailed_name = ref_cursor.get_spelling();
#endif #endif
@ -1377,7 +1381,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
SetUse(db, &ref_index->def.spell, ref_cursor.get_spelling_range(), parent, Role::Definition); SetUse(db, &ref_index->def.spell, ref_cursor.get_spelling_range(), parent, Role::Definition);
SetUse(db, &ref_index->def.extent, ref_cursor.get_extent(), parent, Role::None); SetUse(db, &ref_index->def.extent, ref_cursor.get_extent(), parent, Role::None);
#if CINDEX_HAVE_PRETTY #if CINDEX_HAVE_PRETTY
ref_index->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor); ref_index->def.detailed_name = param->PrettyPrintCursor(ref_cursor.cx_cursor);
#else #else
ref_index->def.detailed_name = ref_cursor.get_spelling(); ref_index->def.detailed_name = ref_cursor.get_spelling();
#endif #endif

View File

@ -150,7 +150,8 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) {
// Index tests change based on the version of clang used. // Index tests change based on the version of clang used.
static constexpr const char* kRequiredClangVersion = static constexpr const char* kRequiredClangVersion =
"clang version 5.0.1 (tags/RELEASE_501/final)"; "clang version 5.0.1 (tags/RELEASE_501/final)";
if (GetClangVersion() != kRequiredClangVersion) { if (GetClangVersion() != kRequiredClangVersion &&
GetClangVersion().find("trunk") == std::string::npos) {
std::cerr << "Index tests must be run using clang version \"" std::cerr << "Index tests must be run using clang version \""
<< kRequiredClangVersion << "\" (cquery is running with \"" << kRequiredClangVersion << "\" (cquery is running with \""
<< GetClangVersion() << "\")" << std::endl; << GetClangVersion() << "\")" << std::endl;