r302505 - [ODRHash] Loosen checks on typedefs.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 20:24:34 PDT 2017


Author: rtrieu
Date: Mon May  8 22:24:34 2017
New Revision: 302505

URL: http://llvm.org/viewvc/llvm-project?rev=302505&view=rev
Log:
[ODRHash] Loosen checks on typedefs.

When a type in a class is from a typedef, only check the canonical type.  Skip
checking the intermediate underlying types.  This is in response to PR 32965

Modified:
    cfe/trunk/lib/AST/ODRHash.cpp
    cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=302505&r1=302504&r2=302505&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Mon May  8 22:24:34 2017
@@ -411,7 +411,7 @@ public:
 
   void VisitTypedefType(const TypedefType *T) {
     AddDecl(T->getDecl());
-    Hash.AddQualType(T->getDecl()->getUnderlyingType());
+    AddQualType(T->getDecl()->getUnderlyingType().getCanonicalType());
     VisitType(T);
   }
 };

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=302505&r1=302504&r2=302505&view=diff
==============================================================================
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Mon May  8 22:24:34 2017
@@ -1078,6 +1078,39 @@ S<X> s;
 #endif
 }
 
+namespace MultipleTypedefs {
+#if defined(FIRST)
+typedef int B1;
+typedef B1 A1;
+struct S1 {
+  A1 x;
+};
+#elif defined(SECOND)
+typedef int A1;
+struct S1 {
+  A1 x;
+};
+#else
+S1 s1;
+#endif
+
+#if defined(FIRST)
+struct T2 { int x; };
+typedef T2 B2;
+typedef B2 A2;
+struct S2 {
+  T2 x;
+};
+#elif defined(SECOND)
+struct T2 { int x; };
+typedef T2 A2;
+struct S2 {
+  T2 x;
+};
+#else
+S2 s2;
+#endif
+}
 
 // Keep macros contained to one file.
 #ifdef FIRST




More information about the cfe-commits mailing list