================
@@ -1104,6 +1104,19 @@ class FunctionTemplateDecl : public 
RedeclarableTemplateDecl {
   static FunctionTemplateDecl *CreateDeserialized(ASTContext &C,
                                                   GlobalDeclID ID);
 
+  SourceRange getSourceRange() const override LLVM_READONLY {
+    SourceLocation BeginLoc = getTemplateParameters()->getTemplateLoc();
+    if (BeginLoc.isInvalid() && isAbbreviated()) {
+      // The BeginLoc of FunctionTemplateDecls is derived from the template
+      // keyword. But "pure" abbreviated templates do not use the template
+      // keyword. Hence the BeginLoc is invalid. Therefore just use the
+      // beginning of the templated declaration instead.
+      BeginLoc = getTemplatedDecl()->getBeginLoc();
+    }
+
+    return SourceRange(BeginLoc, TemplatedDecl->getSourceRange().getEnd());
+  }
+
----------------
zyn0217 wrote:

(Sorry I missed your comment)

For lambdas, I think you will have some luck in 
`SemaLambda.cpp:getGenericLambdaTemplateParameterList`, which should be first 
called from `Sema::ActOnLambdaClosureParameters`.

> But with the new change I am kind of misusing the attributes of 
> TemplateParameterList.

I think they are just fine? It's already marked as 'invented' so it might also 
be reasonable to extend the meaning of TemplateLoc and AngleLoc.

@cor3ntin in case you have any thoughts


https://github.com/llvm/llvm-project/pull/174723
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to