[cfe-commits] r42310 - in /cfe/trunk/Driver: DiagChecker.cpp clang.cpp clang.h
Ted Kremenek
kremenek at apple.com
Tue Sep 25 11:37:21 PDT 2007
Author: kremenek
Date: Tue Sep 25 13:37:20 2007
New Revision: 42310
URL: http://llvm.org/viewvc/llvm-project?rev=42310&view=rev
Log:
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
Modified:
cfe/trunk/Driver/DiagChecker.cpp
cfe/trunk/Driver/clang.cpp
cfe/trunk/Driver/clang.h
Modified: cfe/trunk/Driver/DiagChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/DiagChecker.cpp?rev=42310&r1=42309&r2=42310&view=diff
==============================================================================
--- cfe/trunk/Driver/DiagChecker.cpp (original)
+++ cfe/trunk/Driver/DiagChecker.cpp Tue Sep 25 13:37:20 2007
@@ -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);
}
-
-
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=42310&r1=42309&r2=42310&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Tue Sep 25 13:37:20 2007
@@ -59,6 +59,7 @@
ParseCFGView, // Parse ASTS. Build CFGs. View CFGs.
AnalysisLiveVariables, // Print results of live-variable analysis.
WarnDeadStores, // Run DeadStores checker on parsed ASTs.
+ WarnDeadStoresCheck, // Check diagnostics for "DeadStores".
WarnUninitVals, // Run UnitializedVariables checker.
ParsePrintCallbacks, // Parse and print each callback.
ParseSyntaxOnly, // Parse and perform semantic analysis.
@@ -102,6 +103,8 @@
"Print results of live variable analysis."),
clEnumValN(WarnDeadStores, "warn-dead-stores",
"Flag warnings of stores to dead variables."),
+ clEnumValN(WarnDeadStoresCheck, "warn-dead-stores-check",
+ "Check diagnostics emitted by --warn-dead-stores."),
clEnumValN(WarnUninitVals, "warn-uninit-values",
"Flag warnings of uses of unitialized variables."),
clEnumValN(EmitLLVM, "emit-llvm",
@@ -881,6 +884,12 @@
ParseAST(PP, MainFileID, *C.get(), Stats);
break;
}
+ case WarnDeadStoresCheck: {
+ std::auto_ptr<ASTConsumer> C(CreateDeadStoreChecker(PP.getDiagnostics()));
+ exit (CheckASTConsumer(PP, MainFileID, C));
+ break;
+ }
+
case WarnUninitVals: {
std::auto_ptr<ASTConsumer> C(CreateUnitValsChecker(PP.getDiagnostics()));
ParseAST(PP, MainFileID, *C.get(), Stats);
Modified: cfe/trunk/Driver/clang.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.h?rev=42310&r1=42309&r2=42310&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.h (original)
+++ cfe/trunk/Driver/clang.h Tue Sep 25 13:37:20 2007
@@ -14,12 +14,15 @@
#ifndef LLVM_CLANG_CLANG_H
#define LLVM_CLANG_CLANG_H
+#include <memory>
+
namespace clang {
class Preprocessor;
struct LangOptions;
class MinimalAction;
class TargetInfo;
class Diagnostic;
+class ASTConsumer;
/// DoPrintPreprocessedInput - Implement -E mode.
void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
@@ -39,6 +42,10 @@
/// CheckDiagnostics - Implement the -parse-ast-check diagnostic verifier.
bool CheckDiagnostics(Preprocessor &PP, unsigned MainFileID);
+
+/// CheckASTConsumer - Implement diagnostic checking for AST consumers.
+bool CheckASTConsumer(Preprocessor &PP, unsigned MainFileID,
+ std::auto_ptr<ASTConsumer> C);
} // end namespace clang
More information about the cfe-commits
mailing list