From: Ted Kremenek Date: Thu, 7 Apr 2011 20:02:56 +0000 (+0000) Subject: Teach -Wuninitialized to not warn about variables declared in C++ catch statements. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a21612f95792c1ea8b4362f0861f0c724c39388e;p=clang Teach -Wuninitialized to not warn about variables declared in C++ catch statements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129102 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 062857d86e..d2eaff29ac 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -27,6 +27,7 @@ using namespace clang; static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) { if (vd->isLocalVarDecl() && !vd->hasGlobalStorage() && + !vd->isExceptionVariable() && vd->getDeclContext() == dc) { QualType ty = vd->getType(); return ty->isScalarType() || ty->isVectorType(); diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp index 6fa59fe2a1..777734c825 100644 --- a/test/SemaCXX/uninit-variables.cpp +++ b/test/SemaCXX/uninit-variables.cpp @@ -78,3 +78,17 @@ void PR9625() { (void)static_cast(x); // no-warning } } + +// Don't warn about variables declared in "catch" +void RDar9251392_bar(const char *msg); + +void RDar9251392() { + try { + throw "hi"; + } + catch (const char* msg) { + RDar9251392_bar(msg); // no-warning + } +} + +