[cfe-commits] r39118 - in /cfe/cfe/trunk: AST/Expr.cpp AST/Stmt.cpp clang.xcodeproj/project.pbxproj include/clang/AST/StmtVisitor.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:27:41 PDT 2007
Author: sabre
Date: Wed Jul 11 11:27:41 2007
New Revision: 39118
URL: http://llvm.org/viewvc/llvm-project?rev=39118&view=rev
Log:
use the StmtNodes.def database to eliminate redundant code.
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/StmtVisitor.h
Modified: cfe/cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Expr.cpp?rev=39118&r1=39117&r2=39118&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Expr.cpp (original)
+++ cfe/cfe/trunk/AST/Expr.cpp Wed Jul 11 11:27:41 2007
@@ -18,34 +18,9 @@
using namespace clang;
//===----------------------------------------------------------------------===//
-// Visitor Implementation.
-//===----------------------------------------------------------------------===//
-
-#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)
-MAKE_VISITOR(StringExpr)
-MAKE_VISITOR(ParenExpr)
-MAKE_VISITOR(UnaryOperator)
-MAKE_VISITOR(SizeOfAlignOfTypeExpr)
-MAKE_VISITOR(ArraySubscriptExpr)
-MAKE_VISITOR(CallExpr)
-MAKE_VISITOR(MemberExpr)
-MAKE_VISITOR(CastExpr)
-MAKE_VISITOR(BinaryOperator)
-MAKE_VISITOR(ConditionalOperator)
-
-#undef MAKE_VISITOR
-
-//===----------------------------------------------------------------------===//
// Primary Expressions.
//===----------------------------------------------------------------------===//
-
StringExpr::StringExpr(const char *strData, unsigned byteLength, bool Wide) {
// OPTIMIZE: could allocate this appended to the StringExpr.
char *AStrData = new char[byteLength];
Modified: cfe/cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Stmt.cpp?rev=39118&r1=39117&r2=39118&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/cfe/trunk/AST/Stmt.cpp Wed Jul 11 11:27:41 2007
@@ -17,15 +17,10 @@
using namespace llvm;
using namespace clang;
-#define MAKE_VISITOR(CLASS) \
+// Implement all the AST node visit methods using the StmtNodes.def database.
+#define STMT(CLASS, PARENT) \
void CLASS::visit(StmtVisitor &V) { return V.Visit##CLASS(this); }
-MAKE_VISITOR(Stmt)
-MAKE_VISITOR(CompoundStmt)
-MAKE_VISITOR(IfStmt)
-MAKE_VISITOR(WhileStmt)
-MAKE_VISITOR(DoStmt)
-MAKE_VISITOR(ForStmt)
-MAKE_VISITOR(ReturnStmt)
+STMT(Stmt, )
+#include "clang/AST/StmtNodes.def"
-#undef MAKE_VISITOR
Modified: cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=39118&r1=39117&r2=39118&view=diff
==============================================================================
--- cfe/cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/cfe/trunk/clang.xcodeproj/project.pbxproj Wed Jul 11 11:27:41 2007
@@ -31,6 +31,7 @@
DE345C1A0AFC658B00DBC861 /* StmtVisitor.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE345C190AFC658B00DBC861 /* StmtVisitor.h */; };
DE345C570AFC69E800DBC861 /* StmtVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE345C560AFC69E800DBC861 /* StmtVisitor.cpp */; };
DE345C780AFC6BE600DBC861 /* ASTBuilder.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE345C770AFC6BE600DBC861 /* ASTBuilder.h */; };
+ DE345F220AFD347900DBC861 /* StmtNodes.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE345F210AFD347900DBC861 /* StmtNodes.def */; };
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 */; };
@@ -118,13 +119,14 @@
DE3452810AEF1B1800DBC861 /* Stmt.h in CopyFiles */,
DE345C1A0AFC658B00DBC861 /* StmtVisitor.h in CopyFiles */,
DE345C780AFC6BE600DBC861 /* ASTBuilder.h in CopyFiles */,
+ DE345F220AFD347900DBC861 /* StmtNodes.def in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
- 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
DE06BECA0A854E4B0050E87E /* Scope.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Scope.h; path = clang/Parse/Scope.h; sourceTree = "<group>"; };
DE06CC170A899E110050E87E /* Statement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Statement.cpp; path = Parse/Statement.cpp; sourceTree = "<group>"; };
@@ -149,6 +151,7 @@
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>"; };
DE345C770AFC6BE600DBC861 /* ASTBuilder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTBuilder.h; path = clang/AST/ASTBuilder.h; sourceTree = "<group>"; };
+ DE345F210AFD347900DBC861 /* StmtNodes.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = StmtNodes.def; path = clang/AST/StmtNodes.def; 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>"; };
@@ -292,6 +295,7 @@
DEC8D9900A9433CD00353FCA /* Decl.h */,
DE0FCA620A95859D00248FD5 /* Expr.h */,
DE3452800AEF1B1800DBC861 /* Stmt.h */,
+ DE345F210AFD347900DBC861 /* StmtNodes.def */,
DE345C190AFC658B00DBC861 /* StmtVisitor.h */,
);
name = AST;
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=39118&r1=39117&r2=39118&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/StmtVisitor.h (original)
+++ cfe/cfe/trunk/include/clang/AST/StmtVisitor.h Wed Jul 11 11:27:41 2007
@@ -17,27 +17,10 @@
namespace llvm {
namespace clang {
class Stmt;
- class Expr;
- class CompoundStmt;
- class IfStmt;
- class DoStmt;
- class WhileStmt;
- class ForStmt;
- class ReturnStmt;
-
- class DeclRefExpr;
- class IntegerConstant;
- class FloatingConstant;
- class StringExpr;
- class ParenExpr;
- class UnaryOperator;
- class SizeOfAlignOfTypeExpr;
- class ArraySubscriptExpr;
- class CallExpr;
- class MemberExpr;
- class CastExpr;
- class BinaryOperator;
- class ConditionalOperator;
+ // Add prototypes for all AST node classes.
+#define STMT(CLASS, PARENT) \
+ class CLASS;
+#include "clang/AST/StmtNodes.def"
/// StmtVisitor - This class implements a simple visitor for Stmt subclasses.
/// Since Expr derives from Stmt, this also includes support for visiting Exprs.
@@ -46,30 +29,11 @@
virtual ~StmtVisitor();
virtual void VisitStmt(Stmt *Node) {}
- virtual void VisitExpr(Expr *Node);
-
- // Visitation methods for various Stmt subclasses.
- virtual void VisitCompoundStmt(CompoundStmt *Node);
- virtual void VisitIfStmt(IfStmt *Node);
- virtual void VisitWhileStmt(WhileStmt *Node);
- virtual void VisitDoStmt(DoStmt *Node);
- virtual void VisitForStmt(ForStmt *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);
+ // Implement all the methods with the StmtNodes.def file.
+#define STMT(CLASS, PARENT) \
+ virtual void Visit##CLASS(CLASS *Node);
+#include "clang/AST/StmtNodes.def"
};
}
More information about the cfe-commits
mailing list