From 893e647306ab121567553d5fe1adbbdae041aed7 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 20 Jul 2010 12:54:49 +0200 Subject: Use the location of the unqualified name id. --- src/shared/cplusplus/Semantic.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/shared/cplusplus/Semantic.cpp') diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp index be08ebdf7a..019852cc78 100644 --- a/src/shared/cplusplus/Semantic.cpp +++ b/src/shared/cplusplus/Semantic.cpp @@ -316,4 +316,38 @@ int Semantic::visibilityForClassKey(int tokenKind) const } } +unsigned Semantic::location(DeclaratorAST *ast) const +{ + if (! ast) + return 0; + + else if (CPlusPlus::CoreDeclaratorAST *core = ast->core_declarator) + return location(core); + + return ast->firstToken(); +} + +unsigned Semantic::location(CoreDeclaratorAST *ast) const +{ + if (! ast) + return 0; + + else if (CPlusPlus::DeclaratorIdAST *declaratorId = ast->asDeclaratorId()) + return location(declaratorId->name); + else if (CPlusPlus::NestedDeclaratorAST *nested = ast->asNestedDeclarator()) + return location(nested->declarator); + + return ast->firstToken(); +} + +unsigned Semantic::location(NameAST *ast) const +{ + if (! ast) + return 0; + + else if (CPlusPlus::QualifiedNameAST *qualifiedName = ast->asQualifiedName()) + return location(qualifiedName->unqualified_name); + + return ast->firstToken(); +} -- cgit v1.2.1