eduucaldas updated this revision to Diff 285122.
eduucaldas added a comment.
Don't assume the code is completely correct
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85842/new/
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,17 @@
// 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>())
{
+ if (getTemplateKeywordLoc().isValid())
+ return SourceRange(getTemplateKeywordLoc(),
+ LoadSourceLocation(Data, Offset + sizeof(void *)));
+ return SourceRange(getTemplateNameLoc(),
+ 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,17 @@
// 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>()) {
+ if (getTemplateKeywordLoc().isValid())
+ return SourceRange(getTemplateKeywordLoc(),
+ LoadSourceLocation(Data, Offset + sizeof(void *)));
+ return SourceRange(getTemplateNameLoc(),
+ LoadSourceLocation(Data, Offset + sizeof(void *)));
+ }
return SourceRange(TL.getBeginLoc(),
LoadSourceLocation(Data, Offset + sizeof(void*)));
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits