Fix a template diffing problem were an '&' is unexpectedly printed in
a template argument. llvm-svn: 213609
This commit is contained in:
parent
47bdc929e3
commit
965cfa1d5b
|
@ -991,12 +991,32 @@ class TemplateDiff {
|
|||
if (!HasToValueDecl && ToExpr)
|
||||
ToValueDecl = GetValueDecl(ToIter, ToExpr);
|
||||
QualType ArgumentType = DefaultNTTPD->getType();
|
||||
bool FromAddressOf = FromValueDecl &&
|
||||
!ArgumentType->isReferenceType() &&
|
||||
!FromValueDecl->getType()->isArrayType();
|
||||
bool ToAddressOf = ToValueDecl &&
|
||||
!ArgumentType->isReferenceType() &&
|
||||
!ToValueDecl->getType()->isArrayType();
|
||||
bool FromAddressOf = false;
|
||||
if (FromValueDecl) {
|
||||
if (FromExpr) {
|
||||
if (UnaryOperator *UO = dyn_cast<UnaryOperator>(FromExpr)) {
|
||||
if (UO->getOpcode() == UO_AddrOf)
|
||||
FromAddressOf = true;
|
||||
}
|
||||
} else {
|
||||
if (!ArgumentType->isReferenceType()) {
|
||||
FromAddressOf = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool ToAddressOf = false;
|
||||
if (ToValueDecl) {
|
||||
if (ToExpr) {
|
||||
if (UnaryOperator *UO = dyn_cast<UnaryOperator>(ToExpr)) {
|
||||
if (UO->getOpcode() == UO_AddrOf) {
|
||||
ToAddressOf = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!ArgumentType->isReferenceType())
|
||||
ToAddressOf = true;
|
||||
}
|
||||
}
|
||||
Tree.SetNode(FromValueDecl, ToValueDecl, FromAddressOf, ToAddressOf);
|
||||
Tree.SetSame(FromValueDecl && ToValueDecl &&
|
||||
FromValueDecl->getCanonicalDecl() ==
|
||||
|
|
|
@ -1105,6 +1105,22 @@ using F = C<21 + 21>;
|
|||
}
|
||||
}
|
||||
|
||||
namespace AddressOf {
|
||||
template <int*>
|
||||
struct S {};
|
||||
|
||||
template <class T>
|
||||
struct Wrapper {};
|
||||
|
||||
template <class T>
|
||||
Wrapper<T> MakeWrapper();
|
||||
int global;
|
||||
constexpr int * ptr = nullptr;
|
||||
Wrapper<S<ptr>> W = MakeWrapper<S<&global>>();
|
||||
// Don't print an extra '&' for 'ptr'
|
||||
// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr>>'
|
||||
}
|
||||
|
||||
// CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
|
||||
// CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
|
||||
// CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
|
||||
|
|
Loading…
Reference in New Issue