Implement a proper function list in module, which auto-maintain the parent
pointer, and ensure that functions are deleted when the module is destroyed.

This exposed the fact that MLFunction had no dtor, and that the dtor in
CFGFunction was broken with cyclic references.  Fix both of these problems.

PiperOrigin-RevId: 206051666
diff --git a/lib/Parser/Parser.cpp b/lib/Parser/Parser.cpp
index 55fd260..362f868 100644
--- a/lib/Parser/Parser.cpp
+++ b/lib/Parser/Parser.cpp
@@ -917,11 +917,10 @@
 
   StringRef sRef = getTokenSpelling();
   for (auto entry : dimsAndSymbols) {
-    if (entry.first != sRef)
-      continue;
-
-    consumeToken(Token::bare_identifier);
-    return entry.second;
+    if (entry.first == sRef) {
+      consumeToken(Token::bare_identifier);
+      return entry.second;
+    }
   }
 
   return (emitError("use of undeclared identifier"), nullptr);
@@ -1861,7 +1860,7 @@
                            "'");
   }
 
-  getModule()->functionList.push_back(function);
+  getModule()->getFunctions().push_back(function);
 
   return finalizeFunction(function, braceLoc);
 }
@@ -2053,7 +2052,7 @@
       parseToken(Token::r_brace, "expected '}' to end mlfunc"))
     return ParseFailure;
 
-  getModule()->functionList.push_back(function);
+  getModule()->getFunctions().push_back(function);
 
   return finalizeFunction(function, braceLoc);
 }
@@ -2356,7 +2355,7 @@
     return ParseFailure;
 
   // Okay, the external function definition was parsed correctly.
-  getModule()->functionList.push_back(new ExtFunction(name, type));
+  getModule()->getFunctions().push_back(new ExtFunction(name, type));
   return ParseSuccess;
 }