Further cleanup to Driver mode code, as suggested by dblaikie [NFC]
authorErich Keane <erich.keane@intel.com>
Mon, 12 Feb 2018 17:47:01 +0000 (17:47 +0000)
committerErich Keane <erich.keane@intel.com>
Mon, 12 Feb 2018 17:47:01 +0000 (17:47 +0000)
llvm-svn: 324915

clang/lib/Driver/Driver.cpp

index bbfdaef..88412e3 100644 (file)
@@ -148,15 +148,13 @@ void Driver::setDriverModeFromOption(StringRef Opt) {
     return;
   StringRef Value = Opt.drop_front(OptName.size());
 
-  auto M = llvm::StringSwitch<llvm::Optional<DriverMode>>(Value)
-                           .Case("gcc", GCCMode)
-                           .Case("g++", GXXMode)
-                           .Case("cpp", CPPMode)
-                           .Case("cl", CLMode)
-                           .Default(None);
-
-  if (M)
-    Mode = M.getValue();
+  if (auto M = llvm::StringSwitch<llvm::Optional<DriverMode>>(Value)
+                   .Case("gcc", GCCMode)
+                   .Case("g++", GXXMode)
+                   .Case("cpp", CPPMode)
+                   .Case("cl", CLMode)
+                   .Default(None))
+    Mode = *M;
   else
     Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
 }