Eliminate obvious use-after-free. Fixes PR12433 / <rdar://problem/11168333>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153982 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 9436bfb..840fa13 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -3898,9 +3898,9 @@
     ExceptionSpecificationType EST =
         static_cast<ExceptionSpecificationType>(Record[Idx++]);
     EPI.ExceptionSpecType = EST;
+    SmallVector<QualType, 2> Exceptions;
     if (EST == EST_Dynamic) {
       EPI.NumExceptions = Record[Idx++];
-      SmallVector<QualType, 2> Exceptions;
       for (unsigned I = 0; I != EPI.NumExceptions; ++I)
         Exceptions.push_back(readType(*Loc.F, Record, Idx));
       EPI.Exceptions = Exceptions.data();
diff --git a/test/PCH/cxx-functions.cpp b/test/PCH/cxx-functions.cpp
new file mode 100644
index 0000000..74df01a
--- /dev/null
+++ b/test/PCH/cxx-functions.cpp
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-functions.h -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-functions.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+
+void test_foo() {
+  foo();
+}
diff --git a/test/PCH/cxx-functions.h b/test/PCH/cxx-functions.h
new file mode 100644
index 0000000..8aa4986
--- /dev/null
+++ b/test/PCH/cxx-functions.h
@@ -0,0 +1 @@
+void foo() throw( int, short, char, float, double );