Skip to content

Commit 8be36bf

Browse files
fmayerLukacma
authored andcommitted
[FlowSensitive] [Optional] Fix absl::in_place (llvm#163897)
The mock was not accurate, absl defines in_place[_t] as an alias to std::in_place[_t].
1 parent f750610 commit 8be36bf

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ auto nulloptTypeDecl() {
241241
auto hasNulloptType() { return hasType(nulloptTypeDecl()); }
242242

243243
auto inPlaceClass() {
244-
return recordDecl(hasAnyName("std::in_place_t", "absl::in_place_t",
245-
"base::in_place_t", "folly::in_place_t",
246-
"bsl::in_place_t"));
244+
return namedDecl(hasAnyName("std::in_place_t", "absl::in_place_t",
245+
"base::in_place_t", "folly::in_place_t",
246+
"bsl::in_place_t"));
247247
}
248248

249249
auto isOptionalNulloptConstructor() {

clang/unittests/Analysis/FlowSensitive/MockHeaders.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ struct is_scalar
459459
template <>
460460
struct is_scalar<nullptr_t> : public true_type {};
461461
462+
struct in_place_t {};
463+
464+
constexpr in_place_t in_place;
465+
462466
} // namespace std
463467
464468
#endif // STD_TYPE_TRAITS_H
@@ -511,9 +515,8 @@ using remove_reference_t = typename std::remove_reference<T>::type;
511515
template <typename T>
512516
using decay_t = typename std::decay<T>::type;
513517
514-
struct in_place_t {};
515-
516-
constexpr in_place_t in_place;
518+
using std::in_place;
519+
using std::in_place_t;
517520
} // namespace absl
518521
519522
#endif // ABSL_TYPE_TRAITS_H
@@ -589,9 +592,6 @@ static constexpr char StdOptionalHeader[] = R"(
589592
590593
namespace std {
591594
592-
struct in_place_t {};
593-
constexpr in_place_t in_place;
594-
595595
struct nullopt_t {
596596
constexpr explicit nullopt_t() {}
597597
};

0 commit comments

Comments
 (0)