[PATCH] D154421: [clang][dataflow] Add a test for a struct that is directly self-referential through a reference.
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 4 03:42:14 PDT 2023
mboehme updated this revision to Diff 537029.
mboehme added a comment.
Actually make the test pass. It was missing an indirection.
No idea how I missed this on the initial upload...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154421/new/
https://reviews.llvm.org/D154421
Files:
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
@@ -656,6 +656,30 @@
});
}
+TEST(TransferTest, DirectlySelfReferentialReference) {
+ std::string Code = R"(
+ struct target {
+ target() {
+ (void)0;
+ // [[p]]
+ }
+ target &self = *this;
+ };
+ )";
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {
+ const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+ const ValueDecl *SelfDecl = findValueDecl(ASTCtx, "self");
+
+ auto *ThisLoc = Env.getThisPointeeStorageLocation();
+ auto *RefVal =
+ cast<ReferenceValue>(Env.getValue(ThisLoc->getChild(*SelfDecl)));
+ ASSERT_EQ(&RefVal->getReferentLoc(), ThisLoc);
+ });
+}
+
TEST(TransferTest, MultipleVarsDecl) {
std::string Code = R"(
void target() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154421.537029.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230704/0d6dbcfd/attachment.bin>
More information about the cfe-commits
mailing list