Implement name hiding for macro definitions within modules, such that
only the macro definitions from visible (sub)modules will actually be
visible. This provides the same behavior for macros that r145640
provided for declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145683 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Modules/Inputs/submodules/hash_map.h b/test/Modules/Inputs/submodules/hash_map.h
index 56f0749..ce85984 100644
--- a/test/Modules/Inputs/submodules/hash_map.h
+++ b/test/Modules/Inputs/submodules/hash_map.h
@@ -1 +1,4 @@
 template<typename Key, typename Data> class hash_map { };
+
+#define HAVE_HASH_MAP
+
diff --git a/test/Modules/Inputs/submodules/type_traits.h b/test/Modules/Inputs/submodules/type_traits.h
index 9ef9006..4dad090 100644
--- a/test/Modules/Inputs/submodules/type_traits.h
+++ b/test/Modules/Inputs/submodules/type_traits.h
@@ -7,3 +7,6 @@
 struct remove_reference<T&> {
   typedef T type;
 };
+
+#define HAVE_TYPE_TRAITS
+
diff --git a/test/Modules/Inputs/submodules/vector.h b/test/Modules/Inputs/submodules/vector.h
index 2dcf3e5..8e1cdc8 100644
--- a/test/Modules/Inputs/submodules/vector.h
+++ b/test/Modules/Inputs/submodules/vector.h
@@ -1 +1,3 @@
 template<typename T> class vector { };
+
+#define HAVE_VECTOR
diff --git a/test/Modules/submodules-preprocess.cpp b/test/Modules/submodules-preprocess.cpp
index 1f0f3775..ed51b45 100644
--- a/test/Modules/submodules-preprocess.cpp
+++ b/test/Modules/submodules-preprocess.cpp
@@ -3,12 +3,58 @@
 
 __import_module__ std.vector;
 
-vector<int> vi;
-remove_reference<int&>::type *int_ptr = 0;
+#ifndef HAVE_VECTOR
+#  error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifdef HAVE_TYPE_TRAITS
+#  error HAVE_TYPE_TRAITS_MAP macro is available (but shouldn't be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+#  error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
 
 __import_module__ std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
 
-vector<float> vf;
-remove_reference<int&>::type *int_ptr2 = 0;
+#ifndef HAVE_VECTOR
+#  error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+#  error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+#  error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
 
 __import_module__ std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+__import_module__ std; // import everything in 'std'
+
+#ifndef HAVE_VECTOR
+#  error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+#  error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+#  error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+__import_module__ std.hash_map;
+
+#ifndef HAVE_VECTOR
+#  error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+#  error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifndef HAVE_HASH_MAP
+#  error HAVE_HASH_MAP macro is not available (but should be)
+#endif