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

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 24 11:47:05 PDT 2016


Author: rsmith
Date: Mon Oct 24 13:47:04 2016
New Revision: 284999

URL: http://llvm.org/viewvc/llvm-project?rev=284999&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/AST/StmtProfile.cpp
    cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=284999&r1=284998&r2=284999&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Oct 24 13:47:04 2016
@@ -1190,6 +1190,12 @@ void StmtProfiler::VisitCXXOperatorCallE
   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);

Modified: cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp?rev=284999&r1=284998&r2=284999&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp Mon Oct 24 13:47:04 2016
@@ -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 {




More information about the cfe-commits mailing list