diff options
Diffstat (limited to 'tools/driver')
-rw-r--r-- | tools/driver/CMakeLists.txt | 40 | ||||
-rw-r--r-- | tools/driver/cc1_main.cpp | 4 | ||||
-rw-r--r-- | tools/driver/cc1as_main.cpp | 4 | ||||
-rw-r--r-- | tools/driver/driver.cpp | 16 |
4 files changed, 39 insertions, 25 deletions
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index ae49ac1..71d7766 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -1,4 +1,22 @@ -set( LLVM_USED_LIBS +set( LLVM_LINK_COMPONENTS + ${LLVM_TARGETS_TO_BUILD} + asmparser + bitreader + bitwriter + codegen + instrumentation + ipo + linker + selectiondag + ) + +add_clang_executable(clang + driver.cpp + cc1_main.cpp + cc1as_main.cpp + ) + +target_link_libraries(clang clangFrontendTool clangAST clangAnalysis @@ -19,26 +37,10 @@ set( LLVM_USED_LIBS clangStaticAnalyzerCore ) -set( LLVM_LINK_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - asmparser - bitreader - bitwriter - codegen - instrumentation - ipo - linker - selectiondag - ) - -add_clang_executable(clang - driver.cpp - cc1_main.cpp - cc1as_main.cpp - ) - set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION}) +add_dependencies(clang clang-headers) + if(UNIX) set(CLANGXX_LINK_OR_COPY create_symlink) # Create a relative symlink diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index a211090..f8e8a6b 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -15,7 +15,7 @@ #include "clang/Driver/Arg.h" #include "clang/Driver/ArgList.h" -#include "clang/Driver/CC1Options.h" +#include "clang/Driver/Options.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/OptTable.h" #include "clang/Frontend/CompilerInstance.h" @@ -58,7 +58,7 @@ static int cc1_test(DiagnosticsEngine &Diags, llvm::errs() << "\n"; // Parse the arguments. - OptTable *Opts = createCC1OptTable(); + OptTable *Opts = createDriverOptTable(); unsigned MissingArgIndex, MissingArgCount; InputArgList *Args = Opts->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount); diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index 508d6da..7dd54bd 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -328,7 +328,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, MCCodeEmitter *CE = 0; MCAsmBackend *MAB = 0; if (Opts.ShowEncoding) { - CE = TheTarget->createMCCodeEmitter(*MCII, *STI, Ctx); + CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); MAB = TheTarget->createMCAsmBackend(Opts.Triple); } Str.reset(TheTarget->createAsmStreamer(Ctx, *Out, /*asmverbose*/true, @@ -342,7 +342,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, } else { assert(Opts.OutputType == AssemblerInvocation::FT_Obj && "Invalid file type!"); - MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *STI, Ctx); + MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); MCAsmBackend *MAB = TheTarget->createMCAsmBackend(Opts.Triple); Str.reset(TheTarget->createMCObjectStreamer(Opts.Triple, Ctx, *MAB, *Out, CE, Opts.RelaxAll, diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 8c05fff..12a9329 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Driver/ArgList.h" -#include "clang/Driver/CC1Options.h" +#include "clang/Driver/Options.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" #include "clang/Driver/Option.h" @@ -378,7 +378,7 @@ int main(int argc_, const char **argv_) { DiagnosticOptions DiagOpts; { // Note that ParseDiagnosticArgs() uses the cc1 option table. - OwningPtr<OptTable> CC1Opts(createCC1OptTable()); + OwningPtr<OptTable> CC1Opts(createDriverOptTable()); unsigned MissingArgIndex, MissingArgCount; OwningPtr<InputArgList> Args(CC1Opts->ParseArgs(argv.begin()+1, argv.end(), MissingArgIndex, MissingArgCount)); @@ -475,6 +475,10 @@ int main(int argc_, const char **argv_) { if (C.get()) Res = TheDriver.ExecuteCompilation(*C, FailingCommand); + // Force a crash to test the diagnostics. + if(::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) + Res = -1; + // If result status is < 0, then the driver command signalled an error. // In this case, generate additional diagnostic information if possible. if (Res < 0) @@ -486,5 +490,13 @@ int main(int argc_, const char **argv_) { llvm::llvm_shutdown(); +#ifdef _WIN32 + // Exit status should not be negative on Win32, unless abnormal termination. + // Once abnormal termiation was caught, negative status should not be + // propagated. + if (Res < 0) + Res = 1; +#endif + return Res; } |