NNikolas Klauser[libc++] type_traits: fix short-circuiting in std::conjunction.
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[libc++] type_traits: fix short-circuiting in std::conjunction. Replace the two-level implementation with a simpler one that directly subclasses the predicates, avoiding the instantiation of the template to get the type member in a situation where we should short-circuit. This prevents incorrect diagnostics when the instantiated predicate contains a static assertion. Add a test case that reproduced the previous problem. The existing test case involving HasNoValue didn't catch the problem because HasNoValue was in the final position. The bug comes up when the predicate that shouldn't be instantiated is after the short-circuit position but there is more to follow, because then __conjunction_impl<False, BadPredicate, ...> instantiates __conjunction_impl<BadPredicate, ...> (in order to obtain its type member), which in turn instantiates BadPredicate in order to obtain its value member. In contrast the new implementation doesn't recurse in instantiation any further than it needs to, because it doesn't require particular members of the recursive case. I've also updated the test cases for std::disjunction to match, although it doesn't have the same particular bug (its implementation is quite different). Fixes #58490. Reviewed By: #libc, ldionne, philnik Spies: philnik, ldionne, libcxx-commits Differential Revision: https://reviews.llvm.org/D136318 | 3 年前 | |
[libc++] type_traits: fix short-circuiting in std::conjunction. Replace the two-level implementation with a simpler one that directly subclasses the predicates, avoiding the instantiation of the template to get the type member in a situation where we should short-circuit. This prevents incorrect diagnostics when the instantiated predicate contains a static assertion. Add a test case that reproduced the previous problem. The existing test case involving HasNoValue didn't catch the problem because HasNoValue was in the final position. The bug comes up when the predicate that shouldn't be instantiated is after the short-circuit position but there is more to follow, because then __conjunction_impl<False, BadPredicate, ...> instantiates __conjunction_impl<BadPredicate, ...> (in order to obtain its type member), which in turn instantiates BadPredicate in order to obtain its value member. In contrast the new implementation doesn't recurse in instantiation any further than it needs to, because it doesn't require particular members of the recursive case. I've also updated the test cases for std::disjunction to match, although it doesn't have the same particular bug (its implementation is quite different). Fixes #58490. Reviewed By: #libc, ldionne, philnik Spies: philnik, ldionne, libcxx-commits Differential Revision: https://reviews.llvm.org/D136318 | 3 年前 | |
[libc++] Remove the c++98 Lit feature from the test suite C++98 and C++03 are effectively aliases as far as Clang is concerned. As such, allowing both std=c++98 and std=c++03 as Lit parameters is just slightly confusing, but provides no value. It's similar to allowing both std=c++17 and std=c++1z, which we don't do. This was discovered because we had an internal bot that ran the test suite under both c++98 AND c++03 -- one of which is redundant. Differential Revision: https://reviews.llvm.org/D80926 | 5 年前 |