[PATCH] D85842: Fix `NestedNameSpecifierLoc::getLocalSourceRange()`

Eduardo Caldas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 12 09:58:32 PDT 2020


eduucaldas updated this revision to Diff 285129.
eduucaldas added a comment.

Update comment


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,20 @@
     // 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>::`.
+    // For any TypeLoc we can just use `TypeLoc::getBeginLoc()` to
+    // get the beginning of this LocalSourceRange but for dependent template
+    // specializations `getBeginLoc` returns the location of `T` yielding
+    // `T::template ST<int>::`.
+    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*)));
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85842.285129.patch
Type: text/x-patch
Size: 1286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200812/4cdb67af/attachment.bin>


More information about the cfe-commits mailing list