Fix PR6282: the include guard optimization cannot happen if the
guard macro is already defined for the first occurrence of the
header.  If it is, the body will be skipped and not be properly
analyzed for the include guard optimization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95972 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Preprocessor/mi_opt2.c b/test/Preprocessor/mi_opt2.c
new file mode 100644
index 0000000..198d19f
--- /dev/null
+++ b/test/Preprocessor/mi_opt2.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+// PR6282
+// This test should not trigger the include guard optimization since
+// the guard macro is defined on the first include.
+
+#define ITERATING 1
+#define X 1
+#include "mi_opt2.h"
+#undef X
+#define X 2
+#include "mi_opt2.h"
+
+// CHECK: b: 1
+// CHECK: b: 2
+