Skip to content

Commit d27da81

Browse files
committed
fixup! [clang][dataflow] Propagate locations from result objects to initializers.
1 parent 96ca082 commit d27da81

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <cassert>
2828
#include <utility>
2929

30+
#define DEBUG_TYPE "dataflow"
31+
3032
namespace clang {
3133
namespace dataflow {
3234

@@ -553,8 +555,10 @@ class ResultObjectVisitor : public RecursiveASTVisitor<ResultObjectVisitor> {
553555
// All other expression nodes that propagate a record prvalue should have
554556
// exactly one child.
555557
llvm::SmallVector<Stmt *> Children(E->child_begin(), E->child_end());
556-
if (Children.size() != 1)
557-
E->dump();
558+
LLVM_DEBUG({
559+
if (Children.size() != 1)
560+
E->dump();
561+
});
558562
assert(Children.size() == 1);
559563
for (Stmt *S : Children)
560564
PropagateResultObject(cast<Expr>(S), Loc);

clang/lib/Analysis/FlowSensitive/Transfer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,14 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
470470
void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
471471
const Expr *InitExpr = S->getExpr();
472472
assert(InitExpr != nullptr);
473-
if (!(S->getType()->isRecordType() && S->isPRValue()))
474-
propagateValueOrStorageLocation(*InitExpr, *S, Env);
473+
474+
// If this is a prvalue of record type, the handler for `*InitExpr` (if one
475+
// exists) will initialize the result object; there is no value to propgate
476+
// here.
477+
if (S->getType()->isRecordType() && S->isPRValue())
478+
return;
479+
480+
propagateValueOrStorageLocation(*InitExpr, *S, Env);
475481
}
476482

477483
void VisitCXXConstructExpr(const CXXConstructExpr *S) {

0 commit comments

Comments
 (0)