From: Ted Kremenek Date: Tue, 25 Jan 2011 19:13:42 +0000 (+0000) Subject: Tweak wording of static analyzer diagnostic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=937596fc25bba3ac7519e9ffff3e4fab2c97863e;p=clang Tweak wording of static analyzer diagnostic for a block capturing the value of an uninitialized variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124212 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp index 57e698bb7c..1aaaa68ca6 100644 --- a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp @@ -82,14 +82,14 @@ UndefCapturedBlockVarChecker::PostVisitBlockExpr(CheckerContext &C, if (state->getSVal(VR).isUndef()) if (ExplodedNode *N = C.generateSink()) { if (!BT) - BT = new BuiltinBug("Captured block variable is uninitialized"); + BT = new BuiltinBug("uninitialized variable captured by block"); // Generate a bug report. llvm::SmallString<128> buf; llvm::raw_svector_ostream os(buf); - os << "Variable '" << VD->getName() << "' is captured by block with " - "a garbage value"; + os << "Variable '" << VD->getName() + << "' is uninitialized when captured by block"; EnhancedBugReport *R = new EnhancedBugReport(*BT, os.str(), N); if (const Expr *Ex = FindBlockDeclRefExpr(BE->getBody(), VD)) diff --git a/test/Analysis/blocks.m b/test/Analysis/blocks.m index b05b198c54..e18d7cfb7b 100644 --- a/test/Analysis/blocks.m +++ b/test/Analysis/blocks.m @@ -73,7 +73,7 @@ void test1(NSString *format, ...) { void test2() { static int y = 0; int x; - ^{ y = x + 1; }(); // expected-warning{{Variable 'x' is captured by block with a garbage value}} + ^{ y = x + 1; }(); // expected-warning{{Variable 'x' is uninitialized when captured by block}} } void test2_b() { @@ -86,5 +86,5 @@ void test2_b() { void test2_c() { typedef void (^myblock)(void); - myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is captured by block with a garbage value}} + myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is uninitialized when captured by block}} } \ No newline at end of file