]> granicus.if.org Git - clang/commitdiff
[ODRHash] Skip more types hashing TypedefType
authorRichard Trieu <rtrieu@google.com>
Thu, 12 Apr 2018 02:26:49 +0000 (02:26 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 12 Apr 2018 02:26:49 +0000 (02:26 +0000)
To get the underlying type for TypedefType's, also skip ElaboratedType's.

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

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

index 528e32aaba2190f1101a750be40555e4204401bb..0ee30fbd9b20dc80ec083da2b48d03faf94a0bb4 100644 (file)
@@ -646,9 +646,19 @@ public:
     AddDecl(T->getDecl());
     QualType UnderlyingType = T->getDecl()->getUnderlyingType();
     VisitQualifiers(UnderlyingType.getQualifiers());
-    while (const TypedefType *Underlying =
-               dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
-      UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+    while (true) {
+      if (const TypedefType *Underlying =
+              dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
+        UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+        continue;
+      }
+      if (const ElaboratedType *Underlying =
+              dyn_cast<ElaboratedType>(UnderlyingType.getTypePtr())) {
+        UnderlyingType = Underlying->getNamedType();
+        continue;
+      }
+
+      break;
     }
     AddType(UnderlyingType.getTypePtr());
     VisitType(T);
index 5991dd0a73358b61664c88f3f38e97cdf642dd4e..b22ccdd0c8b6e54c1a8b862c34e5c3caa347f535 100644 (file)
@@ -2744,6 +2744,38 @@ struct S3 {
 #else
 S3 s3;
 #endif
+
+#if defined(FIRST)
+using A4 = int;
+using B4 = A4;
+struct S4 {
+  B4 x;
+};
+#elif defined(SECOND)
+using A4 = int;
+using B4 = ::MultipleTypedefs::A4;
+struct S4 {
+  B4 x;
+};
+#else
+S4 s4;
+#endif
+
+#if defined(FIRST)
+using A5 = int;
+using B5 = MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#elif defined(SECOND)
+using A5 = int;
+using B5 = ::MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#else
+S5 s5;
+#endif
 }  // MultipleTypedefs
 
 namespace DefaultArguments {