]> granicus.if.org Git - clang/commitdiff
Simplify.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 17 Sep 2009 00:47:46 +0000 (00:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 17 Sep 2009 00:47:46 +0000 (00:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82104 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-cc/clang-cc.cpp

index f3563e6ab2aa1efd586a83f5e50755c8164cf1c8..1e1117a1aa3aea229811d96119f8c293b97fa476 100644 (file)
@@ -397,18 +397,11 @@ static llvm::cl::opt<bool>
 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")