std::vector::iterator type may be a pointer, then iterator::value_type fails to compile since iterator is not a class, namespace, or enumeration.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Without this, the error (abbreviated) is:
lib/CodeGen/AsmPrinter/DwarfDebug.cpp: error: 'llvm::MapVector<>::const_iterator' (aka 'const std::pair<> *') is not a class, namespace, or enumeration
@hans, it would be useful to merge this into LLVM 7.
Hi, I know it's a minor change but it should be easy to add a test case for it (a unit test would be appropriate here), especially considering this isn't currently causing issues in any of the current builds as far as I can tell. Also while I'm not insisting, a more-descriptive explanation of the change be nice as it currently, just a sentence or two, so it's more clear on the mailing lists. Thank you.
I have slightly extended the description.
I don't think this is possible to test with a unit test, as this requires an integration test with a c++ library those std::vector::iterator is a pointer. libc++ becomes such a library with this diff applied to include/vector:
typedef typename __base::pointer pointer; typedef typename __base::const_pointer const_pointer; + typedef typename __base::pointer iterator; + typedef typename __base::const_pointer const_iterator; - typedef __wrap_iter<pointer> iterator; - typedef __wrap_iter<const_pointer> const_iterator;
Alright, I'll just run this on a single buildbot and then land it. (I think it's possible to mock it, I can make a differential for a testcase later myself)
Do you have an example of a c++ std library where this happens?
@hans, it would be useful to merge this into LLVM 7.
I've put it on my list, but we're currently not planning another release candidate before final, so it may have to wait for 7.0.1.
Do you have an example of a c++ std library where this happens?
I'm using libc++ with the patch given above. I don't know about other libraries where iterators are pointers, only that this is allowed by the C++ standard.
we're currently not planning another release candidate before final, so it may have to wait for 7.0.1.
That's probably OK if all popular C++ libraries have iterator::value_type, although I'd be surprised if that's the case because its existence seems to be a non standardized convention.
Do you have an example of a c++ std library where this happens?
I have noticed that EASTL also has a pointer iterator: https://github.com/electronicarts/EASTL/blob/3.12.04/include/EASTL/vector.h#L20