From: Richard Trieu Date: Thu, 29 Jun 2017 22:53:04 +0000 (+0000) Subject: [ODRHash] Improve typedef handling. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=820a5338833931da294b354a4a31d3b713dc23d9;p=clang [ODRHash] Improve typedef handling. Follow typedef chains to find the root type when processing types, and also keep track of qualifiers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306753 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ODRHash.cpp b/lib/AST/ODRHash.cpp index 05bed658f3..5c8d151e08 100644 --- a/lib/AST/ODRHash.cpp +++ b/lib/AST/ODRHash.cpp @@ -430,6 +430,13 @@ public: Hash.AddQualType(T); } + void AddType(const Type *T) { + Hash.AddBoolean(T); + if (T) { + Hash.AddType(T); + } + } + void AddNestedNameSpecifier(const NestedNameSpecifier *NNS) { Hash.AddNestedNameSpecifier(NNS); } @@ -517,7 +524,13 @@ public: void VisitTypedefType(const TypedefType *T) { AddDecl(T->getDecl()); - AddQualType(T->getDecl()->getUnderlyingType().getCanonicalType()); + QualType UnderlyingType = T->getDecl()->getUnderlyingType(); + VisitQualifiers(UnderlyingType.getQualifiers()); + while (const TypedefType *Underlying = + dyn_cast(UnderlyingType.getTypePtr())) { + UnderlyingType = Underlying->getDecl()->getUnderlyingType(); + } + AddType(UnderlyingType.getTypePtr()); VisitType(T); } diff --git a/test/Modules/odr_hash.cpp b/test/Modules/odr_hash.cpp index c94940c73e..f01c4e836a 100644 --- a/test/Modules/odr_hash.cpp +++ b/test/Modules/odr_hash.cpp @@ -1762,6 +1762,22 @@ struct S2 { #else S2 s2; #endif + +#if defined(FIRST) +using A3 = const int; +using B3 = volatile A3; +struct S3 { + B3 x = 1; +}; +#elif defined(SECOND) +using A3 = volatile const int; +using B3 = A3; +struct S3 { + B3 x = 1; +}; +#else +S3 s3; +#endif } // Keep macros contained to one file.