[cfe-commits] r86608 - /cfe/trunk/tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 9 14:45:47 PST 2009
Author: ddunbar
Date: Mon Nov 9 16:45:47 2009
New Revision: 86608
URL: http://llvm.org/viewvc/llvm-project?rev=86608&view=rev
Log:
(llvm up) Convert clang-cc.cpp:GetLanguage to StringSwitch.
Modified:
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86608&r1=86607&r2=86608&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon Nov 9 16:45:47 2009
@@ -440,32 +440,21 @@
if (BaseLang != langkind_unspecified)
return BaseLang;
- llvm::StringRef Ext = Filename.rsplit('.').second;
- if (Ext == "ast")
- return langkind_ast;
- else if (Ext == "c")
- return langkind_c;
- else if (Ext == "S" || Ext == "s")
- return langkind_asm_cpp;
- else if (Ext == "i")
- return langkind_c_cpp;
- else if (Ext == "ii")
- return langkind_cxx_cpp;
- else if (Ext == "m")
- return langkind_objc;
- else if (Ext == "mi")
- return langkind_objc_cpp;
- else if (Ext == "mm" || Ext == "M")
- return langkind_objcxx;
- else if (Ext == "mii")
- return langkind_objcxx_cpp;
- else if (Ext == "C" || Ext == "cc" || Ext == "cpp" || Ext == "CPP" ||
- Ext == "c++" || Ext == "cp" || Ext == "cxx")
- return langkind_cxx;
- else if (Ext == "cl")
- return langkind_ocl;
- else
- return langkind_c;
+ return llvm::StringSwitch<LangKind>(Filename.rsplit('.').second)
+ .Case("ast", langkind_ast)
+ .Case("c", langkind_c)
+ .Cases("S", "s", langkind_asm_cpp)
+ .Case("i", langkind_c_cpp)
+ .Case("ii", langkind_cxx_cpp)
+ .Case("m", langkind_objc)
+ .Case("mi", langkind_objc_cpp)
+ .Cases("mm", "M", langkind_objcxx)
+ .Case("mii", langkind_objcxx_cpp)
+ .Case("C", langkind_cxx)
+ .Cases("C", "cc", "cp", langkind_cxx)
+ .Cases("cpp", "CPP", "c++", "cxx", langkind_cxx)
+ .Case("cl", langkind_ocl)
+ .Default(langkind_c);
}
More information about the cfe-commits
mailing list