forked from OSchip/llvm-project
[clang] Fix missing template arguments in AST of access to member variable template
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D134295
This commit is contained in:
parent
1dc48a916a
commit
c493d49cef
|
@ -158,6 +158,8 @@ Bug Fixes
|
||||||
- Fixed a crash in C++20 mode in Clang and Clangd when compile source
|
- Fixed a crash in C++20 mode in Clang and Clangd when compile source
|
||||||
with compilation errors.
|
with compilation errors.
|
||||||
`Issue 53628 <https://github.com/llvm/llvm-project/issues/53628>`_
|
`Issue 53628 <https://github.com/llvm/llvm-project/issues/53628>`_
|
||||||
|
- The template arguments of a variable template being accessed as a
|
||||||
|
member will now be represented in the AST.
|
||||||
|
|
||||||
|
|
||||||
Improvements to Clang's diagnostics
|
Improvements to Clang's diagnostics
|
||||||
|
|
|
@ -1161,10 +1161,10 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
|
||||||
if (!Var->getTemplateSpecializationKind())
|
if (!Var->getTemplateSpecializationKind())
|
||||||
Var->setTemplateSpecializationKind(TSK_ImplicitInstantiation, MemberLoc);
|
Var->setTemplateSpecializationKind(TSK_ImplicitInstantiation, MemberLoc);
|
||||||
|
|
||||||
return BuildMemberExpr(
|
return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Var,
|
||||||
BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Var, FoundDecl,
|
FoundDecl, /*HadMultipleCandidates=*/false,
|
||||||
/*HadMultipleCandidates=*/false, MemberNameInfo,
|
MemberNameInfo, Var->getType().getNonReferenceType(),
|
||||||
Var->getType().getNonReferenceType(), VK_LValue, OK_Ordinary);
|
VK_LValue, OK_Ordinary, TemplateArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We found something that we didn't expect. Complain.
|
// We found something that we didn't expect. Complain.
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct TypeSuffix {
|
||||||
template <long> static int x; // expected-note {{forward declaration of template entity is here}}
|
template <long> static int x; // expected-note {{forward declaration of template entity is here}}
|
||||||
template <auto> static int y; // expected-note {{forward declaration of template entity is here}}
|
template <auto> static int y; // expected-note {{forward declaration of template entity is here}}
|
||||||
};
|
};
|
||||||
// CHECK: int k = TypeSuffix().x + TypeSuffix().y;
|
// CHECK: int k = TypeSuffix().x<0L> + TypeSuffix().y<0L>;
|
||||||
int k = TypeSuffix().x<0L> + TypeSuffix().y<0L>; // expected-warning {{instantiation of variable 'TypeSuffix::x<0>' required here, but no definition is available}} \
|
int k = TypeSuffix().x<0L> + TypeSuffix().y<0L>; // expected-warning {{instantiation of variable 'TypeSuffix::x<0>' required here, but no definition is available}} \
|
||||||
// expected-note {{add an explicit instantiation declaration to suppress this warning if 'TypeSuffix::x<0>' is explicitly instantiated in another translation unit}} \
|
// expected-note {{add an explicit instantiation declaration to suppress this warning if 'TypeSuffix::x<0>' is explicitly instantiated in another translation unit}} \
|
||||||
// expected-warning {{instantiation of variable 'TypeSuffix::y<0L>' required here, but no definition is available}} \
|
// expected-warning {{instantiation of variable 'TypeSuffix::y<0L>' required here, but no definition is available}} \
|
||||||
|
|
|
@ -2262,8 +2262,6 @@ struct S {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static constexpr T x = 42;
|
static constexpr T x = 42;
|
||||||
};
|
};
|
||||||
// FIXME: `<int>` should be a child of `MemberExpression` and `;` of
|
|
||||||
// `ExpressionStatement`. This is a bug in clang, in `getSourceRange` methods.
|
|
||||||
void test(S s) [[{
|
void test(S s) [[{
|
||||||
s.x<int>;
|
s.x<int>;
|
||||||
}]]
|
}]]
|
||||||
|
@ -2272,18 +2270,18 @@ void test(S s) [[{
|
||||||
CompoundStatement
|
CompoundStatement
|
||||||
|-'{' OpenParen
|
|-'{' OpenParen
|
||||||
|-ExpressionStatement Statement
|
|-ExpressionStatement Statement
|
||||||
| `-MemberExpression Expression
|
| |-MemberExpression Expression
|
||||||
| |-IdExpression Object
|
| | |-IdExpression Object
|
||||||
| | `-UnqualifiedId UnqualifiedId
|
| | | `-UnqualifiedId UnqualifiedId
|
||||||
| | `-'s'
|
| | | `-'s'
|
||||||
| |-'.' AccessToken
|
| | |-'.' AccessToken
|
||||||
| `-IdExpression Member
|
| | `-IdExpression Member
|
||||||
| `-UnqualifiedId UnqualifiedId
|
| | `-UnqualifiedId UnqualifiedId
|
||||||
| `-'x'
|
| | |-'x'
|
||||||
|-'<'
|
| | |-'<'
|
||||||
|-'int'
|
| | |-'int'
|
||||||
|-'>'
|
| | `-'>'
|
||||||
|-';'
|
| `-';'
|
||||||
`-'}' CloseParen
|
`-'}' CloseParen
|
||||||
)txt"}));
|
)txt"}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue