summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-12 17:17:38 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-12 17:17:38 +0000
commita11693bc37b1b03da8cbfa088e79250fefc2f898 (patch)
treeae6def25e5a0135bd1f48c09aadeb0b487565653 /clang/lib/Sema/SemaDeclCXX.cpp
parent0df957e09d898cabad8c4c0756e06c349a44e133 (diff)
downloadbcm5719-llvm-a11693bc37b1b03da8cbfa088e79250fefc2f898.tar.gz
bcm5719-llvm-a11693bc37b1b03da8cbfa088e79250fefc2f898.zip
Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin bool operator==(int const*, int const*) can be used for the expression "x1 == x2" given: struct X { operator int const*(); } x1, x2; The scheme for handling these built-in operators is relatively simple: for each candidate required by the standard, create a special kind of candidate function for the built-in. If overload resolution picks the built-in operator, we perform the appropriate conversions on the arguments and then let the normal built-in operator take care of it. There may be some optimization opportunity left: if we can reduce the number of built-in operator overloads we generate, overload resolution for these cases will go faster. However, one must be careful when doing this: GCC generates too few operator overloads in our little test program, and fails to compile it because none of the overloads it generates match. Note that we only support operator overload for non-member binary operators at the moment. The other operators will follow. As part of this change, ImplicitCastExpr can now be an lvalue. llvm-svn: 59148
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 2f43e5fa9ec..128df113858 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1597,7 +1597,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType &DeclType,
// Perform the conversion.
// FIXME: Binding to a subobject of the lvalue is going to require
// more AST annotation than this.
- ImpCastExprToType(Init, T1);
+ ImpCastExprToType(Init, T1, /*isLvalue=*/true);
}
}
@@ -1656,7 +1656,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType &DeclType,
// Perform the conversion.
// FIXME: Binding to a subobject of the lvalue is going to require
// more AST annotation than this.
- ImpCastExprToType(Init, T1);
+ ImpCastExprToType(Init, T1, /*isLvalue=*/true);
}
break;
@@ -1741,7 +1741,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType &DeclType,
} else {
// FIXME: Binding to a subobject of the rvalue is going to require
// more AST annotation than this.
- ImpCastExprToType(Init, T1);
+ ImpCastExprToType(Init, T1, /*isLvalue=*/true);
}
return false;
}
OpenPOWER on IntegriCloud