summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-11-07 00:59:29 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-11-07 00:59:29 +0000
commit68fa1a2411e8519c2d3d40e2f02291a5ca95a092 (patch)
treea272c1e5c60992f5216ad8b922774edd3d06d7a3
parent5717ecba8e7060b7e916d60f474aaead59b52798 (diff)
downloadbcm5719-llvm-68fa1a2411e8519c2d3d40e2f02291a5ca95a092.tar.gz
bcm5719-llvm-68fa1a2411e8519c2d3d40e2f02291a5ca95a092.zip
Reapply "ADT: Require explicit ilist iterator/pointer conversions"
This reverts commit r252373, reapplying r252372 now that I've updated clang-tools-extra. Original commit message follows. ADT: Require explicit ilist iterator/pointer conversions Disallow implicit conversions between ilist iterators and element points. Explicit conversions still work of course. This is the first step toward removing the undefined behaviour in `ilist` and `iplist`: http://lists.llvm.org/pipermail/llvm-dev/2015-October/091115.html The motivation for removing the implicit iterators is that I came across real bugs (that were *really* getting lucky). More details and some brief discussion later in that thread: http://lists.llvm.org/pipermail/llvm-dev/2015-October/091617.html Note: if you have out-of-tree code, it should be fairly easy to revert this patch downstream while you update your out-of-tree call sites. Note that these conversions are occasionally latent bugs (that may happen to "work" now, but only because of getting lucky with UB; follow-ups will change your luck). When they are valid, I suggest using `->getIterator()` to go from pointer to iterator, and `&*` to go from iterator to pointer. llvm-svn: 252380
-rw-r--r--llvm/include/llvm/ADT/ilist.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/include/llvm/ADT/ilist.h b/llvm/include/llvm/ADT/ilist.h
index 371518a04ca..c34434a1f76 100644
--- a/llvm/include/llvm/ADT/ilist.h
+++ b/llvm/include/llvm/ADT/ilist.h
@@ -220,8 +220,8 @@ private:
template<class T> void operator-(T) const;
public:
- ilist_iterator(pointer NP) : NodePtr(NP) {}
- ilist_iterator(reference NR) : NodePtr(&NR) {}
+ explicit ilist_iterator(pointer NP) : NodePtr(NP) {}
+ explicit ilist_iterator(reference NR) : NodePtr(&NR) {}
ilist_iterator() : NodePtr(nullptr) {}
// This is templated so that we can allow constructing a const iterator from
@@ -241,7 +241,7 @@ public:
void reset(pointer NP) { NodePtr = NP; }
// Accessors...
- operator pointer() const {
+ explicit operator pointer() const {
return NodePtr;
}
OpenPOWER on IntegriCloud