[ODRHash] static_cast and Stmt hashing.

Add support for static_cast in classes.  Add pointer-independent profiling for
Stmt's, sharing most of the logic with Stmt::Profile.  This is the first of the
deep sub-Decl diffing for error messages.

Differential Revision: https://reviews.llvm.org/D21675

llvm-svn: 295890
diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp
index 51eb658..652e74f 100644
--- a/clang/test/Modules/odr_hash.cpp
+++ b/clang/test/Modules/odr_hash.cpp
@@ -21,7 +21,7 @@
 // RUN: echo "}"                        >> %t/Inputs/module.map
 
 // Run test
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++11
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++1z
 
 #if !defined(FIRST) && !defined(SECOND)
 #include "first.h"
@@ -57,6 +57,64 @@
 #endif
 } // namespace AccessSpecifiers
 
+namespace StaticAssert {
+#if defined(FIRST)
+struct S1 {
+  static_assert(1 == 1, "First");
+};
+#elif defined(SECOND)
+struct S1 {
+  static_assert(1 == 1, "Second");
+};
+#else
+S1 s1;
+// expected-error@second.h:* {{'StaticAssert::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with message}}
+// expected-note@first.h:* {{but in 'FirstModule' found static assert with different message}}
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  static_assert(2 == 2, "Message");
+};
+#elif defined(SECOND)
+struct S2 {
+  static_assert(2 == 2);
+};
+#else
+S2 s2;
+// expected-error@second.h:* {{'StaticAssert::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with no message}}
+// expected-note@first.h:* {{but in 'FirstModule' found static assert with message}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  static_assert(3 == 3, "Message");
+};
+#elif defined(SECOND)
+struct S3 {
+  static_assert(3 != 4, "Message");
+};
+#else
+S3 s3;
+// expected-error@second.h:* {{'StaticAssert::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with condition}}
+// expected-note@first.h:* {{but in 'FirstModule' found static assert with different condition}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  static_assert(4 == 4, "Message");
+};
+#elif defined(SECOND)
+struct S4 {
+  public:
+};
+#else
+S4 s4;
+// expected-error@second.h:* {{'StaticAssert::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found static assert}}
+#endif
+}
+
 // Naive parsing of AST can lead to cycles in processing.  Ensure
 // self-references don't trigger an endless cycles of AST node processing.
 namespace SelfReference {
@@ -90,12 +148,18 @@
   public:
   private:
   protected:
+
+  static_assert(1 == 1, "Message");
+  static_assert(2 == 2);
 };
 #elif defined(SECOND)
 struct S {
   public:
   private:
   protected:
+
+  static_assert(1 == 1, "Message");
+  static_assert(2 == 2);
 };
 #else
 S s;
@@ -107,6 +171,9 @@
   private:
   protected:
 
+  static_assert(1 == 1, "Message");
+  static_assert(2 == 2);
+
   private:
 };
 #elif defined(SECOND)
@@ -115,6 +182,9 @@
   private:
   protected:
 
+  static_assert(1 == 1, "Message");
+  static_assert(2 == 2);
+
   public:
 };
 #else