[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
martinboehme wrote: This is causing buildbots to fail because `isOriginalRecordConstructor()` is now unused. Reverting. https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
https://github.com/martinboehme closed https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
martinboehme wrote: CI failure looks unrelated https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
martinboehme wrote: Rebased to head and resolved merge conflicts. Will merge once checks pass. https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
https://github.com/martinboehme updated https://github.com/llvm/llvm-project/pull/87320 >From 96ca0820189c5c022a9a0501391e2ab6e08f6677 Mon Sep 17 00:00:00 2001 From: Martin Braenne Date: Tue, 2 Apr 2024 08:00:00 + Subject: [PATCH 1/3] [clang][dataflow] Propagate locations from result

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
@@ -6830,50 +6932,6 @@ TEST(TransferTest, LambdaCaptureThis) { }); } -TEST(TransferTest, DifferentReferenceLocInJoin) { martinboehme wrote: See explanation in PR description. (tl;dr: We can no longer set up the desired situation, so I replaced this

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
@@ -556,6 +763,10 @@ void Environment::pushCallInternal(const FunctionDecl *FuncDecl, const VarDecl *Param = *ParamIt; setStorageLocation(*Param, createObject(*Param, Args[ArgIndex])); } + + ResultObjectMap = std::make_shared( martinboehme wrote:

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
https://github.com/martinboehme updated https://github.com/llvm/llvm-project/pull/87320 >From 2d2aa88aab3e47e41588397471a90c03bb55d900 Mon Sep 17 00:00:00 2001 From: Martin Braenne Date: Tue, 2 Apr 2024 08:00:00 + Subject: [PATCH 1/3] [clang][dataflow] Propagate locations from result

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 Thread via cfe-commits
martinboehme wrote: > I know it is not exactly what we need, but I found > `Expr::skipRValueSubobjectAdjustments` in the compiler. I think it might be a > good idea to take a look just in case there is something we forgot to cover, > and maybe in the future we could look for factoring out

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-09 Thread Gábor Horváth via cfe-commits
@@ -6830,50 +6932,6 @@ TEST(TransferTest, LambdaCaptureThis) { }); } -TEST(TransferTest, DifferentReferenceLocInJoin) { Xazax-hun wrote: What is the main reason for removing this test? https://github.com/llvm/llvm-project/pull/87320

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -556,6 +763,10 @@ void Environment::pushCallInternal(const FunctionDecl *FuncDecl, const VarDecl *Param = *ParamIt; setStorageLocation(*Param, createObject(*Param, Args[ArgIndex])); } + + ResultObjectMap = std::make_shared( Xazax-hun wrote: I

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I know it is not exactly what we need, but I found `Expr::skipRValueSubobjectAdjustments` in the compiler. I think it might be a good idea to take a look just in case there is something we forgot to cover, and maybe in the future we could look for

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
martinboehme wrote: I think all comments should be addressed. @Xazax-hun Should be ready for further review. @ymand LMK if you have any additional comments. https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -460,25 +460,35 @@ class TransferVisitor : public ConstStmtVisitor { // So make sure we have a value if we didn't propagate one above. if (S->isPRValue() && S->getType()->isRecordType()) { if (Env.getValue(*S) == nullptr) { -Value *Val =

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
https://github.com/martinboehme updated https://github.com/llvm/llvm-project/pull/87320 >From 2d2aa88aab3e47e41588397471a90c03bb55d900 Mon Sep 17 00:00:00 2001 From: Martin Braenne Date: Tue, 2 Apr 2024 08:00:00 + Subject: [PATCH 1/2] [clang][dataflow] Propagate locations from result

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -688,71 +682,51 @@ class TransferVisitor : public ConstStmtVisitor { return; } -llvm::DenseMap FieldLocs; -RecordInitListHelper InitListHelper(S); +RecordStorageLocation = Env.getResultObjectLocation(*S); +Env.setValue(*S,

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -460,25 +460,35 @@ class TransferVisitor : public ConstStmtVisitor { // So make sure we have a value if we didn't propagate one above. if (S->isPRValue() && S->getType()->isRecordType()) { if (Env.getValue(*S) == nullptr) { -Value *Val =

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I did not finish reviewing this, but wanted to send a couple of questions early to parallelize the process a bit. https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-02 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-analysis Author: None (martinboehme) Changes Previously, we were propagating storage locations the other way around, i.e. from initializers to result objects, using `RecordValue::getLoc()`. This gave the wrong behavior

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-02 Thread via cfe-commits
https://github.com/martinboehme created https://github.com/llvm/llvm-project/pull/87320 Previously, we were propagating storage locations the other way around, i.e. from initializers to result objects, using `RecordValue::getLoc()`. This gave the wrong behavior in some cases -- see the newly