diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-05 00:51:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-05 00:51:44 +0000 |
commit | 5287f091b269ec01b96c78f0fb3a0079cecc793d (patch) | |
tree | 6569ac454b237ad5018bd3b46c0bfc7eccfa91c8 /clang/lib/Sema/SemaOverload.cpp | |
parent | 45119d8850b65284445927f7ca107ff01a18b8d6 (diff) | |
download | bcm5719-llvm-5287f091b269ec01b96c78f0fb3a0079cecc793d.tar.gz bcm5719-llvm-5287f091b269ec01b96c78f0fb3a0079cecc793d.zip |
When instantiating a UnaryOperator, allow the resulting expression to
still be dependent or invoke an overloaded operator. Previously, we
only supported builtin operators.
BinaryOperator/CompoundAssignOperator didn't have this issue because
we always built a CXXOperatorCallExpr node, even when name lookup
didn't find any functions to save until instantiation time. Now, that
code builds a BinaryOperator or CompoundAssignOperator rather than a
CXXOperatorCallExpr, to save some space.
llvm-svn: 86087
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index dd009a062f0..d2bdfb8e2cc 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -4787,11 +4787,20 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // If either side is type-dependent, create an appropriate dependent // expression. if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) { - // .* cannot be overloaded. - if (Opc == BinaryOperator::PtrMemD) - return Owned(new (Context) BinaryOperator(Args[0], Args[1], Opc, - Context.DependentTy, OpLoc)); - + if (Functions.empty()) { + // If there are no functions to store, just build a dependent + // BinaryOperator or CompoundAssignment. + if (Opc <= BinaryOperator::Assign || Opc > BinaryOperator::OrAssign) + return Owned(new (Context) BinaryOperator(Args[0], Args[1], Opc, + Context.DependentTy, OpLoc)); + + return Owned(new (Context) CompoundAssignOperator(Args[0], Args[1], Opc, + Context.DependentTy, + Context.DependentTy, + Context.DependentTy, + OpLoc)); + } + OverloadedFunctionDecl *Overloads = OverloadedFunctionDecl::Create(Context, CurContext, OpName); for (FunctionSet::iterator Func = Functions.begin(), |