[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-03-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL297323: [analyzer] Teach the MallocChecker about about Glib API (authored by zaks). Changed prior to commit: https://reviews.llvm.org/D28348?vs=89825&id=91101#toc Repository: rL LLVM https://reviews

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-03-01 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment. Hi Anna, Thanks for your review! > The information generated by this checker is used for array bounds checking. > For example, see https://reviews.llvm.org/D24307 I will read carefully about that ;-) > This patch looks good. Do you have commit access or should I com

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-03-01 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision. zaks.anna added a comment. This revision is now accepted and ready to land. > I am not clear why need to calculate the precise allocated size? The information generated by this checker is used for array bounds checking. For example, see https://reviews.llvm.org/

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-26 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 89825. xiangzhai added a comment. Hi Anna, Thanks for your review! I updated the Glib-MallocChecker-single-size-value.patch to use **zeroVal** for **g_malloc0** and **g_try_malloc0** and Yes, I refer CallocMem to implement **SValBinMulOp** in the Glib-M

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment. > Firstly I uploaded Glib-MallocChecker-single-size-value.patch for code > review, if submitted to UPSTREAM, then upload another one, correct? Yes. By the way, you can model XXX_n variants similarly to how calloc is modeled (see CallocMem). Comment

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-22 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 89460. xiangzhai added a comment. Hi Anna, Thanks for your suggest! Firstly I uploaded Glib-MallocChecker-single-size-value.patch for code review, if submitted to UPSTREAM, then upload another one, correct? Regards, Leslie Zhai Repository: rL LLVM h

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-22 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment. Could you please split the patch into two - one with the previously reviewed support for functions that take a single size value and another patch that models the two size arguments (num and size). It's easier to review patches if they do not grow new functionality. S

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-22 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 89333. xiangzhai added a comment. Fixed the confused State->getSVal(CE->getArg(1), C.getLocationContext()); with CE->getArg(1) issue. Repository: rL LLVM https://reviews.llvm.org/D28348 Files: lib/StaticAnalyzer/Checkers/MallocChecker.cpp t

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-22 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 89331. xiangzhai added a comment. Hi Anna, I added **svalBinMulOp** to take BO_Mul evalBinOp for g_malloc_n's two arguments: CE->getArg(0) and CE->getArg(1), so it does **NOT** need to change **MallocMemAux** any more, but just use it in this way: Sta

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-19 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment. Hi Anna, I am not clear why need to calculate the precise allocated size? for example: void *ptr = malloc(size); void *gptr = g_malloc_n(n_blocks, n_block_bytes); Memory-leak and Use-after-free issues' MallocChecker need the ***size*** or ***n_blocks*** x ***n_block_

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-19 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai marked 3 inline comments as done. xiangzhai added a comment. Hi Anna, Thank you so much for the review! I will try to implement extend MallocMemAux and ReallocMem in the follow up patch. Regards, Leslie Zhai Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cp

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-17 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:885 +return; + State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State); + State = ProcessZeroAllocation(C, CE, 0, State); I am not sure this is

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-12 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 84209. xiangzhai added a comment. Hi Anna, Thanks for your review! I process them (for example, g_malloc_n, take a different number of arguments) separately. And I run the testcases for Analysis/malloc.c and Analysis/gmalloc.c Regards, Leslie Zhai Rep

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-12 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:810 +if (CE->getNumArgs() == 2) + State = ProcessZeroAllocation(C, CE, 1, State); } else if (CE->getNumArgs() == 3) { Why did you remove the old beh

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-09 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 83758. xiangzhai marked 2 inline comments as done. xiangzhai added a comment. make II_g_*malloc*_n sense Repository: rL LLVM https://reviews.llvm.org/D28348 Files: lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/gmalloc.c Index: test/A

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-08 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 83587. xiangzhai added a comment. Hi Anna, Thanks for your review! I use: svn diff --diff-cmd=diff -x -U99 lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/gmalloc.c > Glib-MallocChecker.patch to generate the patch, please check is it

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-06 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment. Phabricator still says that context is not available. Please, pass -U when generating the patch. Thanks! Anna Comment at: test/Analysis/gmalloc.c:1 +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.Ca

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-05 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 83339. xiangzhai added a comment. Hi Anna, Thanks for your review! I resubmit the patch with context, please check is it correct, thanks a lot! And I add testcase: test/Analysis/gmalloc.c Repository: rL LLVM https://reviews.llvm.org/D28348 Files: l