summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/StmtSerialization.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-14 16:09:21 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-14 16:09:21 +0000
commit993603d80db194627969b3be96ef64e9635d4ab7 (patch)
treec938a0b3f2aff91cce84b89ffee09da4984d1ef5 /clang/lib/AST/StmtSerialization.cpp
parent5fe593390948b8a133bbabb6237e28f5eec55512 (diff)
downloadbcm5719-llvm-993603d80db194627969b3be96ef64e9635d4ab7.tar.gz
bcm5719-llvm-993603d80db194627969b3be96ef64e9635d4ab7.zip
Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that resolves to an overloaded operator in C++, e.g., "str1 + str2" that resolves to std::operator+(str1, str2)". We now build a CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But only for binary operators, where we actually implement overloading) I decided *not* to refactor the current CallExpr to make it abstract (with FunctionCallExpr and CXXOperatorCallExpr as derived classes). Doing so would allow us to make CXXOperatorCallExpr a little bit smaller, at the cost of making the argument and callee accessors virtual. We won't know if this is going to be a win until we can parse lots of C++ code to determine how much memory we'll save by making this change vs. the performance penalty due to the extra virtual calls. llvm-svn: 59306
Diffstat (limited to 'clang/lib/AST/StmtSerialization.cpp')
-rw-r--r--clang/lib/AST/StmtSerialization.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/AST/StmtSerialization.cpp b/clang/lib/AST/StmtSerialization.cpp
index 667f597b8ab..268922e4813 100644
--- a/clang/lib/AST/StmtSerialization.cpp
+++ b/clang/lib/AST/StmtSerialization.cpp
@@ -53,7 +53,7 @@ Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
return BreakStmt::CreateImpl(D, C);
case CallExprClass:
- return CallExpr::CreateImpl(D, C);
+ return CallExpr::CreateImpl(D, C, CallExprClass);
case CaseStmtClass:
return CaseStmt::CreateImpl(D, C);
@@ -198,6 +198,9 @@ Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
// C++
//==--------------------------------------==//
+ case CXXOperatorCallExprClass:
+ return CXXOperatorCallExpr::CreateImpl(D, C, CXXOperatorCallExprClass);
+
case CXXDefaultArgExprClass:
return CXXDefaultArgExpr::CreateImpl(D, C);
@@ -361,14 +364,14 @@ void CallExpr::EmitImpl(Serializer& S) const {
S.BatchEmitOwnedPtrs(NumArgs+1, SubExprs);
}
-CallExpr* CallExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+CallExpr* CallExpr::CreateImpl(Deserializer& D, ASTContext& C, StmtClass SC) {
QualType t = QualType::ReadVal(D);
SourceLocation L = SourceLocation::ReadVal(D);
unsigned NumArgs = D.ReadInt();
Stmt** SubExprs = new Stmt*[NumArgs+1];
D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
- return new CallExpr(SubExprs,NumArgs,t,L);
+ return new CallExpr(SC, SubExprs,NumArgs,t,L);
}
void CaseStmt::EmitImpl(Serializer& S) const {
OpenPOWER on IntegriCloud