aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-11 00:43:27 +0000
committerChris Lattner <sabre@nondot.org>2007-10-11 00:43:27 +0000
commit77cd2a0b6eea81cc393b4c9e2941ec31fa09fdbe (patch)
tree88197ab7460422a1a607a6d5761b0dead410492e /Driver/RewriteTest.cpp
parentae3758d29743b641eb554477d60b02870b496339 (diff)
add scafolding to play around with and bring up the code rewriter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
new file mode 100644
index 0000000000..ef1a9b0822
--- /dev/null
+++ b/Driver/RewriteTest.cpp
@@ -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());
+
+}