Fix crash if StmtProfile finds a type-dependent member access for which we have

resolved the -> to a call to a specific operator-> function. The particular
test case added here is actually being mishandled: the implicit member access
should not be type-dependent (because it's accessing a non-type-dependent
member of the current instantiation), but calls to a type-dependent operator->
that is a member of the current instantiation would be liable to hit the same
codepath.

llvm-svn: 284999
This commit is contained in:
Richard Smith 2016-10-24 18:47:04 +00:00
parent 28d2d281e7
commit bac0a0d52b
2 changed files with 15 additions and 0 deletions

View File

@ -1190,6 +1190,12 @@ void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
if (S->isTypeDependent()) {
// Type-dependent operator calls are profiled like their underlying
// syntactic operator.
//
// An operator call to operator-> is always implicit, so just skip it. The
// enclosing MemberExpr will profile the actual member access.
if (S->getOperator() == OO_Arrow)
return Visit(S->getArg(0));
UnaryOperatorKind UnaryOp = UO_Extension;
BinaryOperatorKind BinaryOp = BO_Comma;
Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);

View File

@ -80,11 +80,20 @@ namespace PR6851 {
S< S<w>::cond && 1 > foo();
};
struct Arrow { Arrow *operator->(); int n; };
template<typename T> struct M {
Arrow a;
auto f() -> M<decltype(a->n)>;
};
struct Alien;
bool operator&&(const Alien&, const Alien&);
template <bool w>
S< S<w>::cond && 1 > N::foo() { }
template<typename T>
auto M<T>::f() -> M<decltype(a->n)> {}
}
namespace PR7460 {