Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 1 | //===-- driver.cpp - Clang GCC-Compatible Driver --------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Daniel Dunbar | 1eb4e64 | 2009-03-03 05:55:11 +0000 | [diff] [blame] | 10 | // This is the entry point to the clang driver; it is a thin wrapper |
| 11 | // for functionality in the Driver clang library. |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Driver/Compilation.h" |
| 16 | #include "clang/Driver/Driver.h" |
Daniel Dunbar | 2c6f6f3 | 2009-03-04 08:33:23 +0000 | [diff] [blame] | 17 | #include "clang/Driver/Option.h" |
Daniel Dunbar | af20afb | 2010-02-25 03:23:43 +0000 | [diff] [blame] | 18 | #include "clang/Frontend/DiagnosticOptions.h" |
| 19 | #include "clang/Frontend/TextDiagnosticPrinter.h" |
Daniel Dunbar | 2c6f6f3 | 2009-03-04 08:33:23 +0000 | [diff] [blame] | 20 | |
Daniel Dunbar | 510d732 | 2009-03-18 02:11:26 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallString.h" |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/OwningPtr.h" |
Daniel Dunbar | dd98e2c | 2009-03-10 23:41:59 +0000 | [diff] [blame] | 23 | #include "llvm/Config/config.h" |
Daniel Dunbar | 8f25c79 | 2009-03-18 01:38:48 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ManagedStatic.h" |
| 25 | #include "llvm/Support/PrettyStackTrace.h" |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 26 | #include "llvm/Support/Regex.h" |
Chris Lattner | 30bc7e8 | 2010-03-30 05:39:52 +0000 | [diff] [blame] | 27 | #include "llvm/Support/Timer.h" |
Daniel Dunbar | 4ad4b3e | 2009-03-12 08:55:43 +0000 | [diff] [blame] | 28 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | af07f93 | 2009-03-31 17:35:15 +0000 | [diff] [blame] | 29 | #include "llvm/System/Host.h" |
Daniel Dunbar | 365c02f | 2009-03-10 20:52:46 +0000 | [diff] [blame] | 30 | #include "llvm/System/Path.h" |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 31 | #include "llvm/System/Signals.h" |
Daniel Dunbar | 4ad4b3e | 2009-03-12 08:55:43 +0000 | [diff] [blame] | 32 | using namespace clang; |
Daniel Dunbar | 1b3bb6e | 2009-03-04 20:49:20 +0000 | [diff] [blame] | 33 | using namespace clang::driver; |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 34 | |
Rafael Espindola | 0f4c59c | 2009-12-04 19:31:58 +0000 | [diff] [blame] | 35 | llvm::sys::Path GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) { |
| 36 | if (!CanonicalPrefixes) |
| 37 | return llvm::sys::Path(Argv0); |
| 38 | |
Daniel Dunbar | 734932c | 2009-03-18 20:25:53 +0000 | [diff] [blame] | 39 | // This just needs to be some symbol in the binary; C++ doesn't |
| 40 | // allow taking the address of ::main however. |
| 41 | void *P = (void*) (intptr_t) GetExecutablePath; |
| 42 | return llvm::sys::Path::GetMainExecutable(Argv0, P); |
| 43 | } |
| 44 | |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 45 | static const char *SaveStringInSet(std::set<std::string> &SavedStrings, |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 46 | llvm::StringRef S) { |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 47 | return SavedStrings.insert(S).first->c_str(); |
| 48 | } |
| 49 | |
| 50 | /// ApplyQAOverride - Apply a list of edits to the input argument lists. |
| 51 | /// |
| 52 | /// The input string is a space separate list of edits to perform, |
| 53 | /// they are applied in order to the input argument lists. Edits |
| 54 | /// should be one of the following forms: |
| 55 | /// |
Daniel Dunbar | e3d6023 | 2009-07-16 21:32:51 +0000 | [diff] [blame] | 56 | /// '#': Silence information about the changes to the command line arguments. |
| 57 | /// |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 58 | /// '^': Add FOO as a new argument at the beginning of the command line. |
| 59 | /// |
| 60 | /// '+': Add FOO as a new argument at the end of the command line. |
| 61 | /// |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 62 | /// 's/XXX/YYY/': Substitute the regular expression XXX with YYY in the command |
| 63 | /// line. |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 64 | /// |
| 65 | /// 'xOPTION': Removes all instances of the literal argument OPTION. |
| 66 | /// |
| 67 | /// 'XOPTION': Removes all instances of the literal argument OPTION, |
| 68 | /// and the following argument. |
| 69 | /// |
| 70 | /// 'Ox': Removes all flags matching 'O' or 'O[sz0-9]' and adds 'Ox' |
| 71 | /// at the end of the command line. |
Daniel Dunbar | e3d6023 | 2009-07-16 21:32:51 +0000 | [diff] [blame] | 72 | /// |
| 73 | /// \param OS - The stream to write edit information to. |
| 74 | /// \param Args - The vector of command line arguments. |
| 75 | /// \param Edit - The override command to perform. |
| 76 | /// \param SavedStrings - Set to use for storing string representations. |
Chris Lattner | 30bc7e8 | 2010-03-30 05:39:52 +0000 | [diff] [blame] | 77 | static void ApplyOneQAOverride(llvm::raw_ostream &OS, |
| 78 | std::vector<const char*> &Args, |
| 79 | llvm::StringRef Edit, |
| 80 | std::set<std::string> &SavedStrings) { |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 81 | // This does not need to be efficient. |
| 82 | |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 83 | if (Edit[0] == '^') { |
| 84 | const char *Str = |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 85 | SaveStringInSet(SavedStrings, Edit.substr(1)); |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 86 | OS << "### Adding argument " << Str << " at beginning\n"; |
| 87 | Args.insert(Args.begin() + 1, Str); |
| 88 | } else if (Edit[0] == '+') { |
| 89 | const char *Str = |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 90 | SaveStringInSet(SavedStrings, Edit.substr(1)); |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 91 | OS << "### Adding argument " << Str << " at end\n"; |
| 92 | Args.push_back(Str); |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 93 | } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") && |
| 94 | Edit.slice(2, Edit.size()-1).find('/') != llvm::StringRef::npos) { |
| 95 | llvm::StringRef MatchPattern = Edit.substr(2).split('/').first; |
| 96 | llvm::StringRef ReplPattern = Edit.substr(2).split('/').second; |
| 97 | ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1); |
| 98 | |
| 99 | for (unsigned i = 1, e = Args.size(); i != e; ++i) { |
| 100 | std::string Repl = llvm::Regex(MatchPattern).sub(ReplPattern, Args[i]); |
| 101 | |
| 102 | if (Repl != Args[i]) { |
| 103 | OS << "### Replacing '" << Args[i] << "' with '" << Repl << "'\n"; |
| 104 | Args[i] = SaveStringInSet(SavedStrings, Repl); |
| 105 | } |
| 106 | } |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 107 | } else if (Edit[0] == 'x' || Edit[0] == 'X') { |
| 108 | std::string Option = Edit.substr(1, std::string::npos); |
| 109 | for (unsigned i = 1; i < Args.size();) { |
| 110 | if (Option == Args[i]) { |
| 111 | OS << "### Deleting argument " << Args[i] << '\n'; |
| 112 | Args.erase(Args.begin() + i); |
| 113 | if (Edit[0] == 'X') { |
| 114 | if (i < Args.size()) { |
| 115 | OS << "### Deleting argument " << Args[i] << '\n'; |
| 116 | Args.erase(Args.begin() + i); |
| 117 | } else |
| 118 | OS << "### Invalid X edit, end of command line!\n"; |
| 119 | } |
| 120 | } else |
| 121 | ++i; |
| 122 | } |
| 123 | } else if (Edit[0] == 'O') { |
| 124 | for (unsigned i = 1; i < Args.size();) { |
| 125 | const char *A = Args[i]; |
| 126 | if (A[0] == '-' && A[1] == 'O' && |
| 127 | (A[2] == '\0' || |
| 128 | (A[3] == '\0' && (A[2] == 's' || A[2] == 'z' || |
| 129 | ('0' <= A[2] && A[2] <= '9'))))) { |
| 130 | OS << "### Deleting argument " << Args[i] << '\n'; |
| 131 | Args.erase(Args.begin() + i); |
| 132 | } else |
| 133 | ++i; |
| 134 | } |
| 135 | OS << "### Adding argument " << Edit << " at end\n"; |
Daniel Dunbar | 0de9a7b | 2010-02-17 21:00:34 +0000 | [diff] [blame] | 136 | Args.push_back(SaveStringInSet(SavedStrings, '-' + Edit.str())); |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 137 | } else { |
| 138 | OS << "### Unrecognized edit: " << Edit << "\n"; |
| 139 | } |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /// ApplyQAOverride - Apply a comma separate list of edits to the |
| 143 | /// input argument lists. See ApplyOneQAOverride. |
Chris Lattner | 30bc7e8 | 2010-03-30 05:39:52 +0000 | [diff] [blame] | 144 | static void ApplyQAOverride(std::vector<const char*> &Args, |
| 145 | const char *OverrideStr, |
| 146 | std::set<std::string> &SavedStrings) { |
Daniel Dunbar | e3d6023 | 2009-07-16 21:32:51 +0000 | [diff] [blame] | 147 | llvm::raw_ostream *OS = &llvm::errs(); |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 148 | |
Daniel Dunbar | e3d6023 | 2009-07-16 21:32:51 +0000 | [diff] [blame] | 149 | if (OverrideStr[0] == '#') { |
| 150 | ++OverrideStr; |
| 151 | OS = &llvm::nulls(); |
| 152 | } |
| 153 | |
| 154 | *OS << "### QA_OVERRIDE_GCC3_OPTIONS: " << OverrideStr << "\n"; |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 155 | |
| 156 | // This does not need to be efficient. |
| 157 | |
| 158 | const char *S = OverrideStr; |
| 159 | while (*S) { |
| 160 | const char *End = ::strchr(S, ' '); |
| 161 | if (!End) |
| 162 | End = S + strlen(S); |
| 163 | if (End != S) |
Daniel Dunbar | e3d6023 | 2009-07-16 21:32:51 +0000 | [diff] [blame] | 164 | ApplyOneQAOverride(*OS, Args, std::string(S, End), SavedStrings); |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 165 | S = End; |
| 166 | if (*S != '\0') |
| 167 | ++S; |
| 168 | } |
| 169 | } |
| 170 | |
Daniel Dunbar | c88aa79 | 2009-11-30 07:18:13 +0000 | [diff] [blame] | 171 | extern int cc1_main(const char **ArgBegin, const char **ArgEnd, |
Daniel Dunbar | 545c281 | 2009-11-29 20:58:32 +0000 | [diff] [blame] | 172 | const char *Argv0, void *MainAddr); |
Daniel Dunbar | 41b5b17 | 2010-05-20 17:49:16 +0000 | [diff] [blame] | 173 | extern int cc1as_main(const char **ArgBegin, const char **ArgEnd, |
| 174 | const char *Argv0, void *MainAddr); |
Daniel Dunbar | 217acbf | 2009-11-19 07:37:51 +0000 | [diff] [blame] | 175 | |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 176 | int main(int argc, const char **argv) { |
| 177 | llvm::sys::PrintStackTraceOnErrorSignal(); |
Daniel Dunbar | 8f25c79 | 2009-03-18 01:38:48 +0000 | [diff] [blame] | 178 | llvm::PrettyStackTraceProgram X(argc, argv); |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 179 | |
Daniel Dunbar | 41b5b17 | 2010-05-20 17:49:16 +0000 | [diff] [blame] | 180 | // Handle -cc1 integrated tools. |
| 181 | if (argc > 1 && llvm::StringRef(argv[1]).startswith("-cc1")) { |
| 182 | llvm::StringRef Tool = argv[1] + 4; |
| 183 | |
| 184 | if (Tool == "") |
| 185 | return cc1_main(argv+2, argv+argc, argv[0], |
| 186 | (void*) (intptr_t) GetExecutablePath); |
| 187 | if (Tool == "as") |
| 188 | return cc1as_main(argv+2, argv+argc, argv[0], |
| 189 | (void*) (intptr_t) GetExecutablePath); |
| 190 | |
| 191 | // Reject unknown tools. |
| 192 | llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n"; |
| 193 | return 1; |
| 194 | } |
Daniel Dunbar | c88aa79 | 2009-11-30 07:18:13 +0000 | [diff] [blame] | 195 | |
Rafael Espindola | 0f4c59c | 2009-12-04 19:31:58 +0000 | [diff] [blame] | 196 | bool CanonicalPrefixes = true; |
| 197 | for (int i = 1; i < argc; ++i) { |
| 198 | if (llvm::StringRef(argv[i]) == "-no-canonical-prefixes") { |
| 199 | CanonicalPrefixes = false; |
| 200 | break; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | llvm::sys::Path Path = GetExecutablePath(argv[0], CanonicalPrefixes); |
| 205 | |
Daniel Dunbar | af20afb | 2010-02-25 03:23:43 +0000 | [diff] [blame] | 206 | TextDiagnosticPrinter DiagClient(llvm::errs(), DiagnosticOptions()); |
| 207 | DiagClient.setPrefix(Path.getBasename()); |
Daniel Dunbar | 510d732 | 2009-03-18 02:11:26 +0000 | [diff] [blame] | 208 | |
Daniel Dunbar | 8e6e709 | 2009-05-26 16:15:44 +0000 | [diff] [blame] | 209 | Diagnostic Diags(&DiagClient); |
Daniel Dunbar | 510d732 | 2009-03-18 02:11:26 +0000 | [diff] [blame] | 210 | |
Daniel Dunbar | f44c585 | 2009-09-22 22:31:13 +0000 | [diff] [blame] | 211 | #ifdef CLANG_IS_PRODUCTION |
Kovarththanan Rajaratnam | 240c734 | 2010-03-08 18:33:04 +0000 | [diff] [blame] | 212 | const bool IsProduction = true; |
Daniel Dunbar | 5d93ed3 | 2010-04-01 18:21:41 +0000 | [diff] [blame] | 213 | # ifdef CLANGXX_IS_PRODUCTION |
| 214 | const bool CXXIsProduction = true; |
| 215 | # else |
| 216 | const bool CXXIsProduction = false; |
| 217 | # endif |
Daniel Dunbar | f44c585 | 2009-09-22 22:31:13 +0000 | [diff] [blame] | 218 | #else |
Kovarththanan Rajaratnam | 240c734 | 2010-03-08 18:33:04 +0000 | [diff] [blame] | 219 | const bool IsProduction = false; |
Daniel Dunbar | 5d93ed3 | 2010-04-01 18:21:41 +0000 | [diff] [blame] | 220 | const bool CXXIsProduction = false; |
Daniel Dunbar | f44c585 | 2009-09-22 22:31:13 +0000 | [diff] [blame] | 221 | #endif |
Jeffrey Yasskin | e3fdca2 | 2009-12-08 01:46:24 +0000 | [diff] [blame] | 222 | Driver TheDriver(Path.getBasename(), Path.getDirname(), |
| 223 | llvm::sys::getHostTriple(), |
Daniel Dunbar | 5d93ed3 | 2010-04-01 18:21:41 +0000 | [diff] [blame] | 224 | "a.out", IsProduction, CXXIsProduction, |
| 225 | Diags); |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 226 | |
Daniel Dunbar | 8fa01c8 | 2009-11-10 18:47:41 +0000 | [diff] [blame] | 227 | // Check for ".*++" or ".*++-[^-]*" to determine if we are a C++ |
| 228 | // compiler. This matches things like "c++", "clang++", and "clang++-1.1". |
| 229 | // |
| 230 | // Note that we intentionally want to use argv[0] here, to support "clang++" |
| 231 | // being a symlink. |
Benjamin Kramer | d5dc9f3 | 2009-11-20 11:49:06 +0000 | [diff] [blame] | 232 | // |
| 233 | // We use *argv instead of argv[0] to work around a bogus g++ warning. |
| 234 | std::string ProgName(llvm::sys::Path(*argv).getBasename()); |
Daniel Dunbar | e26bd90 | 2009-11-11 10:10:25 +0000 | [diff] [blame] | 235 | if (llvm::StringRef(ProgName).endswith("++") || |
Daniel Dunbar | 0dea4be | 2009-12-25 20:21:23 +0000 | [diff] [blame] | 236 | llvm::StringRef(ProgName).rsplit('-').first.endswith("++")) { |
Daniel Dunbar | 8fa01c8 | 2009-11-10 18:47:41 +0000 | [diff] [blame] | 237 | TheDriver.CCCIsCXX = true; |
Daniel Dunbar | 0dea4be | 2009-12-25 20:21:23 +0000 | [diff] [blame] | 238 | TheDriver.CCCGenericGCCName = "g++"; |
| 239 | } |
Daniel Dunbar | 8fa01c8 | 2009-11-10 18:47:41 +0000 | [diff] [blame] | 240 | |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 241 | llvm::OwningPtr<Compilation> C; |
| 242 | |
Daniel Dunbar | 4c00fcd | 2010-03-20 08:01:59 +0000 | [diff] [blame] | 243 | // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE. |
| 244 | TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS"); |
| 245 | if (TheDriver.CCPrintOptions) |
| 246 | TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE"); |
| 247 | |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 248 | // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a |
| 249 | // command line behind the scenes. |
Daniel Dunbar | a1e2fd9 | 2009-04-10 18:32:59 +0000 | [diff] [blame] | 250 | std::set<std::string> SavedStrings; |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 251 | if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) { |
| 252 | // FIXME: Driver shouldn't take extra initial argument. |
| 253 | std::vector<const char*> StringPointers(argv, argv + argc); |
| 254 | |
| 255 | ApplyQAOverride(StringPointers, OverrideStr, SavedStrings); |
| 256 | |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 257 | C.reset(TheDriver.BuildCompilation(StringPointers.size(), |
Daniel Dunbar | 0311d47 | 2009-05-26 18:00:25 +0000 | [diff] [blame] | 258 | &StringPointers[0])); |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 259 | } else if (const char *Cur = ::getenv("CCC_ADD_ARGS")) { |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 260 | std::vector<const char*> StringPointers; |
| 261 | |
| 262 | // FIXME: Driver shouldn't take extra initial argument. |
| 263 | StringPointers.push_back(argv[0]); |
| 264 | |
| 265 | for (;;) { |
| 266 | const char *Next = strchr(Cur, ','); |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 267 | |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 268 | if (Next) { |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 269 | StringPointers.push_back(SaveStringInSet(SavedStrings, |
| 270 | std::string(Cur, Next))); |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 271 | Cur = Next + 1; |
| 272 | } else { |
Daniel Dunbar | ec9587d | 2009-04-17 01:54:00 +0000 | [diff] [blame] | 273 | if (*Cur != '\0') |
| 274 | StringPointers.push_back(SaveStringInSet(SavedStrings, Cur)); |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 275 | break; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | StringPointers.insert(StringPointers.end(), argv + 1, argv + argc); |
| 280 | |
Daniel Dunbar | 237a31b | 2009-07-17 18:10:27 +0000 | [diff] [blame] | 281 | C.reset(TheDriver.BuildCompilation(StringPointers.size(), |
Daniel Dunbar | 0311d47 | 2009-05-26 18:00:25 +0000 | [diff] [blame] | 282 | &StringPointers[0])); |
Daniel Dunbar | e5be6da | 2009-04-01 19:08:46 +0000 | [diff] [blame] | 283 | } else |
Daniel Dunbar | 8e6e709 | 2009-05-26 16:15:44 +0000 | [diff] [blame] | 284 | C.reset(TheDriver.BuildCompilation(argc, argv)); |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 285 | |
Daniel Dunbar | af96def | 2009-03-21 00:40:53 +0000 | [diff] [blame] | 286 | int Res = 0; |
| 287 | if (C.get()) |
Daniel Dunbar | c88a88f | 2009-07-01 20:03:04 +0000 | [diff] [blame] | 288 | Res = TheDriver.ExecuteCompilation(*C); |
Daniel Dunbar | 8f25c79 | 2009-03-18 01:38:48 +0000 | [diff] [blame] | 289 | |
Chris Lattner | 30bc7e8 | 2010-03-30 05:39:52 +0000 | [diff] [blame] | 290 | |
| 291 | // If any timers were active but haven't been destroyed yet, print their |
| 292 | // results now. This happens in -disable-free mode. |
| 293 | llvm::TimerGroup::printAll(llvm::errs()); |
| 294 | |
Daniel Dunbar | 8f25c79 | 2009-03-18 01:38:48 +0000 | [diff] [blame] | 295 | llvm::llvm_shutdown(); |
| 296 | |
Daniel Dunbar | af96def | 2009-03-21 00:40:53 +0000 | [diff] [blame] | 297 | return Res; |
Daniel Dunbar | 3ede8d0 | 2009-03-02 19:59:07 +0000 | [diff] [blame] | 298 | } |