[ARM] Follow-up to fix crash "-target arm -mcpu=generic", without "-march="

Fix of dangling StringRef after temporary std::string is destroyed

Follow-up to: http://reviews.llvm.org/rL248370

Reviewers: alexfh

Subscribers: cfe-commits
llvm-svn: 248479
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index e8a0852..4061598 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -6164,13 +6164,13 @@
 StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
                                        const llvm::Triple &Triple) {
   unsigned ArchKind;
-  Arch = tools::arm::getARMArch(Arch, Triple);
   if (CPU == "generic") {
-    ArchKind = llvm::ARM::parseArch(Arch);
+    StringRef ARMArch = tools::arm::getARMArch(Arch, Triple);
+    ArchKind = llvm::ARM::parseArch(ARMArch);
     if (ArchKind == llvm::ARM::AK_INVALID)
       // In case of generic Arch, i.e. "arm",
       // extract arch from default cpu of the Triple
-      ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(Arch));
+      ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(ARMArch));
   } else {
     ArchKind = llvm::ARM::parseCPUArch(CPU);
   }