[libc++] Fix error flags and exceptions propagated from input stream operations

Summary:
Before this patch, we would only ever throw an exception if the badbit
was set on the stream. The Standard is currently very unclear on how
exceptions should be propagated and what error flags should be set by
the input stream operations. This commit changes libc++ to behave under
a different (but valid) interpretation of the Standard. This interpretation
of the Standard matches what other implementations are doing.

I will submit a paper in San Diego to clarify the Standard such that the
interpretation used in this commit (and other implementations) is the only
possible one.

PR21586
PR15949
rdar://problem/15347558

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D49863

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357531 91177308-0d34-0410-b5e6-96231b3b80d8
42 files changed