Use unique_ptr to remove an explicit delete. Change return type to pass the unique_ptr to caller.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224003 91177308-0d34-0410-b5e6-96231b3b80d8
Just use the Module unique_ptr object directly in many places instead of separate pointer that's kept in sync with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224004 91177308-0d34-0410-b5e6-96231b3b80d8
Use range-based for loops. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224005 91177308-0d34-0410-b5e6-96231b3b80d8