diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2017-03-07 18:47:48 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@dberlin.org> | 2017-03-07 18:47:48 +0000 |
commit | 48522c9e13866e9e554040f10037dc617023e4f5 (patch) | |
tree | 0c5497611f3093936673d6cf5d372e666946e915 /lldb/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py | |
parent | c86b2134c79ed9791fc87269b23c89fd1669dfcd (diff) | |
download | bcm5719-llvm-48522c9e13866e9e554040f10037dc617023e4f5.tar.gz bcm5719-llvm-48522c9e13866e9e554040f10037dc617023e4f5.zip |
Make SmallPtrSet count and find able to take const PtrType's
Summary:
For our set/map types, count/find normally take const references.
This works well for non-pointer types, but can suck for pointer
types.
DenseSet<int *> foo;
const int *b = nullptr;
foo.count(b) does not work
but the equivalent reference version does work
(patch to fix DenseSet/DenseMap coming up)
For SmallPtrSet, you have no such option.
The following will not work right now:
SmallPtrSet<int *> foo;
const int *b = nullptr;
foo.count(b);
This makes const correctness hard in some cases.
Example:
SmallPtrSet<Instruction *> InstructionsToErase;
You can't make this SmallPtrSet<const Instruction *> because then you
can't erase the instruction. If I want to see if something is in the
set, I may only have a const Instruction *. Given that count and find
are non-mutating, this should just work.
The places in our code base that do this resort to const_cast :(.
This patch makes count and find able to be used with const Instruction
* in the above SmallPtrSet examples.
This is a bit annoying because of where C++ applies the const, so we
have to remove the pointer type from the passed-in-type and rebuild it
with const.
Reviewers: dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D30608
llvm-svn: 297180
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py')
0 files changed, 0 insertions, 0 deletions