[cfe-commits] r39105 - in /cfe/cfe/trunk: AST/Expr.cpp AST/Stmt.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Expr.h include/clang/AST/Stmt.h include/clang/AST/StmtVisitor.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:27:34 PDT 2007
Author: sabre
Date: Wed Jul 11 11:27:33 2007
New Revision: 39105
URL: http://llvm.org/viewvc/llvm-project?rev=39105&view=rev
Log:
implement visitor chaining.
Modified:
cfe/cfe/trunk/AST/Expr.cpp
cfe/cfe/trunk/AST/Stmt.cpp
cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/cfe/trunk/include/clang/AST/Expr.h
cfe/cfe/trunk/include/clang/AST/Stmt.h
cfe/cfe/trunk/include/clang/AST/StmtVisitor.h
Modified: cfe/cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Expr.cpp?rev=39105&r1=39104&r2=39105&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Expr.cpp (original)
+++ cfe/cfe/trunk/AST/Expr.cpp Wed Jul 11 11:27:33 2007
@@ -25,6 +25,7 @@
#define MAKE_VISITOR(CLASS) \
void CLASS::visit(StmtVisitor *V) { return V->Visit ## CLASS(this); }
+MAKE_VISITOR(Expr)
MAKE_VISITOR(DeclRefExpr)
MAKE_VISITOR(IntegerConstant)
MAKE_VISITOR(FloatingConstant)
Modified: cfe/cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Stmt.cpp?rev=39105&r1=39104&r2=39105&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/cfe/trunk/AST/Stmt.cpp Wed Jul 11 11:27:33 2007
@@ -28,7 +28,7 @@
if (isExpr()) std::cerr << ")";
}
-
+void Stmt ::visit(StmtVisitor *V) { return V->VisitStmt(this); }
void CompoundStmt::visit(StmtVisitor *V) { return V->VisitCompoundStmt(this); }
void IfStmt ::visit(StmtVisitor *V) { return V->VisitIfStmt(this); }
void ReturnStmt ::visit(StmtVisitor *V) { return V->VisitReturnStmt(this); }
Modified: cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=39105&r1=39104&r2=39105&view=diff
==============================================================================
--- cfe/cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/cfe/trunk/clang.xcodeproj/project.pbxproj Wed Jul 11 11:27:33 2007
@@ -29,6 +29,7 @@
DE3452810AEF1B1800DBC861 /* Stmt.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3452800AEF1B1800DBC861 /* Stmt.h */; };
DE345B500AFB1CFE00DBC861 /* ASTBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE345B4F0AFB1CFE00DBC861 /* ASTBuilder.cpp */; };
DE345C1A0AFC658B00DBC861 /* StmtVisitor.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE345C190AFC658B00DBC861 /* StmtVisitor.h */; };
+ DE345C570AFC69E800DBC861 /* StmtVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE345C560AFC69E800DBC861 /* StmtVisitor.cpp */; };
DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE46BF270AE0A82D00CC047C /* TargetInfo.h */; };
DE5932D10AD60FF400BC794C /* clang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5932CD0AD60FF400BC794C /* clang.cpp */; };
DE5932D20AD60FF400BC794C /* clang.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE5932CE0AD60FF400BC794C /* clang.h */; };
@@ -144,6 +145,7 @@
DE3452800AEF1B1800DBC861 /* Stmt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Stmt.h; path = clang/AST/Stmt.h; sourceTree = "<group>"; };
DE345B4F0AFB1CFE00DBC861 /* ASTBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTBuilder.cpp; path = AST/ASTBuilder.cpp; sourceTree = "<group>"; };
DE345C190AFC658B00DBC861 /* StmtVisitor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = StmtVisitor.h; path = clang/AST/StmtVisitor.h; sourceTree = "<group>"; };
+ DE345C560AFC69E800DBC861 /* StmtVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = StmtVisitor.cpp; path = AST/StmtVisitor.cpp; sourceTree = "<group>"; };
DE46BF270AE0A82D00CC047C /* TargetInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TargetInfo.h; sourceTree = "<group>"; };
DE5932CD0AD60FF400BC794C /* clang.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = clang.cpp; path = Driver/clang.cpp; sourceTree = "<group>"; };
DE5932CE0AD60FF400BC794C /* clang.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = clang.h; path = Driver/clang.h; sourceTree = "<group>"; };
@@ -298,6 +300,7 @@
DEC8DAAC0A94400300353FCA /* ASTStreamer.cpp */,
DE0FCB330A9C21F100248FD5 /* Expr.cpp */,
DE3452400AEF1A2D00DBC861 /* Stmt.cpp */,
+ DE345C560AFC69E800DBC861 /* StmtVisitor.cpp */,
);
name = AST;
sourceTree = "<group>";
@@ -451,6 +454,7 @@
DE3451580AEC176100DBC861 /* MacroExpander.cpp in Sources */,
DE3452410AEF1A2D00DBC861 /* Stmt.cpp in Sources */,
DE345B500AFB1CFE00DBC861 /* ASTBuilder.cpp in Sources */,
+ DE345C570AFC69E800DBC861 /* StmtVisitor.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: cfe/cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Expr.h?rev=39105&r1=39104&r2=39105&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Expr.h Wed Jul 11 11:27:33 2007
@@ -35,6 +35,7 @@
// FIXME: move to isa/dyncast etc.
virtual bool isExpr() const { return true; }
+ virtual void visit(StmtVisitor *Visitor);
};
//===----------------------------------------------------------------------===//
Modified: cfe/cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Stmt.h?rev=39105&r1=39104&r2=39105&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Stmt.h Wed Jul 11 11:27:33 2007
@@ -36,7 +36,7 @@
virtual bool isExpr() const { return false; }
// Implement visitor support.
- virtual void visit(StmtVisitor *Visitor) = 0;
+ virtual void visit(StmtVisitor *Visitor);
private:
virtual void dump_impl() const = 0;
};
Modified: cfe/cfe/trunk/include/clang/AST/StmtVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/StmtVisitor.h?rev=39105&r1=39104&r2=39105&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/StmtVisitor.h (original)
+++ cfe/cfe/trunk/include/clang/AST/StmtVisitor.h Wed Jul 11 11:27:33 2007
@@ -12,10 +12,12 @@
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_STMTVISITOR_H
-#define LLVM_CLANG_AST_STMT_H
+#define LLVM_CLANG_AST_STMTVISITOR_H
namespace llvm {
namespace clang {
+ class Stmt;
+ class Expr;
class CompoundStmt;
class IfStmt;
class ReturnStmt;
@@ -43,24 +45,28 @@
///
virtual void VisitNull() {}
- // Visitation methods for various subclasses.
- virtual void VisitCompoundStmt(CompoundStmt *Node) {}
- virtual void VisitIfStmt (IfStmt *Node) {}
- virtual void VisitReturnStmt (ReturnStmt *Node) {}
+ virtual void VisitStmt(Stmt *Node) {}
+ virtual void VisitExpr(Expr *Node);
- virtual void VisitDeclRefExpr(DeclRefExpr *Node) {}
- virtual void VisitIntegerConstant(IntegerConstant *Node) {}
- virtual void VisitFloatingConstant(FloatingConstant *Node) {}
- virtual void VisitStringExpr(StringExpr *Node) {}
- virtual void VisitParenExpr(ParenExpr *Node) {}
- virtual void VisitUnaryOperator(UnaryOperator *Node) {}
- virtual void VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {}
- virtual void VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {}
- virtual void VisitCallExpr(CallExpr *Node) {}
- virtual void VisitMemberExpr(MemberExpr *Node) {}
- virtual void VisitCastExpr(CastExpr *Node) {}
- virtual void VisitBinaryOperator(BinaryOperator *Node) {}
- virtual void VisitConditionalOperator(ConditionalOperator *Node) {}
+ // Visitation methods for various Stmt subclasses.
+ virtual void VisitCompoundStmt(CompoundStmt *Node);
+ virtual void VisitIfStmt(IfStmt *Node);
+ virtual void VisitReturnStmt(ReturnStmt *Node);
+
+ // Visitation methods for various Expr subclasses.
+ virtual void VisitDeclRefExpr(DeclRefExpr *Node);
+ virtual void VisitIntegerConstant(IntegerConstant *Node);
+ virtual void VisitFloatingConstant(FloatingConstant *Node);
+ virtual void VisitStringExpr(StringExpr *Node);
+ virtual void VisitParenExpr(ParenExpr *Node);
+ virtual void VisitUnaryOperator(UnaryOperator *Node);
+ virtual void VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node);
+ virtual void VisitArraySubscriptExpr(ArraySubscriptExpr *Node);
+ virtual void VisitCallExpr(CallExpr *Node);
+ virtual void VisitMemberExpr(MemberExpr *Node);
+ virtual void VisitCastExpr(CastExpr *Node);
+ virtual void VisitBinaryOperator(BinaryOperator *Node);
+ virtual void VisitConditionalOperator(ConditionalOperator *Node);
};
}
More information about the cfe-commits
mailing list