[PATCH] D81718: [Analyzer][NFC] Add methods `getReturnObject()` and `getArgObject()` to `CallEvent`
Balogh, Ádám via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 12 01:35:46 PDT 2020
baloghadamsoftware created this revision.
baloghadamsoftware added a reviewer: NoQ.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity, mgorny.
Herald added a reviewer: Szelethus.
There are cases when a checker cannot know in advance the nature of the return value they try to retrieve from a `CallEvent`. If it is a class instance then it must use `getReturnValueUnderConstruction()`. If it is not, then it must use `getReturnValue()`, because the former function returns `None` since only class instances have construction context.
Simlarly, arguments which are class instances passed by value are copy-constructed into the parameter. To retrieve them the checker needs to invoke `getParameterLocation()` instead of `getArgSVal()`. However, for basic types and class instances passed by pointer of reference only the latter can be used to track the value of the argument.
To save checkers from doing these branching all over the time this patch introduces two methods to `CallEvent`: `getReturnObject()` to get the correct return value and `getArgObject()` to get the correct argument.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81718
Files:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/unittests/StaticAnalyzer/CMakeLists.txt
clang/unittests/StaticAnalyzer/TestParameterLocation.cpp
clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81718.270319.patch
Type: text/x-patch
Size: 10702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200612/643fa5ea/attachment-0001.bin>
More information about the cfe-commits
mailing list