diff options
author | Richard Trieu <rtrieu@google.com> | 2017-06-29 22:53:04 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2017-06-29 22:53:04 +0000 |
commit | 3e03d3ee547d8fb03b39e0446af48d379de05871 (patch) | |
tree | 5775c84ca42ae854c8734dc381dc31425fae76d4 | |
parent | d2d4c8db457daff37f89905bf4229fe2b719ed85 (diff) | |
download | bcm5719-llvm-3e03d3ee547d8fb03b39e0446af48d379de05871.tar.gz bcm5719-llvm-3e03d3ee547d8fb03b39e0446af48d379de05871.zip |
[ODRHash] Improve typedef handling.
Follow typedef chains to find the root type when processing types, and also
keep track of qualifiers.
llvm-svn: 306753
-rw-r--r-- | clang/lib/AST/ODRHash.cpp | 15 | ||||
-rw-r--r-- | clang/test/Modules/odr_hash.cpp | 16 |
2 files changed, 30 insertions, 1 deletions
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp index 05bed658f3f..5c8d151e081 100644 --- a/clang/lib/AST/ODRHash.cpp +++ b/clang/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<TypedefType>(UnderlyingType.getTypePtr())) { + UnderlyingType = Underlying->getDecl()->getUnderlyingType(); + } + AddType(UnderlyingType.getTypePtr()); VisitType(T); } diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp index c94940c73eb..f01c4e836a3 100644 --- a/clang/test/Modules/odr_hash.cpp +++ b/clang/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. |