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);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_TerseOutput, 1);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_FullyQualifiedName, 1);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_SuppressInitializers, 1);
print_policy_more = clang_getCursorPrintingPolicy(cursor);
clang_PrintingPolicy_setProperty(print_policy_more,
CXPrintingPolicy_FullyQualifiedName, 1);
clang_PrintingPolicy_setProperty(print_policy_more,
CXPrintingPolicy_TerseOutput, 1);
}
@ -566,8 +570,9 @@ void SetVarDetail(IndexVar* var,
def.comments = cursor.get_comments();
def.storage = GetStorageClass(clang_Cursor_getStorageClass(cursor.cx_cursor));
// TODO how to make PrettyPrint'ed variable name qualified?
std::string qualified_name =
#if CINDEX_HAVE_PRETTY
#if 0 && CINDEX_HAVE_PRETTY
cursor.get_kind() != CXCursor_EnumConstantDecl
? param->PrettyPrintCursor(cursor.cx_cursor)
:
@ -587,9 +592,8 @@ void SetVarDetail(IndexVar* var,
def.detailed_name = std::move(qualified_name);
def.hover = hover;
} else {
#if CINDEX_HAVE_PRETTY
def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor, false);
def.hover = std::move(qualified_name);
#if 0 && CINDEX_HAVE_PRETTY
//def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor, false);
#else
ConcatTypeAndName(type_name, qualified_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.extent, ref_cursor.get_extent(), parent, Role::None);
#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
ref_index->def.detailed_name = ref_cursor.get_spelling();
#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.extent, ref_cursor.get_extent(), parent, Role::None);
#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
ref_index->def.detailed_name = ref_cursor.get_spelling();
#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.
static constexpr const char* kRequiredClangVersion =
"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 \""
<< kRequiredClangVersion << "\" (cquery is running with \""
<< GetClangVersion() << "\")" << std::endl;