wangxindsb created this revision.
This implement a path-sensitive checker that warns if virtual calls are made
from constructors and destructors.
The checker use the GDM (generic data map) to store three integers in the
program state for constructors, destructors and objects. Once enter one of
wangxindsb updated this revision to Diff 103180.
wangxindsb added a comment.
Add test case for the patch
https://reviews.llvm.org/D34275
Files:
virtualcall.cpp
Index: virtualcall.cpp
===
--- virtualcall.cpp
+++ virtualcall.cpp
@
wangxindsb added a comment.
> I do not see any test cases for this patch. Could you add them as well?
I add the test case just now.
> How do you handle the following case?
>
> struct A {
> A() {
> X x;
> x.virtualMethod(); // this virtual call is ok
> }
> }
> int main(
wangxindsb added a comment.
> What about:
>
> struct A {
> A() {
> X x;
> x.virtualMethod(); // this virtual call is ok
> foo(); // should warn here
> }
> virtual foo();
> }
> int main() {
> A a;
> }
>
>
> Does the checker warn on the second call?
Yes,
wangxindsb updated this revision to Diff 103196.
wangxindsb added a comment.
Add test case for the virtual call checker.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: test/Analysis/virtualcall.cpp
wangxindsb updated this revision to Diff 103199.
wangxindsb added a comment.
Add run line in the test case.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: test/Analysis/virtualcall.cpp
=
wangxindsb marked 5 inline comments as done.
wangxindsb added inline comments.
Comment at: VirtualCallChecker.cpp:260
+ if (SFC->inTopFrame()) {
+ const FunctionDecl *FD = SFC->getDecl()->getAsFunction();
+if (!FD)
xazax.hun wrote:
> The formatting seems to
wangxindsb updated this revision to Diff 103214.
wangxindsb added a comment.
Correct some error in VirtualCallChecker.cpp.
Complete the test case.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: test/Analysis/vi
wangxindsb added a comment.
> Oh, I think I see how it works now. How about:
>
>
> struct A;
> struct X {
> void callFooOfA(A*);
> };
> struct A {
> A() {
> X x;
> x.virtualMethod(); // this virtual call is ok
> x.callFooOfA(this)
> }
> virtual foo();
wangxindsb updated this revision to Diff 103832.
wangxindsb added a comment.
Add license to VirtualCallChecker.cpp
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: test/Analysis/virtualcall.cpp
==
wangxindsb updated this revision to Diff 110899.
wangxindsb added a comment.
Fix the Assertion Failed when run the checker to check the building of
LibreOffice.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: t
wangxindsb updated this revision to Diff 111806.
wangxindsb added a comment.
+enum class ObjectState : bool { CtorCalled, DtorCalled };
+} // end namespace
Add namespace closing comment.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis
wangxindsb marked 3 inline comments as done.
wangxindsb added inline comments.
Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:29
namespace {
+enum class ObjectState : bool { CtorCalled, DtorCalled };
+} // end namespace
NoQ wrote:
> Please remind
wangxindsb updated this revision to Diff 111862.
wangxindsb added a comment.
- Rename reportbug();
- Change message "Pure function" to "pure virtual function";
- Fixing: expected-warning;
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis
wangxindsb added inline comments.
Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:31
+} // end namespace
+ // FIXME: Ascending over StackFrameContext maybe another method.
+
Add the FIXME
https://reviews.llvm.org/D34275
__
wangxindsb updated this revision to Diff 112110.
wangxindsb added a comment.
- Fix the errors of the tests;
- Add `-analyzer-output=text` to the run-line;
- Change the message of the visitor's diagnostic piece.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChec
wangxindsb added a comment.
@NoQ
In https://reviews.llvm.org/D34275#847434, @NoQ wrote:
> Most importantly, do you think we can enable the checker by default now? Was
> this checker evaluated on any large codebase, and if so, how many true/false
> positives did it find, probably compared to th
wangxindsb updated this revision to Diff 112196.
wangxindsb added a comment.
- Highlight pure virtual even in non-pure-only mode;
- Add change to the header.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
test/Analys
wangxindsb added a comment.
There are 105 alarms running the checker on the LibreOffice, 92 True positive,
13 not sure.
https://reviews.llvm.org/D34275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/li
wangxindsb updated this revision to Diff 104201.
wangxindsb marked an inline comment as done.
wangxindsb added a comment.
-Fix the bug of the virtual call during a function call of the object.
-Add flag for the PUREONLY.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/Virtu
wangxindsb updated this revision to Diff 105440.
wangxindsb added a comment.
- Rename the BugType.
- Correct the code style to be clang format.
- Rename the arguments to start with uppercase letter.
- Add the support to check for the constructor called by the New expr.
You don't need to put effor
wangxindsb added inline comments.
Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:332
+// Check the base of the callexpr is equal to the this of the ctor
+bool VirtualCallChecker::isCalledbyCtor(const CallExpr *CE,ProgramStateRef
State,const LocationContext *LCtx)
wangxindsb updated this revision to Diff 105738.
wangxindsb added a comment.
- Change the two bugtype to one.
- Use the generateErrorNode() for the pure virtual call.
- Change the test case for the new expression.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallC
wangxindsb updated this revision to Diff 105737.
wangxindsb added a comment.
- Change the two bugtype to one.
- Use the generateErrorNode() for the pure virtual call.
- Change the test case for the new expression.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallC
wangxindsb updated this revision to Diff 105760.
wangxindsb marked an inline comment as done.
wangxindsb added a comment.
- Use the map of object to ctor/dtor to check the virtual call.
- Use CXXInstanceCall and getCXXThisVal method to get the 'this' instead of
getThisSVal().
- Correct some forma
wangxindsb added a comment.
Look forward to your review.
https://reviews.llvm.org/D34275
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
wangxindsb updated this revision to Diff 106204.
wangxindsb added a comment.
- Change IsVirtualCall(const CallExpr *CE) to be a free static function.
- Rename some variables.
- Improve the BugReporterVisitor, enclose the declaration names in single
quotes.
- Hoist getSValBuilder() from the if sta
wangxindsb updated this revision to Diff 106243.
wangxindsb added a comment.
- Change function name to start with a lower case letter.
- Use `StringRef` instead of `const char * ' for ReportBug() const.
- Correct the braces for single statement blocks.
https://reviews.llvm.org/D34275
Files:
l
wangxindsb updated this revision to Diff 106654.
wangxindsb marked an inline comment as done.
wangxindsb added a comment.
- Change two maps to one map.
- Move the declarations of PSM and SVB after the next early return.
- Delete the variable std::string DeclName.
- Delete last return in reportbug(
wangxindsb marked 5 inline comments as done.
wangxindsb added inline comments.
Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:72
+REGISTER_MAP_WITH_PROGRAMSTATE(CtorMap, const MemRegion *, bool)
+REGISTER_MAP_WITH_PROGRAMSTATE(DtorMap, const MemRegion *, bool)
+
-
wangxindsb updated this revision to Diff 108236.
wangxindsb added a comment.
- Change the bugtype, just like the older checker.
https://reviews.llvm.org/D34275
Files:
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
test/Analysis/virtualcall.cpp
Index: test/Analysis/virtualcall.cpp
=
31 matches
Mail list logo