llvmc: make -x work with unknown suffixes.
authorMikhail Glushenkov <foldr@codedgers.com>
Wed, 15 Sep 2010 15:20:41 +0000 (15:20 +0000)
committerMikhail Glushenkov <foldr@codedgers.com>
Wed, 15 Sep 2010 15:20:41 +0000 (15:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113972 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CompilerDriver/CompilationGraph.cpp
test/LLVMC/C++/dg.exp
test/LLVMC/C++/unknown_suffix.unk [new file with mode: 0644]

index d0c0e15bcdb7ba626ffa8bc796e9600deeb0e64c..0aecfa6a9dd11cd7bb525dd33ffea1376af5c7de 100644 (file)
@@ -218,10 +218,11 @@ FindToolChain(const sys::Path& In, const std::string* ForceLanguage,
               InputLanguagesSet& InLangs, const LanguageMap& LangMap) const {
 
   // Determine the input language.
-  const std::string* InLang = LangMap.GetLanguage(In);
+  const std::string* InLang = (ForceLanguage ? ForceLanguage
+                               : LangMap.GetLanguage(In));
   if (InLang == 0)
     return 0;
-  const std::string& InLanguage = (ForceLanguage ? *ForceLanguage : *InLang);
+  const std::string& InLanguage = *InLang;
 
   // Add the current input language to the input language set.
   InLangs.insert(InLanguage);
index fc852e30acf8f998b04cec380bb303b925e700f1..209345540c11f9cec663e3eff8a668bf650666fc 100644 (file)
@@ -1,5 +1,5 @@
 load_lib llvm.exp
 
 if [ llvm_gcc_supports c++ ] then {
-  RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
+  RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{unk,ll,c,cpp}]]
 }
diff --git a/test/LLVMC/C++/unknown_suffix.unk b/test/LLVMC/C++/unknown_suffix.unk
new file mode 100644 (file)
index 0000000..bf4aea2
--- /dev/null
@@ -0,0 +1,9 @@
+// Test that the -x option works for files with unknown suffixes.
+// RUN: llvmc -x c++ %s -o %t
+// RUN: %abs_tmp | grep hello
+// XFAIL: vg
+#include <iostream>
+
+int main() {
+    std::cout << "hello" << '\n';
+}