f42e17f641157a75c2a76e2352bc5387b29155c6
[oota-llvm.git] / tools / llvmc / example / mcc16 / driver / Main.cpp
1 //===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Usually this file just includes CompilerDriver/Main.inc, but here we apply
11 //  some trickery to make the built-in '-save-temps' option hidden and enable
12 //  '--temp-dir' by default.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include "llvm/CompilerDriver/BuiltinOptions.h"
17 #include "llvm/CompilerDriver/ForceLinkage.h"
18 #include "llvm/System/Path.h"
19
20 namespace llvmc {
21   int Main(int argc, char** argv);
22 }
23
24 int main(int argc, char** argv) {
25
26   // HACK
27   SaveTemps.setHiddenFlag(llvm::cl::Hidden);
28   TempDirname = "tmp-objs";
29
30   // Remove the temp dir if already exists.
31   llvm::sys::Path tempDir;
32   tempDir = TempDirname;
33   tempDir.eraseFromDisk(true);
34
35   llvmc::ForceLinkage();
36   return llvmc::Main(argc, argv);
37 }