From c1b9c07504bdb033fb7b44a03d5b6f4b01deb642 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Wed, 7 Feb 2018 00:37:19 +0000 Subject: [PATCH] [NFC] Change odd cast-through-unknown behavior to an Optional This bit of code in the driver uses '~0U' as a sentinel value. The result is an odd mishmash of casts just to work. This replaces it with an optional, which is a little less crazy looking. --ehis line, and those below, will be ignored-- M lib/Driver/Driver.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324433 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Driver.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 9ae5a60fa6..bbfdaefaf3 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -148,15 +148,15 @@ void Driver::setDriverModeFromOption(StringRef Opt) { return; StringRef Value = Opt.drop_front(OptName.size()); - const unsigned M = llvm::StringSwitch(Value) - .Case("gcc", GCCMode) - .Case("g++", GXXMode) - .Case("cpp", CPPMode) - .Case("cl", CLMode) - .Default(~0U); - - if (M != ~0U) - Mode = static_cast(M); + auto M = llvm::StringSwitch>(Value) + .Case("gcc", GCCMode) + .Case("g++", GXXMode) + .Case("cpp", CPPMode) + .Case("cl", CLMode) + .Default(None); + + if (M) + Mode = M.getValue(); else Diag(diag::err_drv_unsupported_option_argument) << OptName << Value; } -- 2.40.0