[modules] If we re-enter a submodule from within itself (when submodule
visibility is enabled) or leave and re-enter it, restore the macro and module
visibility state from last time we were in that submodule.

This allows mutually-#including header files to stand a chance at being
modularized with local visibility enabled.

llvm-svn: 237871
diff --git a/clang/test/Modules/Inputs/submodule-visibility/cycle2.h b/clang/test/Modules/Inputs/submodule-visibility/cycle2.h
new file mode 100644
index 0000000..de9fd8e
--- /dev/null
+++ b/clang/test/Modules/Inputs/submodule-visibility/cycle2.h
@@ -0,0 +1,8 @@
+#ifndef CYCLE2
+#define CYCLE2
+
+#include "cycle1.h"
+
+struct C2 {};
+
+#endif