]> granicus.if.org Git - clang/commitdiff
Teach -Wuninitialized to not warn about variables declared in C++ catch statements.
authorTed Kremenek <kremenek@apple.com>
Thu, 7 Apr 2011 20:02:56 +0000 (20:02 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 7 Apr 2011 20:02:56 +0000 (20:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129102 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UninitializedValues.cpp
test/SemaCXX/uninit-variables.cpp

index 062857d86eedde61e6e33f20b06fc5f4a054b273..d2eaff29ac7ca3f7094eac42a7f6d46180b40d97 100644 (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();
index 6fa59fe2a15e544f7211fbccce4b34fdbc85ba28..777734c82598c625423cdd5b565486181ee43f43 100644 (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
+  }
+}
+
+