diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-13 20:44:56 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-13 20:44:56 +0000 |
commit | de03ff572138c56dab846f26d1a4bde1aa1f59d9 (patch) | |
tree | d2f2837f400366db02f2563bd8444e0ebd2d64d6 /llvm/lib/IR/LLVMContextImpl.h | |
parent | b56d8433483b9b5a99ef5f3b3540193561e54670 (diff) | |
download | bcm5719-llvm-de03ff572138c56dab846f26d1a4bde1aa1f59d9.tar.gz bcm5719-llvm-de03ff572138c56dab846f26d1a4bde1aa1f59d9.zip |
IR: Add MDLocation class
Add a new subclass of `UniquableMDNode`, `MDLocation`. This will be the
IR version of `DebugLoc` and `DILocation`. The goal is to rename this
to `DILocation` once the IR classes supersede the `DI`-prefixed
wrappers.
This isn't used anywhere yet. Part of PR21433.
llvm-svn: 225824
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.h')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index 11b8d38f9af..6ebc567f808 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -215,6 +215,48 @@ struct MDTupleInfo { } }; +/// \brief DenseMapInfo for MDLocation. +struct MDLocationInfo { + struct KeyTy { + unsigned Line; + unsigned Column; + Metadata *Scope; + Metadata *InlinedAt; + + KeyTy(unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt) + : Line(Line), Column(Column), Scope(Scope), InlinedAt(InlinedAt) {} + + KeyTy(const MDLocation *L) + : Line(L->getLine()), Column(L->getColumn()), Scope(L->getScope()), + InlinedAt(L->getInlinedAt()) {} + + bool operator==(const MDLocation *RHS) const { + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) + return false; + return Line == RHS->getLine() && Column == RHS->getColumn() && + Scope == RHS->getScope() && InlinedAt == RHS->getInlinedAt(); + } + }; + static inline MDLocation *getEmptyKey() { + return DenseMapInfo<MDLocation *>::getEmptyKey(); + } + static inline MDLocation *getTombstoneKey() { + return DenseMapInfo<MDLocation *>::getTombstoneKey(); + } + static unsigned getHashValue(const KeyTy &Key) { + return hash_combine(Key.Line, Key.Column, Key.Scope, Key.InlinedAt); + } + static unsigned getHashValue(const MDLocation *U) { + return getHashValue(KeyTy(U)); + } + static bool isEqual(const KeyTy &LHS, const MDLocation *RHS) { + return LHS == RHS; + } + static bool isEqual(const MDLocation *LHS, const MDLocation *RHS) { + return LHS == RHS; + } +}; + class LLVMContextImpl { public: /// OwnedModules - The set of modules instantiated in this context, and which @@ -246,6 +288,7 @@ public: DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues; DenseSet<MDTuple *, MDTupleInfo> MDTuples; + DenseSet<MDLocation *, MDLocationInfo> MDLocations; // MDNodes may be uniqued or not uniqued. When they're not uniqued, they // aren't in the MDNodeSet, but they're still shared between objects, so no |