Commit Graph

32 Commits

Author SHA1 Message Date
Howard Hinnant
9a894d93de Zhihao Yuan noted that there were a few unneeded statements. Eliminated the unnecessary ones, and commented the ones that are there for non-obvious reasons such as to help things limp along in C++03 language mode.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@189039 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-22 18:29:50 +00:00
Howard Hinnant
0f678bd69e Nico Rieck: this patch series fixes visibility issues on Windows as explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188192 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 18:38:34 +00:00
Marshall Clow
193ef03eb5 N3644 support for <unordered_set> and <unordered_map>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187915 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-07 21:30:44 +00:00
Howard Hinnant
824c19963e debug mode for unordered_map. Also picked up a missing check and test in unordered_multimap. This wraps up debug mode for the unordered containers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187659 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-02 17:50:49 +00:00
Howard Hinnant
8b00e6c960 Ok, 3 major changes for debug mode in one commit:
1.  I had been detecting and trapping iterator == and \!= among iterators
    in different containers as an error.  But the trapping itself is actually
    an error.
    
    Consider:
    
    #include <iostream>
    #include <vector>
    #include <algorithm>

    template <class C>
    void
    display(const C& c)
    {
        std::cout << "{";
        bool first = true;
        for (const auto& x : c)
        {
            if (\!first)
                std::cout << ", ";
            first = false;
            std::cout << x;
        }
        std::cout << "}\n";
    }

    int
    main()
    {
        typedef std::vector<int> V;
        V v1 = {1, 3, 5};
        V v2 = {2, 4, 6};
        display(v1);
        display(v2);
        V::iterator i = std::find(v1.begin(), v1.end(), 1);
        V::iterator j = std::find(v2.begin(), v2.end(), 2);
        if (*i == *j)
            i = j;    // perfectly legal
        // ...
        if (i \!= j)   // the only way to check
            v2.push_back(*i);
        display(v1);
        display(v2);
    }

    It is legal to assign an iterator from one container to another of the
    same type.  This is required to work.  One might want to test whether or
    not such an assignment had been made.  The way one performs such a check
    is using the iterator's ==, \!= operator.  This is a logical and necessary
    function and does not constitute an error.

2.  I had a header circular dependence bug when _LIBCPP_DEBUG2 is defined.
    This caused a problem in several of the libc++ tests.
    Fixed.

3.  There is a serious problem when _LIBCPP_DEBUG2=1 at the moment in that
    std::basic_string is inoperable.  std::basic_string uses __wrap_iterator
    to implement its iterators.  __wrap_iterator has been rigged up in debug
    mode to support vector.  But string hasn't been rigged up yet.  This means
    that one gets false positives when using std::string in debug mode.  I've
    upped std::string's priority in www/debug_mode.html.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187636 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-02 00:26:35 +00:00
Howard Hinnant
0bb0a7c9ea Debug mode for unordered_multiset. The exercise spotted a few places I had missed on unordered_set, so I picked those up as well.
There are actually two debug modes:

   1.  -D_LIBCPP_DEBUG2 or -D_LIBCPP_DEBUG2=1
       This is a relatively expensive debug mode, but very thorough.  This is normally what you want to debug with, but may turn O(1) operations into O(N) operations.

   2.  -D_LIBCPP_DEBUG2=0
       This is "debug lite."  Only preconditions that can be checked with O(1) expense are checked.  For example range checking on an indexing operation.  But not iterator validity.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187369 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-29 19:05:47 +00:00
Howard Hinnant
39213641f4 Debug mode for unordered_set. I believe this to be fairly complete for
unordered_set, however it is not complete yet for unordered_multiset,
unordered_map or unordered_multimap.  There has been a lot of work done
for these other three containers, however that work was done just to
keep all of the tests passing.

You can try this out with -D_LIBCPP_DEBUG2.  You will have to link to a
libc++.dylib that has been compiled with src/debug.cpp.  So far, vector
(but not vector<bool>), list, and unordered_set are treated.  I hope to
get the other three unordered containers up fairly quickly now that
unordered_set is done.

The flag _LIBCPP_DEBUG2 will eventually be changed to _LIBCPP_DEBUG, but
not today.  This is my second effort at getting debug mode going for
libc++, and I'm not quite yet ready to throw all of the work under the
first attempt away.

