[cfe-commits] r71886 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-function-1.cpp
Anders Carlsson
andersca at mac.com
Fri May 15 13:26:03 PDT 2009
Author: andersca
Date: Fri May 15 15:26:03 2009
New Revision: 71886
URL: http://llvm.org/viewvc/llvm-project?rev=71886&view=rev
Log:
Instantiation support for 'this'
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=71886&r1=71885&r2=71886&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Fri May 15 15:26:03 2009
@@ -47,6 +47,7 @@
OwningExprResult VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *E);
OwningExprResult VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
OwningExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
+ OwningExprResult VisitCXXThisExpr(CXXThisExpr *E);
// Base case. I'm supposed to ignore this.
Sema::OwningExprResult VisitStmt(Stmt *S) {
@@ -418,6 +419,17 @@
return SemaRef.Owned(ICE);
}
+Sema::OwningExprResult
+TemplateExprInstantiator::VisitCXXThisExpr(CXXThisExpr *E) {
+ QualType ThisType =
+ cast<CXXMethodDecl>(SemaRef.CurContext)->getThisType(SemaRef.Context);
+
+ CXXThisExpr *TE =
+ new (SemaRef.Context) CXXThisExpr(E->getLocStart(), ThisType);
+
+ return SemaRef.Owned(TE);
+}
+
Sema::OwningExprResult
Sema::InstantiateExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
TemplateExprInstantiator Instantiator(*this, TemplateArgs);
Modified: cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp?rev=71886&r1=71885&r2=71886&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp Fri May 15 15:26:03 2009
@@ -75,3 +75,11 @@
template struct X6<ConvertibleToInt, float, char>;
template struct X6<bool, int, int*>; // expected-note{{instantiation}}
+
+template <typename T> struct X7 {
+ void f() {
+ void *v = this;
+ }
+};
+
+template struct X7<int>;
More information about the cfe-commits
mailing list