eduucaldas created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. eduucaldas requested review of this revision.
>From the documentation comment above >`NestedNameSpecifierLoc::getLocalSourceRange()` /// Retrieve the source range covering just the last part of /// this nested-name-specifier, not including the prefix. /// /// For example, if this instance refers to a nested-name-specifier /// \c \::std::vector<int>::, the returned source range would cover /// from "vector" to the last '::'. We would expect that for a nested-name-specifier with a dependent template specialization type: `T::template ST<int>::` `NestedNameSpecifierLoc::getLocalSourceRange()` would return `template ST<int>::` but instead it returns `T::template ST<int>::`. The issue might as well be on `DependentTemplateSpecializationTypeLoc::getLocalSourceRange()` which is indirectly called from `NestedNameSpecifierLoc::getLocalSourceRange()`. I think not. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D85842 Files: clang/lib/AST/NestedNameSpecifier.cpp Index: clang/lib/AST/NestedNameSpecifier.cpp =================================================================== --- clang/lib/AST/NestedNameSpecifier.cpp +++ clang/lib/AST/NestedNameSpecifier.cpp @@ -439,6 +439,14 @@ // Note: the 'template' keyword is part of the TypeLoc. void *TypeData = LoadPointer(Data, Offset); TypeLoc TL(Qualifier->getAsType(), TypeData); + // For `T::template ST<int>::x` + // `NestedNameSpecifierLoc::getLocalSourceRange()` should return `template + // ST<int>::` but `DependentTemplateSpecializationTypeLoc::getBeginLoc()` + // returns `^T::temp...` + if (auto DependentTL = TL.getAs<DependentTemplateSpecializationTypeLoc>()) { + return SourceRange(DependentTL.getTemplateKeywordLoc(), + LoadSourceLocation(Data, Offset + sizeof(void *))); + } return SourceRange(TL.getBeginLoc(), LoadSourceLocation(Data, Offset + sizeof(void*))); }
Index: clang/lib/AST/NestedNameSpecifier.cpp =================================================================== --- clang/lib/AST/NestedNameSpecifier.cpp +++ clang/lib/AST/NestedNameSpecifier.cpp @@ -439,6 +439,14 @@ // Note: the 'template' keyword is part of the TypeLoc. void *TypeData = LoadPointer(Data, Offset); TypeLoc TL(Qualifier->getAsType(), TypeData); + // For `T::template ST<int>::x` + // `NestedNameSpecifierLoc::getLocalSourceRange()` should return `template + // ST<int>::` but `DependentTemplateSpecializationTypeLoc::getBeginLoc()` + // returns `^T::temp...` + if (auto DependentTL = TL.getAs<DependentTemplateSpecializationTypeLoc>()) { + return SourceRange(DependentTL.getTemplateKeywordLoc(), + LoadSourceLocation(Data, Offset + sizeof(void *))); + } return SourceRange(TL.getBeginLoc(), LoadSourceLocation(Data, Offset + sizeof(void*))); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits