Page MenuHomePhabricator

Reduce hash collisions for reference and pointer types
AbandonedPublic

Authored by v.g.vassilev on Feb 23 2018, 2:15 PM.

Details

Reviewers
rtrieu
rsmith
Summary

While investigating the work done in D41416 I found out that the hash values for pointer and reference types are the same.

Diff Detail

Repository
rC Clang

Event Timeline

v.g.vassilev created this revision.Feb 23 2018, 2:15 PM

Looks reasonable, can you add a testcase that shows the ODR checker now distinguishes pointers/references to distinct types?

lib/AST/ODRHash.cpp
581

This looks redundant, the above Visit(const Type*) function seems to already do this.

rtrieu added inline comments.Feb 23 2018, 5:03 PM
lib/AST/ODRHash.cpp
581

That's correct, VisitType is intended to be empty. The TypeClass enum value is added in Visit so that it is the first value added to the data stream.

590

Use T->getPointeeTypeAsWritten() here.

v.g.vassilev added inline comments.Feb 24 2018, 2:35 AM
lib/AST/ODRHash.cpp
581

Ok, then I am a little confused. If VisitType is supposed to be nop why we call it in all VisitXXX functions.

rtrieu added inline comments.Feb 28 2018, 8:28 PM
lib/AST/ODRHash.cpp
581

Each Type calls its parent Type, all the way up to Type. It's just a manual traversal of the Type hierarchy. Right now, there's nothing in VisitType, but there might be in the future.

r328404 has been committed to support references and pointers.

v.g.vassilev abandoned this revision.Mar 24 2018, 2:55 PM

Ok, that's great! Sorry for the delay and thanks for landing a similar patch. Btw, we should probably find a more terse way to test the ODRHash, eg. with unittests.