[cfe-commits] r167352 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp lib/StaticAnalyzer/Core/RegionStore.cpp lib/StaticAnalyzer/Core/SymbolManager.cpp test/Analysis/simple-stream-checks.c
Jordan Rose
jordan_rose at apple.com
Fri Nov 2 20:49:26 PDT 2012
On Nov 2, 2012, at 19:54 , Anna Zaks <ganna at apple.com> wrote:
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp?rev=167352&r1=167351&r2=167352&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp Fri Nov 2 21:54:20 2012
> @@ -510,6 +510,9 @@
>
> bool
> SymbolReaper::isLive(const Stmt *ExprVal, const LocationContext *ELCtx) const {
> + if (LCtx == 0)
> + return false;
> +
> if (LCtx != ELCtx) {
> // If the reaper's location context is a parent of the expression's
> // location context, then the expression value is now "out of scope".
> @@ -517,6 +520,7 @@
> return false;
> return true;
> }
> +
> // If no statement is provided, everything is this and parent contexts is live.
> if (!Loc)
> return true;
> @@ -526,6 +530,12 @@
>
> bool SymbolReaper::isLive(const VarRegion *VR, bool includeStoreBindings) const{
> const StackFrameContext *VarContext = VR->getStackFrame();
> +
> + if (!VarContext)
> + return true;
> +
> + if (!LCtx)
> + return false;
This might have interesting repercussions for blocks. I'm not sure. I can try to come up with a test case.
> const StackFrameContext *CurrentContext = LCtx->getCurrentStackFrame();
>
> if (VarContext == CurrentContext) {
> @@ -557,7 +567,7 @@
> return false;
> }
>
> - return !VarContext || VarContext->isParentOf(CurrentContext);
> + return VarContext->isParentOf(CurrentContext);
> }
>
> SymbolVisitor::~SymbolVisitor() {}
>
> Modified: cfe/trunk/test/Analysis/simple-stream-checks.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/simple-stream-checks.c?rev=167352&r1=167351&r2=167352&view=diff
> ==============================================================================
> --- cfe/trunk/test/Analysis/simple-stream-checks.c (original)
> +++ cfe/trunk/test/Analysis/simple-stream-checks.c Fri Nov 2 21:54:20 2012
> @@ -49,3 +49,17 @@
> fclose(F);
> int x = 0; // no warning
> }
> +
> +void leakOnEnfOfPath1(int *Data) {
> + FILE *F = fopen("myfile.txt", "w");// expected-warning {{Opened file is never closed; potential resource leak}}
> +}
> +
> +void leakOnEnfOfPath2(int *Data) {
> + FILE *F = fopen("myfile.txt", "w");
> + return; // expected-warning {{Opened file is never closed; potential resource leak}}
> +}
> +
> +FILE *leakOnEnfOfPath3(int *Data) {
> + FILE *F = fopen("myfile.txt", "w");
> + return F;
> +}
>
>
> _______________________________________________
> 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