[cfe-commits] r42855 - in /cfe/trunk/Driver: ASTConsumers.h RewriteTest.cpp clang.cpp
Chris Lattner
sabre at nondot.org
Wed Oct 10 17:43:27 PDT 2007
Author: lattner
Date: Wed Oct 10 19:43:27 2007
New Revision: 42855
URL: http://llvm.org/viewvc/llvm-project?rev=42855&view=rev
Log:
add scafolding to play around with and bring up the code rewriter.
Added:
cfe/trunk/Driver/RewriteTest.cpp
Modified:
cfe/trunk/Driver/ASTConsumers.h
cfe/trunk/Driver/clang.cpp
Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=42855&r1=42854&r2=42855&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Wed Oct 10 19:43:27 2007
@@ -27,6 +27,7 @@
ASTConsumer *CreateDeadStoreChecker(Diagnostic &Diags);
ASTConsumer *CreateUnitValsChecker(Diagnostic &Diags);
ASTConsumer *CreateLLVMEmitter(Diagnostic &Diags);
+ASTConsumer *CreateCodeRewriterTest();
} // end clang namespace
Added: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=42855&view=auto
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (added)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Oct 10 19:43:27 2007
@@ -0,0 +1,43 @@
+//===--- RewriteTest.cpp - Playground for the code rewriter ---------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Hacks and fun related to the code rewriter.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ASTConsumers.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+
+using namespace clang;
+
+
+namespace {
+ class ASTViewer : public ASTConsumer {
+ SourceManager *SM;
+ public:
+ void Initialize(ASTContext &Context, unsigned MainFileID) {
+ SM = &Context.SourceMgr;
+ }
+
+ virtual void HandleTopLevelDecl(Decl *D);
+ };
+}
+
+ASTConsumer *clang::CreateCodeRewriterTest() { return new ASTViewer(); }
+
+
+
+
+void ASTViewer::HandleTopLevelDecl(Decl *D) {
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(D))
+ if (ND->getName())
+ printf("%s\n", ND->getName());
+
+}
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=42855&r1=42854&r2=42855&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Oct 10 19:43:27 2007
@@ -49,6 +49,7 @@
Stats("stats", llvm::cl::desc("Print performance metrics and statistics"));
enum ProgActions {
+ RewriteTest, // Rewriter testing stuff.
EmitLLVM, // Emit a .ll file.
ASTPrint, // Parse ASTs and print them.
ASTDump, // Parse ASTs and dump them.
@@ -101,6 +102,8 @@
"Flag warnings of uses of unitialized variables."),
clEnumValN(EmitLLVM, "emit-llvm",
"Build ASTs then convert to LLVM, emit .ll file"),
+ clEnumValN(RewriteTest, "rewrite-test",
+ "Playground for the code rewriter"),
clEnumValEnd));
static llvm::cl::opt<bool>
@@ -796,6 +799,10 @@
case EmitLLVM:
Consumer = CreateLLVMEmitter(PP.getDiagnostics());
break;
+
+ case RewriteTest:
+ Consumer = CreateCodeRewriterTest();
+ break;
}
if (Consumer) {
More information about the cfe-commits
mailing list