diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-12 08:55:43 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-12 08:55:43 +0000 |
commit | 4ad4b3ebbe5769143389dccfcfadb666a4ba5940 (patch) | |
tree | 3dcf3c1c899f8d125125becd9a8ad0f5096ba22c /tools/driver | |
parent | e7fffa14dc50091200b778a747acad15a254626c (diff) |
Driver: Use standard Diagnostic interface for diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver')
-rw-r--r-- | tools/driver/Makefile | 9 | ||||
-rw-r--r-- | tools/driver/driver.cpp | 18 |
2 files changed, 23 insertions, 4 deletions
diff --git a/tools/driver/Makefile b/tools/driver/Makefile index 60d89204fd..ca2253a9b0 100644 --- a/tools/driver/Makefile +++ b/tools/driver/Makefile @@ -12,8 +12,13 @@ TOOLNAME = clang-driver CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include CXXFLAGS = -fno-rtti -LINK_COMPONENTS := system support -USEDLIBS = clangDriver.a +# FIXME: It is unfortunate we need to pull in the bitcode reader and +# writer just to get the serializer stuff used by clangBasic. +LINK_COMPONENTS := system support bitreader bitwriter + +# FIXME: We shouldn't need clangLex.a here; we do because the +# TextDiagnosticPrinter is pulling it in. :( +USEDLIBS = clangDriver.a clangFrontend.a clangLex.a clangBasic.a # This tool has no plugins, optimize startup time. TOOL_NO_EXPORTS = 1 diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index b9e94b2813..645a3ff11a 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -17,15 +17,24 @@ #include "clang/Driver/Option.h" #include "clang/Driver/Options.h" +#include "clang/Frontend/TextDiagnosticPrinter.h" + #include "llvm/ADT/OwningPtr.h" #include "llvm/Config/config.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" #include "llvm/System/Signals.h" +using namespace clang; using namespace clang::driver; int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(); + llvm::OwningPtr<DiagnosticClient> + DiagClient(new TextDiagnosticPrinter(llvm::errs())); + + Diagnostic Diags(DiagClient.get()); + // FIXME: We should use GetMainExecutable here, probably, but we may // want to handle symbolic links slightly differently. The problem // is that the path derived from this will influence search paths. @@ -35,9 +44,14 @@ int main(int argc, const char **argv) { // compiled on. llvm::OwningPtr<Driver> TheDriver(new Driver(Path.getBasename().c_str(), Path.getDirname().c_str(), - LLVM_HOSTTRIPLE)); - + LLVM_HOSTTRIPLE, + Diags)); + llvm::OwningPtr<Compilation> C(TheDriver->BuildCompilation(argc, argv)); + // If there were errors building the compilation, quit now. + if (Diags.getNumErrors()) + return 1; + return C->Execute(); } |