summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-10 18:27:41 +0000
committerChris Lattner <sabre@nondot.org>2007-08-10 18:27:41 +0000
commitac9823bc5d3939f20aeb7f559aaeb5d427ac6917 (patch)
tree7c875904aca604f9ea29aee2fcf31e4f6db44f5a
parent47fea35e48970da9094ef22404f295726ee4aef9 (diff)
downloadbcm5719-llvm-ac9823bc5d3939f20aeb7f559aaeb5d427ac6917.tar.gz
bcm5719-llvm-ac9823bc5d3939f20aeb7f559aaeb5d427ac6917.zip
Build ASTs before relexing the file. This avoids having comment finding mutate the
preprocessor state, causing bogus diagnostics when the file is parsed for real. This implements Misc/diag-checker.c. Thanks to Ted for noticing this. llvm-svn: 41000
-rw-r--r--clang/Driver/DiagChecker.cpp6
-rw-r--r--clang/test/Misc/diag-checker.c5
2 files changed, 8 insertions, 3 deletions
diff --git a/clang/Driver/DiagChecker.cpp b/clang/Driver/DiagChecker.cpp
index 279b55b7731..1e327ce363d 100644
--- a/clang/Driver/DiagChecker.cpp
+++ b/clang/Driver/DiagChecker.cpp
@@ -216,13 +216,13 @@ static bool CheckResults(Preprocessor &PP,
/// CheckDiagnostics - Implement the -parse-ast-check diagnostic verifier.
bool clang::CheckDiagnostics(Preprocessor &PP, unsigned MainFileID) {
+ // Parse the specified input file.
+ BuildASTs(PP, MainFileID, false);
+
// Gather the set of expected diagnostics.
DiagList ExpectedErrors, ExpectedWarnings;
FindExpectedDiags(PP, MainFileID, ExpectedErrors, ExpectedWarnings);
- // Parse the specified input file.
- BuildASTs(PP, MainFileID, false);
-
// Check that the expected diagnostics occurred.
return CheckResults(PP, ExpectedErrors, ExpectedWarnings);
}
diff --git a/clang/test/Misc/diag-checker.c b/clang/test/Misc/diag-checker.c
new file mode 100644
index 00000000000..2aa5051d8b4
--- /dev/null
+++ b/clang/test/Misc/diag-checker.c
@@ -0,0 +1,5 @@
+// RUN: clang -parse-ast-check %s
+
+#include <stdio.h>
+
+void foo(FILE *FP) {}
OpenPOWER on IntegriCloud