This test makes sure that the "-frandomize-layout-seed" and
"-frandomize-layout-seed-file" flags generate the same layout for the
record.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| clang/unittests/AST/RandstructTest.cpp | ||
|---|---|---|
| 43 | There's an explanation below. | |
| 59 | The d'tors for the unique_ptrs is called if I place them in the tuple. I think it's because I can't do something like this: const unique_ptr<ASTUnit> std::tie(AST, ASTFileSeed) = makeAST(...); in the test functions. When I assign it as a non-initializer, it apparently calls the d'tor. So, kinda stumped on what to do. And the EXPECT_FALSE above is used because the ASSERT_FALSE adds an extra return point, which messes with the lambda. | |
| clang/unittests/AST/RandstructTest.cpp | ||
|---|---|---|
| 39–40 | constexpr llvm::StringLiteral Seed = ... or constexpr char Seed[] | |
| 41 | Change this to a normal function static std::pair<std::unique_ptr<ASTUnit>, std::unique_ptr<ASTUnit>>
makeAST(llvm::StringRef SourceCode) { | |
| 59 | I think std::unique_ptr should and can be used here. See comment above. | |
| 85 | return getFieldNamesFromRecord(LHSRD) == getFieldNamesFromRecord(RHSRD); | |
| clang/unittests/AST/RandstructTest.cpp | ||
|---|---|---|
| 59 | Yeah, it's just that it doesn't work. I actually tried it a lot of different ways before, of course, and it just doesn't work. Sorry about that. /usr/local/google/home/morbo/llvm/llvm-project/clang/unittests/AST/RandstructTest.cpp:73:10: error: no matching constructor for initialization of 'std::pair<std::unique_ptr<ASTUnit>, std::unique_ptr<ASTUnit>>'
return std::pair<std::unique_ptr<ASTUnit>, std::unique_ptr<ASTUnit>>(AST, ASTFileSeed);
^ ~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:266:17: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_ConstructiblePair()' was not satisfied [with _U1 = std::unique_ptr<clang::ASTUnit>, _U2 = std::unique_ptr<clang::ASTUnit>]
constexpr pair(const _T1& __a, const _T2& __b)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:276:26: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_ConstructiblePair()' was not satisfied [with _U1 = std::unique_ptr<clang::ASTUnit>, _U2 = std::unique_ptr<clang::ASTUnit>]
explicit constexpr pair(const _T1& __a, const _T2& __b)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:322:18: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_MoveCopyPair()' was not satisfied [with _U1 = std::unique_ptr<clang::ASTUnit> &]
constexpr pair(_U1&& __x, const _T2& __y)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:329:27: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_MoveCopyPair()' was not satisfied [with _U1 = std::unique_ptr<clang::ASTUnit> &]
explicit constexpr pair(_U1&& __x, const _T2& __y)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:336:18: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_CopyMovePair()' was not satisfied [with _U2 = std::unique_ptr<clang::ASTUnit> &]
constexpr pair(const _T1& __x, _U2&& __y)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:343:17: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_CopyMovePair()' was not satisfied [with _U2 = std::unique_ptr<clang::ASTUnit> &]
explicit pair(const _T1& __x, _U2&& __y)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:352:12: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_MoveConstructiblePair()' was not satisfied [with _U1 = std::unique_ptr<clang::ASTUnit> &, _U2 = std::unique_ptr<clang::ASTUnit> &]
constexpr pair(_U1&& __x, _U2&& __y)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:361:21: note: candidate template ignored: requirement '_PCC<true, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit>>>::_MoveConstructiblePair()' was not satisfied [with _U1 = std::unique_ptr<clang::ASTUnit> &, _U2 = std::unique_ptr<clang::ASTUnit> &]
explicit constexpr pair(_U1&& __x, _U2&& __y)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:300:19: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
constexpr pair(const pair<_U1, _U2>& __p)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:309:21: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
explicit constexpr pair(const pair<_U1, _U2>& __p)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:314:17: note: candidate constructor not viable: requires 1 argument, but 2 were provided
constexpr pair(const pair&) = default; ///< Copy constructor
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:315:17: note: candidate constructor not viable: requires 1 argument, but 2 were provided
constexpr pair(pair&&) = default; ///< Move constructor
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:371:12: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
constexpr pair(pair<_U1, _U2>&& __p)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:381:21: note: candidate constructor template not viable: requires single argument '__p', but 2 arguments were provided
explicit constexpr pair(pair<_U1, _U2>&& __p)
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:387:9: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:232:26: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
_GLIBCXX_CONSTEXPR pair()
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:245:26: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
explicit constexpr pair()
^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:452:9: note: candidate constructor template not viable: requires 4 arguments, but 2 were provided
pair(tuple<_Args1...>&, tuple<_Args2...>&,
^
1 error generated. | |
| clang/unittests/AST/RandstructTest.cpp | ||
|---|---|---|
| 59 | I think it will work if you change makeAST a function and use return {std::move(...), std::move(...)}; I have tested it locally. | |
| clang/unittests/AST/RandstructTest.cpp | ||
|---|---|---|
| 59 | I went a different path. PTAL. | |
constexpr llvm::StringLiteral Seed = ... or constexpr char Seed[]