[cfe-commits] r162156 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/exceptions.mm

Anna Zaks ganna at apple.com
Fri Aug 17 19:15:00 PDT 2012


On Aug 17, 2012, at 5:30 PM, Jordan Rose wrote:

> Author: jrose
> Date: Fri Aug 17 19:30:20 2012
> New Revision: 162156
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=162156&view=rev
> Log:
> [analyzer] Treat @throw as a sink (stop processing).
> 
> The CFG approximates @throw as a return statement, but that's not good
> enough in inlined functions. Moreover, since Objective-C exceptions are
> usually considered fatal, we should be suppressing leak warnings like we
> do for calls to noreturn functions (like abort()).
> 
> The comments indicate that we were probably intending to do this all along;
> it may have been inadvertantly changed during a refactor at one point.
> 
> Added:
>    cfe/trunk/test/Analysis/exceptions.mm
> Modified:
>    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
> 
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=162156&r1=162155&r2=162156&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Aug 17 19:30:20 2012
> @@ -889,7 +889,7 @@
>     case Stmt::ObjCAtThrowStmtClass: {
>       // FIXME: This is not complete.  We basically treat @throw as
>       // an abort.
> -      Bldr.generateNode(S, Pred, Pred->getState());
> +      Bldr.generateNode(S, Pred, Pred->getState(), /*IsSink=*/true);
Please remove the C style comment.
You can mention that we are generating a sink in a comment or better yet add another API to the node builder spelling out what we do:
"Bldr.generateSink"

Anna.
>       break;
>     }
> 
> 
> Added: cfe/trunk/test/Analysis/exceptions.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exceptions.mm?rev=162156&view=auto
> ==============================================================================
> --- cfe/trunk/test/Analysis/exceptions.mm (added)
> +++ cfe/trunk/test/Analysis/exceptions.mm Fri Aug 17 19:30:20 2012
> @@ -0,0 +1,23 @@
> +// RUN: %clang_cc1 -analyze -fexceptions -fobjc-exceptions -fcxx-exceptions -analyzer-ipa=inlining -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s
> +
> +void clang_analyzer_checkInlined(bool);
> +
> +typedef typeof(sizeof(int)) size_t;
> +void *malloc(size_t);
> +void free(void *);
> +
> +
> +id getException();
> +void inlinedObjC() {
> +  clang_analyzer_checkInlined(true); // expected-warning{{TRUE}}
> +  @throw getException();
> +}
> +
> +int testObjC() {
> +  int a; // uninitialized
> +  void *mem = malloc(4); // no-warning (ObjC exceptions are usually fatal)
> +  inlinedObjC();
> +  free(mem);
> +  return a; // no-warning
> +}
> +
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list