diff options
author | Chris Lattner <sabre@nondot.org> | 2007-10-16 22:36:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-10-16 22:36:42 +0000 |
commit | 311ff02fae0392bee6abe7723cdf5a69b2899a47 (patch) | |
tree | d5ad955ebc02cca2d55aec58847593b73ffa340a /Driver/RewriteTest.cpp | |
parent | 3e7fd152aa8f13da75cd91a96ef78cc823c5f32d (diff) |
Add a new Rewriter::getRangeSize method.
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r-- | Driver/RewriteTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 5b27f55190..731d6fe777 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -36,6 +36,9 @@ namespace { void HandleDeclInMainFile(Decl *D); void RewriteInclude(SourceLocation Loc); + + void RewriteFunctionBody(Stmt *S); + void RewriteAtEncode(ObjCEncodeExpr *Exp); ~RewriteTest(); }; @@ -86,10 +89,36 @@ void RewriteTest::RewriteInclude(SourceLocation Loc) { /// HandleDeclInMainFile - This is called for each top-level decl defined in the /// main file of the input. void RewriteTest::HandleDeclInMainFile(Decl *D) { + if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) + if (Stmt *Body = FD->getBody()) + RewriteFunctionBody(Body); // Nothing yet. } +void RewriteTest::RewriteFunctionBody(Stmt *S) { + // Handle specific things. + if (ObjCEncodeExpr *AtEncode = dyn_cast<ObjCEncodeExpr>(S)) + return RewriteAtEncode(AtEncode); + + // Otherwise, just rewrite all children. + for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end(); + CI != E; ++CI) + RewriteFunctionBody(*CI); +} + +void RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) { +#if 0 + int Size = Rewrite.getRangeSize(Exp->getSourceRange()); + if (Size == -1) { + printf("BLAH!"); + } + + Rewrite.RemoveText(Exp->getEncLoc(), Size); +#endif +} + + RewriteTest::~RewriteTest() { // Get the top-level buffer that this corresponds to. std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); |