The basic design is that all of the debug information is kept in a
central database, instead of in the containers.  This has been done as
an attempt to have debug mode and non-debug mode be ABI compatible with
each other.  There are some circumstances where if you construct a
container in an environment without debug mode and pass it into debug
mode, the checking will get confused and let you know with a readable
error message.  Passing containers the other way: from debug mode out to
a non-debugging mode container should be 100% safe (at least that is the
goal).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@186991 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 22:01:58 +00:00
Howard Hinnant
7a6b7cedcb Implement full support for non-pointer types in custom allocators. This is for the unordered containers only. This work still needs to be done on the sequence containers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@184635 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 15:21:29 +00:00
Howard Hinnant
83eade6abb No functionality change at this time. I've split _LIBCPP_VISIBLE up into two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@176593 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-06 23:30:19 +00:00
Howard Hinnant
33be35effe Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you send me a patch to CREDITS.TXT?
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@163862 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14 00:39:16 +00:00
Howard Hinnant
7a44515588 This commit establishes a new bucket_count policy in the unordered containers: The policy now allows a power-of-2 number of buckets to be requested (and that request honored) by the client. And if the number of buckets is set to a power of 2, then the constraint of the hash to the number of buckets uses & instead of %. If the client does not specify a number of buckets, then the policy remains unchanged: a prime number of buckets is selected. The growth policy is that the number of buckets is roughly doubled when needed. While growing, either the prime, or the power-of-2 strategy will be preserved. There is a small run time cost for putting in this switch. For very cheap hash functions, e.g. identity for int, the cost can be as high as 18%. However with more typical use cases, e.g. strings, the cost is in the noise level. I've measured cases with very cheap hash functions (int) that using a power-of-2 number of buckets can make look up about twice as fast. However I've also noted that a power-of-2 number of buckets is more susceptible to accidental catastrophic collisions. Though I've also noted that accidental catastrophic collisions are also possible when using a prime number of buckets (but seems far less likely). In short, this patch adds an extra tuning knob for those clients trying to get the last bit of performance squeezed out of their hash containers. Casual users of the hash containers will not notice the introduction of this tuning knob. Those clients who swear by power-of-2 hash containers can now opt-in to that strategy. Clients who prefer a prime number of buckets can continue as they have.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159836 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 17:31:14 +00:00
Howard Hinnant
f8880d0b85 As an extension, support incomplete types in the unordered containers to match what we already do in the associative containers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@146376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-12 17:26:24 +00:00
Howard Hinnant
ec3773c2da Quash a whole bunch of warnings
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145624 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-01 20:21:04 +00:00
Howard Hinnant
9996844df0 Further macro protection by replacing _[A-Z] with _[A-Z]p
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145410 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 18:15:50 +00:00
Howard Hinnant
66c6f9733b Add protection from min/max macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145407 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 16:45:27 +00:00
Howard Hinnant
08e17472e4 Windows support by Ruben Van Boxem.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@142235 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 20:05:10 +00:00
Howard Hinnant
199d0aec1b Fixed PR10507 (http://llvm.org/bugs/show_bug.cgi?id=10507)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136595 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-31 17:04:30 +00:00
Chandler Carruth
a73da5d2ca Revert r136546, which was submitted without review.
Original change:
Destruct elements of hash tables when removing individual entries from
the hash_table. I think this is the correct solution to PR10507, but I'm
not sure since this is a little bit cargo-culted. Howard, please review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 21:10:16 +00:00
Sean Hunt
b59b929cc9 Destruct elements of hash tables when removing individual entries from
the hash_table. I think this is the correct solution to PR10507, but I'm
not sure since this is a little bit cargo-culted. Howard, please review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136546 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 00:18:12 +00:00
Howard Hinnant
9f66bffdbe Fix uninitialized loop counter. http://llvm.org/bugs/show_bug.cgi?id=10278
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134405 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 14:14:17 +00:00
Howard Hinnant
0949eedbd6 _STD -> _VSTD to avoid macro clash on windows
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134190 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 21:18:19 +00:00
Howard Hinnant
2b1b2d40d7 Provide names for template and function parameters in forward declarations. The purpose is to aid automated documentation tools.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@133008 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 19:58:17 +00:00
Howard Hinnant
5f2f14c5d2 noexcept for <unordered_map>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132646 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 18:54:24 +00:00
Howard Hinnant
df85e57f4a Fixed two problems found by Chris Jefferson: Made operator>> for char consistent with gcc. Opened an LWG issue on this one. 2) Renamed some private typedefs which are causing boost grief.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@126576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-27 18:02:02 +00:00
Howard Hinnant
2529d02b5d Qualify calls to addressof with std::. Bug 9106
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@124726 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 17:36:20 +00:00
Howard Hinnant
b64f8b07c1 license change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@119395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-16 22:09:02 +00:00
Howard Hinnant
99acc5008b visibility-decoration.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@114451 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-21 17:32:39 +00:00
Howard Hinnant
bfd5530c06 Fix whitespace
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@113089 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-04 23:46:48 +00:00
Howard Hinnant
73d21a4f07 Changed __config to react to all of clang's currently documented has_feature flags, and renamed _LIBCPP_MOVE to _LIBCPP_HAS_NO_RVALUE_REFERENCES to be more consistent with the rest of the libc++'s flags, and with clang's nomenclature.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@113086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-04 23:28:19 +00:00
Howard Hinnant
324bb03bb9 Fixing whitespace problems
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@111750 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 00:02:43 +00:00
Howard Hinnant
f5256e16df Wiped out some non-ascii characters that snuck into the copyright.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 21:36:01 +00:00
Howard Hinnant
bc8d3f97eb libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 19:42:16 +00:00