Teach -Wuninitialized to not warn about variables declared in C++ catch statements.

llvm-svn: 129102
This commit is contained in:
Ted Kremenek 2011-04-07 20:02:56 +00:00
parent 27f3330132
commit 97c393807b
2 changed files with 15 additions and 0 deletions

View File

@ -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();

View File

@ -78,3 +78,17 @@ void PR9625() {
(void)static_cast<float>(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
}
}