[llvm-commits] [llvm] r76181 - /llvm/trunk/lib/Support/TargetRegistry.cpp

Daniel Dunbar daniel at zuster.org
Fri Jul 17 08:51:17 PDT 2009


Author: ddunbar
Date: Fri Jul 17 10:50:49 2009
New Revision: 76181

URL: http://llvm.org/viewvc/llvm-project?rev=76181&view=rev
Log:
Provide slightly more refined error message when trying to lookup a target, and
none are registered.

Modified:
    llvm/trunk/lib/Support/TargetRegistry.cpp

Modified: llvm/trunk/lib/Support/TargetRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetRegistry.cpp?rev=76181&r1=76180&r2=76181&view=diff

==============================================================================
--- llvm/trunk/lib/Support/TargetRegistry.cpp (original)
+++ llvm/trunk/lib/Support/TargetRegistry.cpp Fri Jul 17 10:50:49 2009
@@ -21,6 +21,11 @@
 const Target *
 TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT,
                                                 std::string &Error) {
+  // Provide special warning when no targets are initialized.
+  if (begin() == end()) {
+    Error = "Unable to find target for this triple (no targets are registered)";
+    return 0;
+  }
   const Target *Best = 0, *EquallyBest = 0;
   unsigned BestQuality = 0;
   for (iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -35,7 +40,7 @@
   }
 
   if (!Best) {
-    Error = "No available targets are compatible with this module";
+    Error = "No available targets are compatible with this triple";
     return 0;
   }
 
@@ -53,6 +58,12 @@
 const Target *
 TargetRegistry::getClosestStaticTargetForModule(const Module &M,
                                                 std::string &Error) {
+  // Provide special warning when no targets are initialized.
+  if (begin() == end()) {
+    Error = "Unable to find target for this module (no targets are registered)";
+    return 0;
+  }
+
   const Target *Best = 0, *EquallyBest = 0;
   unsigned BestQuality = 0;
   for (iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -84,6 +95,12 @@
 
 const Target *
 TargetRegistry::getClosestTargetForJIT(std::string &Error) {
+  // Provide special warning when no targets are initialized.
+  if (begin() == end()) {
+    Error = "No JIT is available for this host (no targets are registered)";
+    return 0;
+  }
+
   const Target *Best = 0, *EquallyBest = 0;
   unsigned BestQuality = 0;
   for (iterator it = begin(), ie = end(); it != ie; ++it) {





More information about the llvm-commits mailing list