dont call iterator::end() on every cycle and dont read already-deleted memory

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61015 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp
index 9535965..044acd7 100644
--- a/lib/AST/DeclarationName.cpp
+++ b/lib/AST/DeclarationName.cpp
@@ -261,10 +261,11 @@
 DeclarationNameTable::~DeclarationNameTable() {
   llvm::FoldingSet<CXXSpecialName> *set =
     static_cast<llvm::FoldingSet<CXXSpecialName>*>(CXXSpecialNamesImpl);
-  llvm::FoldingSetIterator<CXXSpecialName> it = set->begin();
+  llvm::FoldingSetIterator<CXXSpecialName> I = set->begin(), E = set->end();
 
-  while (it != set->end()) {
-    delete &*it++;
+  while (I != E) {
+    CXXSpecialName *n = &*I++;
+    delete n;
   }
 
   delete set;