r300814 - [ODRHash] clean up test and add new examples. NFC

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 19:53:53 PDT 2017


Author: rtrieu
Date: Wed Apr 19 21:53:53 2017
New Revision: 300814

URL: http://llvm.org/viewvc/llvm-project?rev=300814&view=rev
Log:
[ODRHash] clean up test and add new examples.  NFC

Use a macro to generate the struct with all decls.  Previously, four identical
changes would be needed to update this test.  This macro reduces that to one
location.  Added two other tests for issues that triggered false positives
during testing.

Modified:
    cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=300814&r1=300813&r2=300814&view=diff
==============================================================================
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Apr 19 21:53:53 2017
@@ -526,138 +526,51 @@ S3 s3;
 // Interesting cases that should not cause errors.  struct S should not error
 // while struct T should error at the access specifier mismatch at the end.
 namespace AllDecls {
-#if defined(FIRST)
-typedef int INT;
-struct S {
-  public:
-  private:
-  protected:
-
-  static_assert(1 == 1, "Message");
-  static_assert(2 == 2);
-
-  int x;
-  double y;
-
-  INT z;
-
-  unsigned a : 1;
-  unsigned b : 2*2 + 5/2;
-
-  mutable int c = sizeof(x + y);
+#define CREATE_ALL_DECL_STRUCT(NAME, ACCESS) \
+  typedef int INT;                           \
+  struct NAME {                              \
+  public:                                    \
+  private:                                   \
+  protected:                                 \
+    static_assert(1 == 1, "Message");        \
+    static_assert(2 == 2);                   \
+                                             \
+    int x;                                   \
+    double y;                                \
+                                             \
+    INT z;                                   \
+                                             \
+    unsigned a : 1;                          \
+    unsigned b : 2 * 2 + 5 / 2;              \
+                                             \
+    mutable int c = sizeof(x + y);           \
+                                             \
+    void method() {}                         \
+    static void static_method() {}           \
+    virtual void virtual_method() {}         \
+    virtual void pure_virtual_method() = 0;  \
+    inline void inline_method() {}           \
+    void volatile_method() volatile {}       \
+    void const_method() const {}             \
+                                             \
+    typedef int typedef_int;                 \
+    using using_int = int;                   \
+                                             \
+    ACCESS:                                  \
+  };
 
-  void method() {}
-  static void static_method() {}
-  virtual void virtual_method() {}
-  virtual void pure_virtual_method() = 0;
-  inline void inline_method() {}
-  void volatile_method() volatile {}
-  void const_method() const {}
-
-  typedef int typedef_int;
-  using using_int = int;
-};
+#if defined(FIRST)
+CREATE_ALL_DECL_STRUCT(S, public)
 #elif defined(SECOND)
-typedef int INT;
-struct S {
-  public:
-  private:
-  protected:
-
-  static_assert(1 == 1, "Message");
-  static_assert(2 == 2);
-
-  int x;
-  double y;
-
-  INT z;
-
-  unsigned a : 1;
-  unsigned b : 2 * 2 + 5 / 2;
-
-  mutable int c = sizeof(x + y);
-
-  void method() {}
-  static void static_method() {}
-  virtual void virtual_method() {}
-  virtual void pure_virtual_method() = 0;
-  inline void inline_method() {}
-  void volatile_method() volatile {}
-  void const_method() const {}
-
-  typedef int typedef_int;
-  using using_int = int;
-};
+CREATE_ALL_DECL_STRUCT(S, public)
 #else
 S *s;
 #endif
 
 #if defined(FIRST)
-typedef int INT;
-struct T {
-  public:
-  private:
-  protected:
-
-  static_assert(1 == 1, "Message");
-  static_assert(2 == 2);
-
-  int x;
-  double y;
-
-  INT z;
-
-  unsigned a : 1;
-  unsigned b : 2 * 2 + 5 / 2;
-
-  mutable int c = sizeof(x + y);
-
-  void method() {}
-  static void static_method() {}
-  virtual void virtual_method() {}
-  virtual void pure_virtual_method() = 0;
-  inline void inline_method() {}
-  void volatile_method() volatile {}
-  void const_method() const {}
-
-  typedef int typedef_int;
-  using using_int = int;
-
-  private:
-};
+CREATE_ALL_DECL_STRUCT(T, private)
 #elif defined(SECOND)
-typedef int INT;
-struct T {
-  public:
-  private:
-  protected:
-
-  static_assert(1 == 1, "Message");
-  static_assert(2 == 2);
-
-  int x;
-  double y;
-
-  INT z;
-
-  unsigned a : 1;
-  unsigned b : 2 * 2 + 5 / 2;
-
-  mutable int c = sizeof(x + y);
-
-  void method() {}
-  static void static_method() {}
-  virtual void virtual_method() {}
-  virtual void pure_virtual_method() = 0;
-  inline void inline_method() {}
-  void volatile_method() volatile {}
-  void const_method() const {}
-
-  typedef int typedef_int;
-  using using_int = int;
-
-  public:
-};
+CREATE_ALL_DECL_STRUCT(T, public)
 #else
 T *t;
 // expected-error at second.h:* {{'AllDecls::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
@@ -944,6 +857,36 @@ T t;
 #endif
 }  // namespace StructWithForwardDeclarationNoDefinition
 
+namespace LateParsedDefaultArgument {
+#if defined(FIRST)
+template <typename T>
+struct S {
+  struct R {
+    void foo(T x = 0) {}
+  };
+};
+#elif defined(SECOND)
+#else
+void run() {
+  S<int>::R().foo();
+}
+#endif
+}
+
+namespace LateParsedDefaultArgument {
+#if defined(FIRST)
+template <typename alpha> struct Bravo {
+  void charlie(bool delta = false) {}
+};
+typedef Bravo<char> echo;
+echo foxtrot;
+
+Bravo<char> golf;
+#elif defined(SECOND)
+#else
+#endif
+}
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST




More information about the cfe-commits mailing list