r210296 - PR19936: Fix a really dumb bug where we would profile dependent operator* expressions incorrectly.
Richard Smith
richard-llvm at metafoo.co.uk
Thu Jun 5 15:43:40 PDT 2014
Author: rsmith
Date: Thu Jun 5 17:43:40 2014
New Revision: 210296
URL: http://llvm.org/viewvc/llvm-project?rev=210296&view=rev
Log:
PR19936: Fix a really dumb bug where we would profile dependent operator* expressions incorrectly.
Modified:
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/SemaTemplate/dependent-names.cpp
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=210296&r1=210295&r2=210296&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Jun 5 17:43:40 2014
@@ -627,11 +627,11 @@ static Stmt::StmtClass DecodeOperatorCal
case OO_Star:
if (S->getNumArgs() == 1) {
- UnaryOp = UO_Minus;
+ UnaryOp = UO_Deref;
return Stmt::UnaryOperatorClass;
}
- BinaryOp = BO_Sub;
+ BinaryOp = BO_Mul;
return Stmt::BinaryOperatorClass;
case OO_Slash:
@@ -776,7 +776,7 @@ static Stmt::StmtClass DecodeOperatorCal
llvm_unreachable("Invalid overloaded operator expression");
}
-
+
void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
if (S->isTypeDependent()) {
@@ -785,7 +785,7 @@ void StmtProfiler::VisitCXXOperatorCallE
UnaryOperatorKind UnaryOp = UO_Extension;
BinaryOperatorKind BinaryOp = BO_Comma;
Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
-
+
ID.AddInteger(SC);
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
Visit(S->getArg(I));
@@ -796,10 +796,10 @@ void StmtProfiler::VisitCXXOperatorCallE
ID.AddInteger(BinaryOp);
else
assert(SC == Stmt::ArraySubscriptExprClass);
-
+
return;
}
-
+
VisitCallExpr(S);
ID.AddInteger(S->getOperator());
}
Modified: cfe/trunk/test/SemaTemplate/dependent-names.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-names.cpp?rev=210296&r1=210295&r2=210296&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/dependent-names.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-names.cpp Thu Jun 5 17:43:40 2014
@@ -399,3 +399,18 @@ namespace OperatorNew {
using size_t = decltype(sizeof(0));
void *operator new(size_t, OperatorNew::X); // expected-note-re {{should be declared prior to the call site{{$}}}}
template void OperatorNew::f(OperatorNew::X); // expected-note {{instantiation of}}
+
+namespace PR19936 {
+ template<typename T> decltype(*T()) f() {} // expected-note {{previous}}
+ template<typename T> decltype(T() * T()) g() {} // expected-note {{previous}}
+
+ // Create some overloaded operators so we build an overload operator call
+ // instead of a builtin operator call for the dependent expression.
+ enum E {};
+ int operator*(E);
+ int operator*(E, E);
+
+ // Check that they still profile the same.
+ template<typename T> decltype(*T()) f() {} // expected-error {{redefinition}}
+ template<typename T> decltype(T() * T()) g() {} // expected-error {{redefinition}}
+}
More information about the cfe-commits
mailing list