Page MenuHomePhabricator

[Basic] Make SourceLocation usable as key in hash maps, NFCI
Needs ReviewPublic

Authored by miyuki on Tue, Nov 5, 4:11 AM.



This change creates a DenseMapInfo trait specialization for the
SourceLocation class. The empty key, the tombstone key and the hash
function are identical to DenseMapInfo<unsigned>, because we already
have hash maps that use raw the representation of SourceLocation as
a key.

The patch also converts the existing llvm::DenseMap<unsigned, T>,
llvm::DenseSet<unsigned> and std::map<unsigned, T> objects that store
source location as 'unsigned' to using SourceLocation directly.

Diff Detail

Event Timeline

miyuki created this revision.Tue, Nov 5, 4:11 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: cfe-commits. · View Herald Transcript
miyuki edited reviewers, added: JDevlieghere; removed: jdoerfert.Tue, Nov 5, 4:11 AM
miyuki updated this revision to Diff 227894.Tue, Nov 5, 8:52 AM

Changed getRawEncoding -> getHashValue in Sema.h

What's the motivation behind this?

miyuki added a comment.Tue, Nov 5, 9:18 AM

The motivation is to be able to make source locations' underlying type configurable. Richard Smith suggested that this might be feasible:
So, the first step is to get rid of getRawEncoding where possible. I think this would make the code cleaner anyway.