diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -519,7 +519,7 @@ // TODO: Support allocator calls. if (Call.getKind() != CE_CXXAllocator) - if (Call.isArgumentConstructedDirectly(Idx)) + if (Call.isArgumentConstructedDirectly(Call.getASTArgumentIndex(Idx))) continue; // TODO: Allocators should receive the correct size and possibly alignment, diff --git a/clang/test/Analysis/temporaries.cpp b/clang/test/Analysis/temporaries.cpp --- a/clang/test/Analysis/temporaries.cpp +++ b/clang/test/Analysis/temporaries.cpp @@ -1231,3 +1231,19 @@ return coin ? S() : foo(); // no-warning } } // namespace return_from_top_frame + +#if __cplusplus >= 201103L +namespace arguments_of_operators { +struct S { + S() {} + S(const S &) {} +}; + +void test() { + int x = 0; + auto foo = [](S s, int &y) { y = 1; }; + foo(S(), x); + clang_analyzer_eval(x == 1); // expected-warning{{TRUE}} +} +} // namespace arguments_of_operators +#endif // __cplusplus >= 201103L