antecipation of `CWG2563 <https://cplusplus.github.io/CWG/issues/2563.html>_`.
- Fix highlighting issue with ``_Complex`` and initialization list with more than
2 items. (`#61518 <https://github.com/llvm/llvm-project/issues/61518>`_)
+- Fix ``getSourceRange`` on ``VarTemplateSpecializationDecl`` and
+ ``VarTemplatePartialSpecializationDecl``, which represents variable with
+ the initializer, so it behaves consistently with other ``VarDecls`` and ends
+ on the last token of initializer, instead of right angle bracket of
+ the template argument list.
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
}
- SourceRange getSourceRange() const override LLVM_READONLY {
- if (isExplicitSpecialization()) {
- if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
- return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
- }
- return VarDecl::getSourceRange();
- }
+ SourceRange getSourceRange() const override LLVM_READONLY;
void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, TemplateArgs->asArray(), getASTContext());
return First->InstantiatedFromMember.setInt(true);
}
- SourceRange getSourceRange() const override LLVM_READONLY {
- if (isExplicitSpecialization()) {
- if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
- return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
- }
- return VarDecl::getSourceRange();
- }
+ SourceRange getSourceRange() const override LLVM_READONLY;
void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),
ASTTemplateArgumentListInfo::Create(getASTContext(), ArgsInfo);
}
+SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
+ if (isExplicitSpecialization() && !hasInit()) {
+ if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
+ return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+ }
+ return VarDecl::getSourceRange();
+}
+
+
//===----------------------------------------------------------------------===//
// VarTemplatePartialSpecializationDecl Implementation
//===----------------------------------------------------------------------===//
return new (C, ID) VarTemplatePartialSpecializationDecl(C);
}
+SourceRange VarTemplatePartialSpecializationDecl::getSourceRange() const {
+ if (isExplicitSpecialization() && !hasInit()) {
+ if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
+ return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+ }
+ return VarDecl::getSourceRange();
+}
+
static TemplateParameterList *
createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC) {
// typename T
template<>
float unTempl<float> = 1;
-// FIXME (#61680) - serializing and loading AST should not affect reported source range
-// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}} <line:{{[0-9]+}}:1, line:{{[0-9]+}}:20> col:7 unTempl 'float' cinit
-// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}} <line:{{[0-9]+}}:1, line:{{[0-9]+}}:24> col:7 unTempl 'float' cinit
+// CHECK: VarTemplateSpecializationDecl 0x{{[^ ]*}} <line:{{[0-9]+}}:1, line:{{[0-9]+}}:24> col:7 unTempl 'float' cinit
// CHECK-NEXT: |-TemplateArgument type 'float'
// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}} <col:24> 'float' <IntegralToFloating>
template<>
float binTempl<float, float> = 1;
-// FIXME (#61680) - serializing and loading AST should not affect reported source range
-// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}} <line:{{[0-9]+}}:1, line:{{[0-9]+}}:28> col:7 binTempl 'float' cinit
-// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}} <line:{{[0-9]+}}:1, line:{{[0-9]+}}:32> col:7 binTempl 'float' cinit
+// CHECK: VarTemplateSpecializationDecl 0x{{[^ ]*}} <line:{{[0-9]+}}:1, line:{{[0-9]+}}:32> col:7 binTempl 'float' cinit
// CHECK-NEXT: |-TemplateArgument type 'float'
// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
// CHECK-NEXT: |-TemplateArgument type 'float'