diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-17 15:50:49 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-17 15:50:49 +0000 |
commit | 50745bf0802f32d796f755b799d6fde688415637 (patch) | |
tree | e75b9b9e28e87495e35650e62b84685399c7de5d /llvm/lib/Support/TargetRegistry.cpp | |
parent | c960b3e80c86ba702d832e8b59a9e0ff4a506916 (diff) | |
download | bcm5719-llvm-50745bf0802f32d796f755b799d6fde688415637.tar.gz bcm5719-llvm-50745bf0802f32d796f755b799d6fde688415637.zip |
Provide slightly more refined error message when trying to lookup a target, and
none are registered.
llvm-svn: 76181
Diffstat (limited to 'llvm/lib/Support/TargetRegistry.cpp')
-rw-r--r-- | llvm/lib/Support/TargetRegistry.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Support/TargetRegistry.cpp b/llvm/lib/Support/TargetRegistry.cpp index bf631feb686..b3446e61092 100644 --- a/llvm/lib/Support/TargetRegistry.cpp +++ b/llvm/lib/Support/TargetRegistry.cpp @@ -21,6 +21,11 @@ TargetRegistry::iterator TargetRegistry::begin() { 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 @@ TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT, } 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 @@ TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT, 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 @@ TargetRegistry::getClosestStaticTargetForModule(const Module &M, 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) { |