[cfe-commits] r78347 - /cfe/trunk/lib/Sema/TreeTransform.h
Douglas Gregor
dgregor at apple.com
Thu Aug 6 15:17:11 PDT 2009
Author: dgregor
Date: Thu Aug 6 17:17:10 2009
New Revision: 78347
URL: http://llvm.org/viewvc/llvm-project?rev=78347&view=rev
Log:
Minor refactoring to introduce a new transformation function,
TransformStmt, into the tree transformer.
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=78347&r1=78346&r2=78347&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Aug 6 17:17:10 2009
@@ -15,6 +15,7 @@
#include "Sema.h"
#include "clang/Sema/SemaDiagnostic.h"
+#include "clang/AST/Expr.h"
#include <algorithm>
namespace clang {
@@ -149,9 +150,16 @@
/// other clients.
QualType AddTypeQualifiers(QualType T, unsigned CVRQualifiers);
- /// \brief Transform the given expression.
+ /// \brief Transform the given statement.
///
/// FIXME: At the moment, subclasses must override this.
+ Sema::OwningStmtResult TransformStmt(Stmt *S);
+
+ /// \brief Transform the given expression.
+ ///
+ /// By default, invokes the derived class's TransformStmt() and downcasts
+ /// the result. Subclasses may override this function to provide alternate
+ /// behavior.
Sema::OwningExprResult TransformExpr(Expr *E);
/// \brief Transform the given declaration, which is referenced from a type
@@ -468,6 +476,15 @@
};
template<typename Derived>
+Sema::OwningExprResult TreeTransform<Derived>::TransformExpr(Expr *E) {
+ Sema::OwningStmtResult Result = getDerived().TransformStmt(E);
+ if (Result.isInvalid())
+ return SemaRef.ExprError();
+
+ return SemaRef.Owned(cast_or_null<Stmt>(Result.takeAs<Stmt>()));
+}
+
+template<typename Derived>
NestedNameSpecifier *
TreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range) {
More information about the cfe-commits
mailing list