[cfe-commits] r82104 - /cfe/trunk/tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Wed Sep 16 17:47:46 PDT 2009


Author: ddunbar
Date: Wed Sep 16 19:47:46 2009
New Revision: 82104

URL: http://llvm.org/viewvc/llvm-project?rev=82104&view=rev
Log:
Simplify.

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=82104&r1=82103&r2=82104&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Sep 16 19:47:46 2009
@@ -397,18 +397,11 @@
 PThread("pthread", llvm::cl::desc("Support POSIX threads in generated code"),
          llvm::cl::init(false));
 
-static LangKind GetLanguage(const std::string &Filename) {
+static LangKind GetLanguage(llvm::StringRef Filename) {
   if (BaseLang != langkind_unspecified)
     return BaseLang;
 
-  std::string::size_type DotPos = Filename.rfind('.');
-
-  if (DotPos == std::string::npos) {
-    BaseLang = langkind_c;  // Default to C if no extension.
-    return langkind_c;
-  }
-
-  std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
+  llvm::StringRef Ext = Filename.rsplit('.').second;
   if (Ext == "c")
     return langkind_c;
   else if (Ext == "S" || Ext == "s")





More information about the cfe-commits mailing list