refactor for-loop as range-loop before making changes.

Differential Revision: http://reviews.llvm.org/D4176

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212262 91177308-0d34-0410-b5e6-96231b3b80d8
Move the calling of emitTargetMD() later.

Summary:
Because a global created by GetOrCreateLLVMGlobal() is not finalised until later viz:
  extern char a[];
  char f(){ return a[5];}
  char a[10];

Change MangledDeclNames to use a MapVector rather than a DenseMap so that the
Metadata is output in order of original declaration, so to make deterministic
and improve human readablity.

Differential Revision: http://reviews.llvm.org/D4176

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