llvm-capstone/clang/lib/StaticAnalyzer/Core
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
..
AnalysisManager.cpp
AnalyzerOptions.cpp [clang] Use value instead of getValue (NFC) 2022-07-13 23:39:33 -07:00
APSIntType.cpp
BasicValueFactory.cpp [analyzer] Fix static_cast on pointer-to-member handling 2021-02-15 11:44:37 +03:00
BlockCounter.cpp
BugReporter.cpp [clang, clang-tools-extra] Use has_value instead of hasValue (NFC) 2022-07-12 22:47:41 -07:00
BugReporterVisitors.cpp [analyzer] Support implicit parameter 'self' in path note 2022-09-21 17:26:09 -07:00
CallDescription.cpp [clang] Don't use Optional::getValue (NFC) 2022-06-20 22:59:26 -07:00
CallEvent.cpp [analyzer] Pass correct bldrCtx to computeObjectUnderConstruction 2022-09-26 11:39:10 +02:00
Checker.cpp
CheckerContext.cpp [analyzer][NFC] Prefer using isa<> instead getAs<> in conditions 2022-06-15 16:58:13 +02:00
CheckerHelpers.cpp [analyzer] Model comparision methods of std::unique_ptr 2021-07-16 09:54:05 +05:30
CheckerManager.cpp [analyzer] Dump checker name if multiple checkers evaluate the same call 2021-11-02 14:42:14 +01:00
CheckerRegistryData.cpp
CMakeLists.txt [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
CommonBugCategories.cpp [analyzer] Introduce common bug category "Unused code". 2021-03-17 20:58:27 -07:00
ConstraintManager.cpp [analyzer][NFC] Add LLVM_UNLIKELY to assumeDualImpl 2022-06-07 12:48:48 +02:00
CoreEngine.cpp [clang] Qualify auto in range-based for loops (NFC) 2022-09-03 23:27:27 -07:00
DynamicExtent.cpp [analyzer] DynamicSize: Rename 'size' to 'extent' 2021-04-05 19:20:43 +02:00
DynamicType.cpp [clang] Add a raw_ostream operator<< overload for QualType 2022-04-20 22:09:05 +01:00
Environment.cpp [analyzer] Dump the environment entry kind as well 2022-09-13 09:04:27 +02:00
ExplodedGraph.cpp [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer 2021-10-20 17:43:31 +02:00
ExprEngine.cpp [analyzer] Prefer wrapping SymbolicRegions by ElementRegions 2022-09-13 08:58:46 +02:00
ExprEngineC.cpp [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
ExprEngineCallAndReturn.cpp [analyzer] Pass correct bldrCtx to computeObjectUnderConstruction 2022-09-26 11:39:10 +02:00
ExprEngineCXX.cpp [analyzer] Pass correct bldrCtx to computeObjectUnderConstruction 2022-09-26 11:39:10 +02:00
ExprEngineObjC.cpp [clang] Qualify auto in range-based for loops (NFC) 2022-09-03 23:27:27 -07:00
FunctionSummary.cpp
HTMLDiagnostics.cpp [clang] Use llvm::reverse (NFC) 2021-12-17 16:51:42 -08:00
LoopUnrolling.cpp [Clang][C++20] Support capturing structured bindings in lambdas 2022-08-04 10:12:53 +02:00
LoopWidening.cpp [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer 2021-10-20 17:43:31 +02:00
MemRegion.cpp [analyzer] Prefer wrapping SymbolicRegions by ElementRegions 2022-09-13 08:58:46 +02:00
PlistDiagnostics.cpp [clang] Use value instead of getValue (NFC) 2022-07-13 23:39:33 -07:00
PrettyStackTraceLocationContext.h
ProgramState.cpp [analyzer] Process non-POD array element destructors 2022-08-24 01:28:21 +02:00
RangeConstraintManager.cpp [clang][clang-tools-extra] LLVM_NODISCARD => [[nodiscard]]. NFC 2022-08-09 07:11:18 +00:00
RangedConstraintManager.cpp [analyzer] Fix crash in RangedConstraintManager.cpp 2022-03-23 08:26:40 -05:00
RegionStore.cpp [analyzer] LazyCompoundVals should be always bound as default bindings 2022-09-13 08:58:46 +02:00
SarifDiagnostics.cpp [clang] Convert for_each to range-based for loops (NFC) 2022-06-10 22:39:45 -07:00
SimpleConstraintManager.cpp [analyzer] Remove NotifyAssumeClients 2022-06-07 13:02:03 +02:00
SimpleSValBuilder.cpp [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
SMTConstraintManager.cpp [llvm][clang][NFC] updates inline licence info 2021-08-11 02:48:53 +00:00
Store.cpp [analyzer][NFC] Prefer using isa<> instead getAs<> in conditions 2022-06-15 16:58:13 +02:00
SValBuilder.cpp [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 09:12:46 -07:00
SVals.cpp [analyzer] Add new function clang_analyzer_value to ExprInspectionChecker 2022-07-15 20:07:04 +03:00
SymbolManager.cpp [analyzer] Add UnarySymExpr 2022-05-26 14:00:27 +02:00
TextDiagnostics.cpp Fix a typo (occured => occurred) 2022-02-08 21:35:26 +01:00
WorkList.cpp Use llvm::less_second (NFC) 2022-06-04 22:48:32 -07:00