I accidentally used `cast` instead of `cast_or_null`.
Reviewed By: sammccall, xazax.hun
Differential Revision: https://reviews.llvm.org/D153956
const Expr *Arg = S->getArg(0);
assert(Arg != nullptr);
- auto *ArgLoc = cast<AggregateStorageLocation>(
+ auto *ArgLoc = cast_or_null<AggregateStorageLocation>(
Env.getStorageLocation(*Arg, SkipPast::Reference));
if (ArgLoc == nullptr)
return;
});
}
+TEST(TransferTest, CopyConstructorArgIsRefReturnedByFunction) {
+ // This is a crash repro.
+ std::string Code = R"(
+ struct S {};
+ const S &returnsSRef();
+ void target() {
+ S s(returnsSRef());
+ }
+ )";
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {});
+}
+
TEST(TransferTest, MoveConstructor) {
std::string Code = R"(
namespace std {