[PATCH] D128013: [clang][dataflow] Add support for comma binary operator
Stanislav Gatev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 17 10:48:48 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba53906ceff1: [clang][dataflow] Add support for comma binary operator (authored by sgatev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128013/new/
https://reviews.llvm.org/D128013
Files:
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===================================================================
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3557,4 +3557,35 @@
});
}
+TEST_F(TransferTest, BinaryOperatorComma) {
+ std::string Code = R"(
+ void target(int Foo, int Bar) {
+ int &Baz = (Foo, Bar);
+ // [[p]]
+ }
+ )";
+ runDataflow(Code,
+ [](llvm::ArrayRef<
+ std::pair<std::string, DataflowAnalysisState<NoopLattice>>>
+ Results,
+ ASTContext &ASTCtx) {
+ ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+ const Environment &Env = Results[0].second.Env;
+
+ const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ ASSERT_THAT(BarDecl, NotNull());
+
+ const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
+ ASSERT_THAT(BazDecl, NotNull());
+
+ const StorageLocation *BarLoc =
+ Env.getStorageLocation(*BarDecl, SkipPast::Reference);
+ ASSERT_THAT(BarLoc, NotNull());
+
+ const StorageLocation *BazLoc =
+ Env.getStorageLocation(*BazDecl, SkipPast::Reference);
+ EXPECT_EQ(BazLoc, BarLoc);
+ });
+}
+
} // namespace
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -95,6 +95,11 @@
: Env.makeNot(LHSEqRHSValue));
break;
}
+ case BO_Comma: {
+ if (auto *Loc = Env.getStorageLocation(*RHS, SkipPast::None))
+ Env.setStorageLocation(*S, *Loc);
+ break;
+ }
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128013.437970.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220617/3e015301/attachment.bin>
More information about the cfe-commits
mailing list