]> granicus.if.org Git - clang/commitdiff
[ODRHash] Loosen checks on typedefs.
authorRichard Trieu <rtrieu@google.com>
Tue, 9 May 2017 03:24:34 +0000 (03:24 +0000)
committerRichard Trieu <rtrieu@google.com>
Tue, 9 May 2017 03:24:34 +0000 (03:24 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302505 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ODRHash.cpp
test/Modules/odr_hash.cpp

index 83168d0924f6b0de9c56afd582d893208558a7bf..f4d314a6dd0d2327d8ef80829e8f638926e5aab4 100644 (file)
@@ -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);
   }
 };
index 294e925627c6e3353d9234fa3fbac41cf0a731a6..58814dd6b3fb819cbb875580775b8ffb2fa44fca 100644 (file)
@@ -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