llvm-project/clang/lib
Tomasz Kamiński 4ff836a138 [analyzer] Pass correct bldrCtx to computeObjectUnderConstruction
In case when the prvalue is returned from the function (kind is one
of `SimpleReturnedValueKind`, `CXX17ElidedCopyReturnedValueKind`),
then it construction happens in context of the caller.
We pass `BldrCtx` explicitly, as `currBldrCtx` will always refer to callee
context.

In the following example:
```
struct Result {int value; };
Result create() { return Result{10}; }
int accessValue(Result r) { return r.value; }

void test() {
   for (int i = 0; i < 2; ++i)
      accessValue(create());
}
```

In case when the returned object was constructed directly into the
argument to a function call `accessValue(create())`, this led to
inappropriate value of `blockCount` being used to locate parameter region,
and as a consequence resulting object (from `create()`) was constructed
into a different region, that was later read by inlined invocation of
outer function (`accessValue`).
This manifests itself only in case when calling block is visited more
than once (loop in above example), as otherwise there is no difference
in `blockCount` value between callee and caller context.
This happens only in case when copy elision is disabled (before C++17).

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D132030
2022-09-26 11:39:10 +02:00
..
APINotes
ARCMigrate [NFC] Typo fix in ARCMTActions.h 2022-09-18 12:34:24 +05:30
AST Re-apply "Deferred Concept Instantiation Implementation" 2022-09-22 05:53:59 -07:00
ASTMatchers Revert "ManagedStatic: remove from ASTMatchersInternal.h" 2022-07-27 15:46:21 +02:00
Analysis [clang][dataflow] Add support for nested method calls. 2022-09-22 19:16:31 +00:00
Basic [Clang][LoongArch] Add inline asm support for constraints f/l/I/K 2022-09-26 08:49:58 +08:00
CodeGen Fix MSVC "not all control paths return a value" warning. NFCI. 2022-09-26 10:27:38 +01:00
CrossTU Fixed a number of typos 2022-08-01 13:13:18 -04:00
DirectoryWatcher [clang] fix deprecation 2022-08-09 17:42:55 +02:00
Driver [clang-cl] Implement /ZH: flag 2022-09-25 14:43:14 -04:00
Edit [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
ExtractAPI [clang][ExtractAPI] Record availability information on all platforms 2022-08-19 14:54:52 -07:00
Format [clang-format] Handle constructor invocations after new operator in C# correct 2022-09-25 21:10:26 -07:00
Frontend Restore "[MemProf] Memprof profile matching and annotation" 2022-09-23 11:38:47 -07:00
FrontendTool [C++20][Modules][HU 1/5] Introduce header units as a module type. 2022-03-25 09:17:14 +00:00
Headers [HLSL] remove unnecessary abs attributes 2022-09-20 16:04:21 -05:00
Index [clang] Qualify auto in range-based for loops (NFC) 2022-09-03 23:27:27 -07:00
IndexSerialization
Interpreter [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
Lex [clang][modules][deps] Report modulemaps describing excluded headers 2022-09-22 12:36:05 -07:00
Parse Don't crash when code completing `using enum ^Foo`. 2022-09-26 04:52:19 +02:00
Rewrite [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
Sema [Clang] Warn when trying to dereference void pointers in C 2022-09-24 22:18:04 +08:00
Serialization [clang][modules][deps] Preserve module map load order 2022-09-22 12:54:51 -07:00
StaticAnalyzer [analyzer] Pass correct bldrCtx to computeObjectUnderConstruction 2022-09-26 11:39:10 +02:00
Support [RISCV][Clang] Support policy function for all vector segment load. 2022-08-04 17:47:24 +00:00
Testing [include-cleaner] Include-cleaner library structure, and simplistic AST walking. 2022-04-29 11:04:11 +02:00
Tooling [clang][modules][deps] Preserve module map load order 2022-09-22 12:54:51 -07:00
CMakeLists.txt [RISCV] Moving RVV intrinsic type related util to clang/Support 2022-04-20 21:13:13 +08:00