File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
clang/unittests/Analysis/FlowSensitive Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -2735,6 +2735,39 @@ TEST(TransferTest, ResultObjectLocationForDefaultInitExpr) {
2735
2735
});
2736
2736
}
2737
2737
2738
+ // This test ensures that CXXOperatorCallExpr returning prvalues are correctly
2739
+ // handled by the transfer functions, especially that `getResultObjectLocation`
2740
+ // correctly returns a storage location for those.
2741
+ TEST (TransferTest, ResultObjectLocationForCXXOperatorCallExpr) {
2742
+ std::string Code = R"(
2743
+ struct A {
2744
+ A operator+(int);
2745
+ };
2746
+
2747
+ void target() {
2748
+ A a;
2749
+ a + 3;
2750
+ (void)0; // [[p]]
2751
+ }
2752
+ )" ;
2753
+ using ast_matchers::cxxOperatorCallExpr;
2754
+ using ast_matchers::match;
2755
+ using ast_matchers::selectFirst;
2756
+ using ast_matchers::traverse;
2757
+ runDataflow (
2758
+ Code,
2759
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
2760
+ ASTContext &ASTCtx) {
2761
+ const Environment &Env = getEnvironmentAtAnnotation (Results, " p" );
2762
+
2763
+ auto *CallExpr = selectFirst<CXXOperatorCallExpr>(
2764
+ " call_expr" ,
2765
+ match (cxxOperatorCallExpr ().bind (" call_expr" ), ASTCtx));
2766
+
2767
+ EXPECT_NE (&Env.getResultObjectLocation (*CallExpr), nullptr );
2768
+ });
2769
+ }
2770
+
2738
2771
TEST (TransferTest, StaticCast) {
2739
2772
std::string Code = R"(
2740
2773
void target(int Foo) {
You can’t perform that action at this time.
0 commit comments