-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][dataflow] Fix getResultObjectLocation()
on CXXDefaultArgExpr
.
#85072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][dataflow] Fix getResultObjectLocation()
on CXXDefaultArgExpr
.
#85072
Conversation
@llvm/pr-subscribers-clang-analysis @llvm/pr-subscribers-clang Author: None (martinboehme) ChangesI'm working on an upcoming change that will improve the semantics of Full diff: https://github.com/llvm/llvm-project/pull/85072.diff 1 Files Affected:
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index a8c282f140b4cd..86c7f32f0104be 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2924,6 +2924,36 @@ TEST(TransferTest, ResultObjectLocation) {
});
}
+TEST(TransferTest, ResultObjectLocationForDefaultArgExpr) {
+ std::string Code = R"(
+ struct S {};
+ void funcWithDefaultArg(S s = S());
+ void target() {
+ funcWithDefaultArg();
+ // [[p]]
+ }
+ )";
+
+ using ast_matchers::cxxDefaultArgExpr;
+ using ast_matchers::match;
+ using ast_matchers::selectFirst;
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {
+ const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+ auto *DefaultArg = selectFirst<CXXDefaultArgExpr>(
+ "default_arg",
+ match(cxxDefaultArgExpr().bind("default_arg"), ASTCtx));
+ ASSERT_NE(DefaultArg, nullptr);
+
+ // The values for default arguments aren't modeled; we merely verify
+ // that we can get a result object location for a default arg.
+ Env.getResultObjectLocation(*DefaultArg);
+ });
+}
+
TEST(TransferTest, ResultObjectLocationForDefaultInitExpr) {
std::string Code = R"(
struct S {};
|
The newly added test is failing, but apparently only on Windows. Will need to take a closer look at why this is, and will update this PR when I have something new. |
The new test now does actually also fail for me locally. Not sure why I didn't notice this before. Will add a fix. |
a9193ba
to
7c61dc4
Compare
CXXDefaultArgExpr
.getResultObjectLocation()
on CXXDefaultArgExpr
.
New commit pushed with fix. I have changed the title and description of the PR accordingly. |
…pr`. This patch includes a test that causes an assertion failure without the other changes in this patch.
7c61dc4
to
dfa4da9
Compare
…pr`. (llvm#85072) This patch includes a test that causes an assertion failure without the other changes in this patch.
This patch includes a test that causes an assertion failure without the other
changes in this patch.