summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/StmtSerialization.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-06 00:22:45 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-06 00:22:45 +0000
commitb0846b0f5101ced59627c73d370915e5f2370ace (patch)
treedadc73d8abfbd7948d60f88cd8ce67bcedb86cd2 /clang/lib/AST/StmtSerialization.cpp
parent35e2cfccafd00304507e3f99ec3ecfa6168326a7 (diff)
downloadbcm5719-llvm-b0846b0f5101ced59627c73d370915e5f2370ace.tar.gz
bcm5719-llvm-b0846b0f5101ced59627c73d370915e5f2370ace.zip
Add support for calls to dependent names within templates, e.g.,
template<typename T> void f(T x) { g(x); // g is a dependent name, so don't even bother to look it up g(); // error: g is not a dependent name } Note that when we see "g(", we build a CXXDependentNameExpr. However, if none of the call arguments are type-dependent, we will force the resolution of the name "g" and replace the CXXDependentNameExpr with its result. GCC actually produces a nice error message when you make this mistake, and even offers to compile your code with -fpermissive. I'll do the former next, but I don't plan to do the latter. llvm-svn: 60618
Diffstat (limited to 'clang/lib/AST/StmtSerialization.cpp')
-rw-r--r--clang/lib/AST/StmtSerialization.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/StmtSerialization.cpp b/clang/lib/AST/StmtSerialization.cpp
index 6ebaca1c8e5..9b6207be2b7 100644
--- a/clang/lib/AST/StmtSerialization.cpp
+++ b/clang/lib/AST/StmtSerialization.cpp
@@ -239,6 +239,9 @@ Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
case CXXDeleteExprClass:
return CXXDeleteExpr::CreateImpl(D, C);
+
+ case CXXDependentNameExprClass:
+ return CXXDependentNameExpr::CreateImpl(D, C);
}
}
@@ -1506,3 +1509,17 @@ CXXDeleteExpr::CreateImpl(Deserializer& D, ASTContext& C) {
return new CXXDeleteExpr(Ty, GlobalDelete, ArrayForm, OperatorDelete,
cast<Expr>(Argument), Loc);
}
+
+void CXXDependentNameExpr::EmitImpl(llvm::Serializer& S) const {
+ S.Emit(getType());
+ S.EmitPtr(Name);
+ S.Emit(Loc);
+}
+
+CXXDependentNameExpr *
+CXXDependentNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
+ QualType Ty = QualType::ReadVal(D);
+ IdentifierInfo *N = D.ReadPtr<IdentifierInfo>();
+ SourceLocation L = SourceLocation::ReadVal(D);
+ return new CXXDependentNameExpr(N, Ty, L);
+}
OpenPOWER on IntegriCloud