[ODRHash] Improve typedef handling.
Follow typedef chains to find the root type when processing types, and also
keep track of qualifiers.
llvm-svn: 306753
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 05bed65..5c8d151 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -430,6 +430,13 @@
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 @@
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);
}