aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-29 00:41:01 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-29 00:41:01 +0000
commit55d3f7ae512875a1d6402943c3a619633feb2a18 (patch)
treea6309c6fb13dc8dfaa18db528c18bda38cf85b12 /lib/Driver/Tools.cpp
parentd8ee95fd4fb8fb00ad999dffad5fa1613c68a113 (diff)
[llvm up]
Switch a few ugly switch-on-string-literal constructs to use the new llvm::StringSwitch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r--lib/Driver/Tools.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 357dcb3d90..32ce80d514 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -22,6 +22,7 @@
#include "clang/Driver/Util.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
@@ -1667,23 +1668,18 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
static bool isSourceSuffix(const char *Str) {
// match: 'C', 'CPP', 'c', 'cc', 'cp', 'c++', 'cpp', 'cxx', 'm',
// 'mm'.
- switch (strlen(Str)) {
- default:
- return false;
- case 1:
- return (memcmp(Str, "C", 1) == 0 ||
- memcmp(Str, "c", 1) == 0 ||
- memcmp(Str, "m", 1) == 0);
- case 2:
- return (memcmp(Str, "cc", 2) == 0 ||
- memcmp(Str, "cp", 2) == 0 ||
- memcmp(Str, "mm", 2) == 0);
- case 3:
- return (memcmp(Str, "CPP", 3) == 0 ||
- memcmp(Str, "c++", 3) == 0 ||
- memcmp(Str, "cpp", 3) == 0 ||
- memcmp(Str, "cxx", 3) == 0);
- }
+ return llvm::StringSwitch<bool>(Str)
+ .Case("C", true)
+ .Case("c", true)
+ .Case("m", true)
+ .Case("cc", true)
+ .Case("cp", true)
+ .Case("mm", true)
+ .Case("CPP", true)
+ .Case("c++", true)
+ .Case("cpp", true)
+ .Case("cxx", true)
+ .Default(false);
}
// FIXME: Can we tablegen this?