From c06beb21cb03baf3becc74a092bad0b681c9ddfe Mon Sep 17 00:00:00 2001 From: malte_langkabel Date: Wed, 21 Oct 2015 19:56:47 +0200 Subject: [PATCH] data: template class/function scope locations * Added source locations of template parameters to the scope of template classes and functions to improve context availability in the code view. --- src/lib/data/parser/cxx/ASTVisitor.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lib/data/parser/cxx/ASTVisitor.cpp b/src/lib/data/parser/cxx/ASTVisitor.cpp index a4f0923b..c717731d 100644 --- a/src/lib/data/parser/cxx/ASTVisitor.cpp +++ b/src/lib/data/parser/cxx/ASTVisitor.cpp @@ -876,7 +876,18 @@ ParseLocation ASTVisitor::getParseLocationOfFunctionBody(const clang::FunctionDe { if (decl->hasBody() && decl->isThisDeclarationADefinition()) { - return getParseLocation(decl->getSourceRange()); + clang::SourceRange range; + clang::FunctionTemplateDecl* templateDecl = decl->getDescribedFunctionTemplate(); + if (templateDecl) + { + range = templateDecl->getSourceRange(); + } + else + { + range = decl->getSourceRange(); + } + + return getParseLocation(range); } return ParseLocation(); @@ -886,7 +897,18 @@ ParseLocation ASTVisitor::getParseLocationOfRecordBody(clang::CXXRecordDecl* dec { if (decl->hasDefinition() && decl->isThisDeclarationADefinition()) { - return getParseLocation(decl->getDefinition()->getSourceRange()); + clang::SourceRange range; + clang::ClassTemplateDecl* templateDecl = decl->getDescribedClassTemplate(); + if (templateDecl) + { + range = templateDecl->getSourceRange(); + } + else + { + range = decl->getDefinition()->getSourceRange(); + } + + return getParseLocation(range); } return ParseLocation();