From fc1a43c1a5a50801559ace4abb2b6d08f2c32486 Mon Sep 17 00:00:00 2001 From: malte_langkabel Date: Mon, 22 Feb 2016 13:14:48 +0100 Subject: [PATCH] data: fixed indexer coverage * revised the check if a declaration is implicit. this affects whether or not the reference to the decl should be recorded. --- src/lib_parser/data/parser/cxx/ASTVisitor.cpp | 28 ++++++++++++++++--- src/lib_parser/data/parser/cxx/ASTVisitor.h | 2 ++ .../cxx/name_resolver/CxxTypeNameResolver.cpp | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/lib_parser/data/parser/cxx/ASTVisitor.cpp b/src/lib_parser/data/parser/cxx/ASTVisitor.cpp index 71bd9a75..76567659 100644 --- a/src/lib_parser/data/parser/cxx/ASTVisitor.cpp +++ b/src/lib_parser/data/parser/cxx/ASTVisitor.cpp @@ -1076,15 +1076,35 @@ void ASTVisitor::RecordTypeRef( } } +bool ASTVisitor::isImpliciit(clang::Decl* d) const +{ + if (!d) + { + return false; + } + + if (clang::ClassTemplateSpecializationDecl* ctsd = clang::dyn_cast_or_null(d)) + { + if (!ctsd->isExplicitSpecialization()) + { + return true; + } + } + + return isImpliciit(clang::dyn_cast_or_null(d->getDeclContext())); +} + void ASTVisitor::RecordDeclRef( - clang::NamedDecl *d, + clang::NamedDecl* d, clang::SourceLocation beginLoc, RefType refType, SymbolType symbolType) { - if ((!d) || - (d->isImplicit() && !isLocatedInProjectFile(beginLoc)) || - (!d->isImplicit() && !isLocatedInUnparsedProjectFile(beginLoc))) + bool isImplicit = isImpliciit(d); + + if (!d || + (isImplicit && !isLocatedInProjectFile(beginLoc)) || + (!isImplicit && !isLocatedInUnparsedProjectFile(beginLoc))) { return; } diff --git a/src/lib_parser/data/parser/cxx/ASTVisitor.h b/src/lib_parser/data/parser/cxx/ASTVisitor.h index 3a055f51..745a7a0c 100644 --- a/src/lib_parser/data/parser/cxx/ASTVisitor.h +++ b/src/lib_parser/data/parser/cxx/ASTVisitor.h @@ -287,6 +287,8 @@ private: RefType refType, SymbolType symbolType = ST_Max); + bool isImpliciit(clang::Decl* d) const; + void RecordDeclRef( clang::NamedDecl *d, clang::SourceLocation beginLoc, diff --git a/src/lib_parser/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp b/src/lib_parser/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp index e1e5b27d..d8dfcb17 100644 --- a/src/lib_parser/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp +++ b/src/lib_parser/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp @@ -116,7 +116,7 @@ std::shared_ptr CxxTypeNameResolver::typeToDataType(const clang::Type* CxxDeclNameResolver declNameResolver(tagType->getDecl(), getIgnoredContextDecls()); typeNameHerarchy = declNameResolver.getDeclNameHierarchy(); } - else // specialization of a template template parameter (no concrete class) + else // specialization of a template template parameter (no concrete class) important, may help: has no underlying decl! { const clang::TemplateSpecializationType* templateSpecializationType = type->getAs(); CxxDeclNameResolver declNameResolver(templateSpecializationType->getTemplateName().getAsTemplateDecl(), getIgnoredContextDecls());