Added "CheckASTConsumer", a function that generalizes
"CheckDiagnostics" (used for -parse-ast-check) to check the
diagnostics of any ASTConsumer.
Reimplemented CheckDiagnostics to use CheckASTConsumer instead.
Added driver option -warn-dead-stores-check, which checks the
diagnostics generated by the DeadStores checker. This is implemented
using CheckASTConsumer.111
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42310 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/DiagChecker.cpp b/Driver/DiagChecker.cpp
index 48d8049..21c3454 100644
--- a/Driver/DiagChecker.cpp
+++ b/Driver/DiagChecker.cpp
@@ -227,17 +227,22 @@
bool clang::CheckDiagnostics(Preprocessor &PP, unsigned MainFileID) {
// Parse the specified input file, building ASTs and performing sema, but
// doing nothing else.
-{
- ASTConsumer NullConsumer;
- ParseAST(PP, MainFileID, NullConsumer);
+ return CheckASTConsumer(PP,MainFileID,
+ std::auto_ptr<ASTConsumer>(new ASTConsumer()));
}
+/// CheckASTConsumer - Implement diagnostic checking for AST consumers.
+bool clang::CheckASTConsumer(Preprocessor &PP, unsigned MainFileID,
+ std::auto_ptr<ASTConsumer> C) {
+
+ // Local scope for ASTConsumer to auto release the consumer ...
+ { std::auto_ptr<ASTConsumer> Consumer(C);
+ ParseAST(PP, MainFileID, *Consumer.get()); }
+
// Gather the set of expected diagnostics.
DiagList ExpectedErrors, ExpectedWarnings;
FindExpectedDiags(PP, MainFileID, ExpectedErrors, ExpectedWarnings);
-
+
// Check that the expected diagnostics occurred.
return CheckResults(PP, ExpectedErrors, ExpectedWarnings);
}
-
-