]> granicus.if.org Git - clang/commitdiff
Build ASTs before relexing the file. This avoids having comment finding mutate the
authorChris Lattner <sabre@nondot.org>
Fri, 10 Aug 2007 18:27:41 +0000 (18:27 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 10 Aug 2007 18:27:41 +0000 (18:27 +0000)
preprocessor state, causing bogus diagnostics when the file is parsed for real.  This
implements Misc/diag-checker.c.  Thanks to Ted for noticing this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41000 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/DiagChecker.cpp
test/Misc/diag-checker.c [new file with mode: 0644]

index 279b55b7731de1861407e13591e831f0262987ca..1e327ce363d920ba74d735f05431aea5cbd0adf4 100644 (file)
@@ -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/test/Misc/diag-checker.c b/test/Misc/diag-checker.c
new file mode 100644 (file)
index 0000000..2aa5051
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: clang -parse-ast-check %s
+
+#include <stdio.h>
+
+void foo(FILE *FP) {}