forked from OSchip/llvm-project
Don't rely on the default constructor default constructing a begin and
end iterator for iterator_range<>. I removed this constructor because for some iterators (notably pointers) it left begin and end uninitialized. It also is an usual constraint that an iterator default constructs to a valid end iterator such that the pair of them for a valid range. In the three places where this was used in Clang, explicitly build the empty range from the iterators and comment on why default constructed iterators make sense here. llvm-svn: 225594
This commit is contained in:
parent
c491f72e7a
commit
68fba279bc
|
@ -75,7 +75,10 @@ inline DeclContext::lookups_range DeclContext::lookups() const {
|
|||
if (StoredDeclsMap *Map = Primary->buildLookup())
|
||||
return lookups_range(all_lookups_iterator(Map->begin(), Map->end()),
|
||||
all_lookups_iterator(Map->end(), Map->end()));
|
||||
return lookups_range();
|
||||
|
||||
// Synthesize an empty range. This requires that two default constructed
|
||||
// versions of these iterators form a valid empty range.
|
||||
return lookups_range(all_lookups_iterator(), all_lookups_iterator());
|
||||
}
|
||||
|
||||
inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
|
||||
|
@ -91,7 +94,10 @@ inline DeclContext::lookups_range DeclContext::noload_lookups() const {
|
|||
if (StoredDeclsMap *Map = Primary->getLookupPtr())
|
||||
return lookups_range(all_lookups_iterator(Map->begin(), Map->end()),
|
||||
all_lookups_iterator(Map->end(), Map->end()));
|
||||
return lookups_range();
|
||||
|
||||
// Synthesize an empty range. This requires that two default constructed
|
||||
// versions of these iterators form a valid empty range.
|
||||
return lookups_range(all_lookups_iterator(), all_lookups_iterator());
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
|
@ -178,7 +178,8 @@ inline DeclContext::ddiag_range DeclContext::ddiags() const {
|
|||
= static_cast<DependentStoredDeclsMap*>(getPrimaryContext()->getLookupPtr());
|
||||
|
||||
if (!Map)
|
||||
return ddiag_range();
|
||||
// Return an empty range using the always-end default constructor.
|
||||
return ddiag_range(ddiag_iterator(), ddiag_iterator());
|
||||
|
||||
return ddiag_range(ddiag_iterator(Map->FirstDiagnostic), ddiag_iterator());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue