[cfe-commits] r113498 - /cfe/trunk/lib/Sema/TreeTransform.h
Douglas Gregor
dgregor at apple.com
Thu Sep 9 09:55:46 PDT 2010
Author: dgregor
Date: Thu Sep 9 11:55:46 2010
New Revision: 113498
URL: http://llvm.org/viewvc/llvm-project?rev=113498&view=rev
Log:
Eliminate some unnecessary uses of TreeTransform::TemporaryBase. There
are still a few (legitimate, unfortunate) uses of this hack around,
but at least now there are fewer.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=113498&r1=113497&r2=113498&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Sep 9 11:55:46 2010
@@ -1558,8 +1558,8 @@
/// semantic analysis. Subclasses may override this routine to provide
/// different behavior.
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc,
- QualType ThisType,
- bool isImplicit) {
+ QualType ThisType,
+ bool isImplicit) {
return getSema().Owned(
new (getSema().Context) CXXThisExpr(ThisLoc, ThisType,
isImplicit));
@@ -4618,32 +4618,22 @@
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
- TypeSourceInfo *OldT;
- TypeSourceInfo *NewT;
- {
- // FIXME: Source location isn't quite accurate.
- SourceLocation TypeStartLoc
- = SemaRef.PP.getLocForEndOfToken(E->getLParenLoc());
- TemporaryBase Rebase(*this, TypeStartLoc, DeclarationName());
-
- OldT = E->getTypeInfoAsWritten();
- NewT = getDerived().TransformType(OldT);
- if (!NewT)
- return ExprError();
- }
-
+ TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
+ if (!Type)
+ return ExprError();
+
ExprResult SubExpr
= getDerived().TransformExpr(E->getSubExprAsWritten());
if (SubExpr.isInvalid())
return ExprError();
if (!getDerived().AlwaysRebuild() &&
- OldT == NewT &&
+ Type == E->getTypeInfoAsWritten() &&
SubExpr.get() == E->getSubExpr())
return SemaRef.Owned(E->Retain());
return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
- NewT,
+ Type,
E->getRParenLoc(),
SubExpr.get());
}
@@ -5024,27 +5014,17 @@
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) {
- TypeSourceInfo *OldT;
- TypeSourceInfo *NewT;
- {
- // FIXME: Source location isn't quite accurate.
- SourceLocation TypeStartLoc
- = SemaRef.PP.getLocForEndOfToken(E->getOperatorLoc());
- TemporaryBase Rebase(*this, TypeStartLoc, DeclarationName());
-
- OldT = E->getTypeInfoAsWritten();
- NewT = getDerived().TransformType(OldT);
- if (!NewT)
- return ExprError();
- }
-
+ TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
+ if (!Type)
+ return ExprError();
+
ExprResult SubExpr
= getDerived().TransformExpr(E->getSubExprAsWritten());
if (SubExpr.isInvalid())
return ExprError();
if (!getDerived().AlwaysRebuild() &&
- OldT == NewT &&
+ Type == E->getTypeInfoAsWritten() &&
SubExpr.get() == E->getSubExpr())
return SemaRef.Owned(E->Retain());
@@ -5058,7 +5038,7 @@
return getDerived().RebuildCXXNamedCastExpr(E->getOperatorLoc(),
E->getStmtClass(),
FakeLAngleLoc,
- NewT,
+ Type,
FakeRAngleLoc,
FakeRAngleLoc,
SubExpr.get(),
@@ -5094,16 +5074,9 @@
ExprResult
TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
CXXFunctionalCastExpr *E) {
- TypeSourceInfo *OldT;
- TypeSourceInfo *NewT;
- {
- TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
-
- OldT = E->getTypeInfoAsWritten();
- NewT = getDerived().TransformType(OldT);
- if (!NewT)
- return ExprError();
- }
+ TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
+ if (!Type)
+ return ExprError();
ExprResult SubExpr
= getDerived().TransformExpr(E->getSubExprAsWritten());
@@ -5111,11 +5084,11 @@
return ExprError();
if (!getDerived().AlwaysRebuild() &&
- OldT == NewT &&
+ Type == E->getTypeInfoAsWritten() &&
SubExpr.get() == E->getSubExpr())
return SemaRef.Owned(E->Retain());
- return getDerived().RebuildCXXFunctionalCastExpr(NewT,
+ return getDerived().RebuildCXXFunctionalCastExpr(Type,
/*FIXME:*/E->getSubExpr()->getLocStart(),
SubExpr.get(),
E->getRParenLoc());
@@ -5214,14 +5187,11 @@
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
- TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
-
- QualType T = getDerived().TransformType(E->getType());
- if (T.isNull())
- return ExprError();
+ DeclContext *DC = getSema().getFunctionLevelDeclContext();
+ CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC);
+ QualType T = MD->getThisType(getSema().Context);
- if (!getDerived().AlwaysRebuild() &&
- T == E->getType())
+ if (!getDerived().AlwaysRebuild() && T == E->getType())
return SemaRef.Owned(E->Retain());
return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit());
More information about the cfe-commits
mailing list