aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
diff options
context:
space:
mode:
authorPaul Semel <semelpaul@gmail.com>2024-02-13 11:39:27 +0100
committerGitHub <noreply@github.com>2024-02-13 11:39:27 +0100
commita8fb0dcc41bf355a3bff9ad7165715a8b6012059 (patch)
tree34d2af8888e27bf38501cfbf7f17c6b8bd1ddca7 /clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
parent9ca1a1575a337931d0e49859f83a0d5b70916abd (diff)
downloadllvm-a8fb0dcc41bf355a3bff9ad7165715a8b6012059.zip
llvm-a8fb0dcc41bf355a3bff9ad7165715a8b6012059.tar.gz
llvm-a8fb0dcc41bf355a3bff9ad7165715a8b6012059.tar.bz2
[dataflow] CXXOperatorCallExpr equal operator might not be a glvalue (#80991)
Although in a normal implementation the assumption is reasonable, it seems that some esoteric implementation are not returning a T&. This should be handled correctly and the values be propagated. --------- Co-authored-by: martinboehme <mboehme@google.com>
Diffstat (limited to 'clang/unittests/Analysis/FlowSensitive/TransferTest.cpp')
-rw-r--r--clang/unittests/Analysis/FlowSensitive/TransferTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 55af702..4b3b351 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2313,6 +2313,42 @@ TEST(TransferTest, AssignmentOperatorWithInitAndInheritance) {
ASTContext &ASTCtx) {});
}
+TEST(TransferTest, AssignmentOperatorReturnsVoid) {
+ // This is a crash repro.
+ std::string Code = R"(
+ struct S {
+ void operator=(S&& other);
+ };
+ void target() {
+ S s;
+ s = S();
+ // [[p]]
+ }
+ )";
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {});
+}
+
+TEST(TransferTest, AssignmentOperatorReturnsByValue) {
+ // This is a crash repro.
+ std::string Code = R"(
+ struct S {
+ S operator=(S&& other);
+ };
+ void target() {
+ S s;
+ s = S();
+ // [[p]]
+ }
+ )";
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {});
+}
+
TEST(TransferTest, CopyConstructor) {
std::string Code = R"(
struct A {