diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-09 15:20:18 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-09 15:20:18 +0000 |
commit | f3473a7e48dfaaa88f58dd9304856e16754f9b1c (patch) | |
tree | d13c3d76c6b1515af49c88c4367f4227b927644b /Driver/RewriteTest.cpp | |
parent | 5d37e32a5bfefacdd7b4d0664199d72c703d489d (diff) |
Rewrite global variable initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r-- | Driver/RewriteTest.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 885da01429..b74faf5b69 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -96,7 +96,7 @@ namespace { bool needToScanForQualifiers(QualType T); // Expression Rewriting. - Stmt *RewriteFunctionBody(Stmt *S); + Stmt *RewriteFunctionBodyOrGlobalInitializer(Stmt *S); Stmt *RewriteAtEncode(ObjCEncodeExpr *Exp); Stmt *RewriteAtSelector(ObjCSelectorExpr *Exp); Stmt *RewriteMessageExpr(ObjCMessageExpr *Exp); @@ -185,7 +185,7 @@ void RewriteTest::HandleTopLevelDecl(Decl *D) { void RewriteTest::HandleDeclInMainFile(Decl *D) { if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) if (Stmt *Body = FD->getBody()) - FD->setBody(RewriteFunctionBody(Body)); + FD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body)); if (ObjcImplementationDecl *CI = dyn_cast<ObjcImplementationDecl>(D)) ClassImplementation.push_back(CI); @@ -193,6 +193,10 @@ void RewriteTest::HandleDeclInMainFile(Decl *D) { CategoryImplementation.push_back(CI); else if (ObjcClassDecl *CD = dyn_cast<ObjcClassDecl>(D)) RewriteForwardClassDecl(CD); + else if (VarDecl *VD = dyn_cast<VarDecl>(D)) { + if (VD->getInit()) + RewriteFunctionBodyOrGlobalInitializer(VD->getInit()); + } // Nothing yet. } @@ -414,12 +418,12 @@ void RewriteTest::RewriteInterfaceDecl(ObjcInterfaceDecl *ClassDecl) { // Function Body / Expression rewriting //===----------------------------------------------------------------------===// -Stmt *RewriteTest::RewriteFunctionBody(Stmt *S) { +Stmt *RewriteTest::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { // Otherwise, just rewrite all children. for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end(); CI != E; ++CI) if (*CI) { - Stmt *newStmt = RewriteFunctionBody(*CI); + Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(*CI); if (newStmt) *CI = newStmt; } |