mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-22 10:33:23 +00:00
Fix some error messages; Make LLVMC pass through the exit code of a failed tool.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2ce3898e41
commit
a673037097
@ -11,6 +11,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "Error.h"
|
||||||
#include "CompilationGraph.h"
|
#include "CompilationGraph.h"
|
||||||
|
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
@ -90,7 +91,7 @@ const Node& CompilationGraph::getNode(const std::string& ToolName) const {
|
|||||||
const std::string& CompilationGraph::getLanguage(const sys::Path& File) const {
|
const std::string& CompilationGraph::getLanguage(const sys::Path& File) const {
|
||||||
LanguageMap::const_iterator Lang = ExtsToLangs.find(File.getSuffix());
|
LanguageMap::const_iterator Lang = ExtsToLangs.find(File.getSuffix());
|
||||||
if (Lang == ExtsToLangs.end())
|
if (Lang == ExtsToLangs.end())
|
||||||
throw std::runtime_error("Unknown suffix: " + File.getSuffix() + '!');
|
throw std::runtime_error("Unknown suffix: " + File.getSuffix());
|
||||||
return Lang->second;
|
return Lang->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ CompilationGraph::getToolsVector(const std::string& LangName) const
|
|||||||
tools_map_type::const_iterator I = ToolsMap.find(LangName);
|
tools_map_type::const_iterator I = ToolsMap.find(LangName);
|
||||||
if (I == ToolsMap.end())
|
if (I == ToolsMap.end())
|
||||||
throw std::runtime_error("No tool corresponding to the language "
|
throw std::runtime_error("No tool corresponding to the language "
|
||||||
+ LangName + "found!");
|
+ LangName + "found");
|
||||||
return I->second;
|
return I->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +177,8 @@ void CompilationGraph::PassThroughGraph (const sys::Path& InFile,
|
|||||||
Out = MakeTempFile(TempDir, In.getBasename(), CurTool->OutputSuffix());
|
Out = MakeTempFile(TempDir, In.getBasename(), CurTool->OutputSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurTool->GenerateAction(In, Out).Execute() != 0)
|
if (int ret = CurTool->GenerateAction(In, Out).Execute())
|
||||||
throw std::runtime_error("Tool returned error code!");
|
throw error_code(ret);
|
||||||
|
|
||||||
if (Last)
|
if (Last)
|
||||||
return;
|
return;
|
||||||
@ -206,7 +207,7 @@ FindToolChain(const sys::Path& In, const std::string* forceLanguage,
|
|||||||
const tools_vector_type& TV = getToolsVector(InLanguage);
|
const tools_vector_type& TV = getToolsVector(InLanguage);
|
||||||
if (TV.empty())
|
if (TV.empty())
|
||||||
throw std::runtime_error("No toolchain corresponding to language "
|
throw std::runtime_error("No toolchain corresponding to language "
|
||||||
+ InLanguage + " found!");
|
+ InLanguage + " found");
|
||||||
return &getNode(ChooseEdge(TV, InLangs)->ToolName());
|
return &getNode(ChooseEdge(TV, InLangs)->ToolName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,8 +343,8 @@ int CompilationGraph::Build (const sys::Path& TempDir) {
|
|||||||
Out = MakeTempFile(TempDir, "tmp", JT->OutputSuffix());
|
Out = MakeTempFile(TempDir, "tmp", JT->OutputSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JT->GenerateAction(Out).Execute() != 0)
|
if (int ret = JT->GenerateAction(Out).Execute())
|
||||||
throw std::runtime_error("Tool returned error code!");
|
throw error_code(ret);
|
||||||
|
|
||||||
if (!IsLast) {
|
if (!IsLast) {
|
||||||
const Node* NextNode =
|
const Node* NextNode =
|
||||||
@ -397,7 +398,7 @@ void CompilationGraph::writeGraph() {
|
|||||||
O.close();
|
O.close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw std::runtime_error("");
|
throw std::runtime_error("Error opening file for writing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
tools/llvmc2/Error.h
Normal file
33
tools/llvmc2/Error.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//===--- Error.h - The LLVM Compiler Driver ---------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open
|
||||||
|
// Source License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Exception classes for LLVMC.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_TOOLS_LLVMC2_ERROR_H
|
||||||
|
#define LLVM_TOOLS_LLVMC2_ERROR_H
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace llvmc {
|
||||||
|
|
||||||
|
class error_code: public std::runtime_error {
|
||||||
|
int Code_;
|
||||||
|
public:
|
||||||
|
error_code (int c)
|
||||||
|
: std::runtime_error("Tool returned error code"), Code_(c)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int code() const { return Code_; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //LLVM_TOOLS_LLVMC2_ERROR_H
|
@ -15,6 +15,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "CompilationGraph.h"
|
#include "CompilationGraph.h"
|
||||||
|
#include "Error.h"
|
||||||
#include "Tool.h"
|
#include "Tool.h"
|
||||||
|
|
||||||
#include "llvm/System/Path.h"
|
#include "llvm/System/Path.h"
|
||||||
@ -92,6 +93,9 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
return BuildTargets(graph);
|
return BuildTargets(graph);
|
||||||
}
|
}
|
||||||
|
catch(llvmc::error_code& ec) {
|
||||||
|
return ec.code();
|
||||||
|
}
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
std::cerr << ex.what() << '\n';
|
std::cerr << ex.what() << '\n';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user