From e9c810c87c448f877278e49167008d3ef6a2c827 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 30 Nov 2007 22:25:36 +0000 Subject: [PATCH] pass diagnostics into the rewrite test client. llvm-svn: 44468 --- clang/Driver/ASTConsumers.h | 2 +- clang/Driver/RewriteTest.cpp | 12 ++++++++++-- clang/Driver/clang.cpp | 2 +- clang/clang.xcodeproj/project.pbxproj | 1 - 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/clang/Driver/ASTConsumers.h b/clang/Driver/ASTConsumers.h index dc6e750b72bd..37f825b5daec 100644 --- a/clang/Driver/ASTConsumers.h +++ b/clang/Driver/ASTConsumers.h @@ -30,7 +30,7 @@ ASTConsumer *CreateLiveVarAnalyzer(); ASTConsumer *CreateDeadStoreChecker(Diagnostic &Diags); ASTConsumer *CreateUnitValsChecker(Diagnostic &Diags); ASTConsumer *CreateLLVMEmitter(Diagnostic &Diags, const LangOptions &Features); -ASTConsumer *CreateCodeRewriterTest(); +ASTConsumer *CreateCodeRewriterTest(Diagnostic &Diags); ASTConsumer *CreateSerializationTest(); } // end clang namespace diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp index 043b260b16df..5d14f0355531 100644 --- a/clang/Driver/RewriteTest.cpp +++ b/clang/Driver/RewriteTest.cpp @@ -27,6 +27,7 @@ using llvm::utostr; namespace { class RewriteTest : public ASTConsumer { Rewriter Rewrite; + Diagnostic &Diags; ASTContext *Context; SourceManager *SM; unsigned MainFileID; @@ -92,6 +93,7 @@ namespace { // Top Level Driver code. virtual void HandleTopLevelDecl(Decl *D); void HandleDeclInMainFile(Decl *D); + RewriteTest(Diagnostic &D) : Diags(D) {} ~RewriteTest(); // Syntactic Rewriting. @@ -160,7 +162,9 @@ namespace { }; } -ASTConsumer *clang::CreateCodeRewriterTest() { return new RewriteTest(); } +ASTConsumer *clang::CreateCodeRewriterTest(Diagnostic &Diags) { + return new RewriteTest(Diags); +} //===----------------------------------------------------------------------===// // Top Level Driver Code @@ -860,7 +864,11 @@ Stmt *RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) { Expr *Replacement = new StringLiteral(StrEncoding.c_str(), StrEncoding.length(), false, StrType, SourceLocation(), SourceLocation()); - Rewrite.ReplaceStmt(Exp, Replacement); + if (Rewrite.ReplaceStmt(Exp, Replacement)) { + // replacement failed. + return Exp; + } + delete Exp; return Replacement; } diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index ac3a04ab2e92..f26fb994b9eb 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -836,7 +836,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID, break; case RewriteTest: - Consumer = CreateCodeRewriterTest(); + Consumer = CreateCodeRewriterTest(PP.getDiagnostics()); break; } diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj index 1585d851d9ab..db10ad3f4485 100644 --- a/clang/clang.xcodeproj/project.pbxproj +++ b/clang/clang.xcodeproj/project.pbxproj @@ -766,7 +766,6 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; - compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = "";