[all-commits] [llvm/llvm-project] a826b9: [clang] source range of variable template speciali...

tomasz-kaminski-sonarsource via All-commits all-commits at lists.llvm.org
Mon Mar 27 03:37:45 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a826b9034bbd046a5d0708ba656a3d345d179920
      https://github.com/llvm/llvm-project/commit/a826b9034bbd046a5d0708ba656a3d345d179920
  Author: Tomasz Kamiński <tomasz.kamiński at sonarsource.com>
  Date:   2023-03-27 (Mon, 27 Mar 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/DeclTemplate.h
    M clang/lib/AST/DeclTemplate.cpp
    M clang/test/AST/ast-dump-template-decls.cpp

  Log Message:
  -----------
  [clang] source range of variable template specialization should include initializer

This patch adjust the getSourceRange() for the
VarTemplateSpecializationDecl and VarTemplatePartialSpecializationDecl,
such that the initializer is included if present:
```
template<typename T>
T temp = 1;

template<> double temp<double> = 1;
```
This patch makes it consistent with the behavior of
non-template variables with initializers and restores
behavior that was present before https://reviews.llvm.org/D139705.

n case, when the initializer is not present we still
include the template arguments in the source range,
which was required for fixing zero-initialization fix-it.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D146733




More information about the All-commits mailing list