blob: e3797d4495894d9480c1f31348150f82c98764df [file] [log] [blame]
Daniel Dunbar3ede8d02009-03-02 19:59:07 +00001//===-- 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 Dunbar1eb4e642009-03-03 05:55:11 +000010// This is the entry point to the clang driver; it is a thin wrapper
11// for functionality in the Driver clang library.
Daniel Dunbar3ede8d02009-03-02 19:59:07 +000012//
13//===----------------------------------------------------------------------===//
14
15#include "clang/Driver/Compilation.h"
16#include "clang/Driver/Driver.h"
Daniel Dunbar2c6f6f32009-03-04 08:33:23 +000017#include "clang/Driver/Option.h"
Daniel Dunbaraf20afb2010-02-25 03:23:43 +000018#include "clang/Frontend/DiagnosticOptions.h"
19#include "clang/Frontend/TextDiagnosticPrinter.h"
Daniel Dunbar2c6f6f32009-03-04 08:33:23 +000020
Daniel Dunbar510d7322009-03-18 02:11:26 +000021#include "llvm/ADT/SmallString.h"
Rafael Espindola8a1af322010-07-19 15:20:12 +000022#include "llvm/ADT/SmallVector.h"
Daniel Dunbar3ede8d02009-03-02 19:59:07 +000023#include "llvm/ADT/OwningPtr.h"
Daniel Dunbardd98e2c2009-03-10 23:41:59 +000024#include "llvm/Config/config.h"
Rafael Espindola8a1af322010-07-19 15:20:12 +000025#include "llvm/Support/ErrorHandling.h"
Michael J. Spencerfbfd1802010-12-21 16:45:57 +000026#include "llvm/Support/FileSystem.h"
Daniel Dunbar8f25c792009-03-18 01:38:48 +000027#include "llvm/Support/ManagedStatic.h"
Rafael Espindola8a1af322010-07-19 15:20:12 +000028#include "llvm/Support/MemoryBuffer.h"
Daniel Dunbar8f25c792009-03-18 01:38:48 +000029#include "llvm/Support/PrettyStackTrace.h"
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +000030#include "llvm/Support/Regex.h"
Chris Lattner30bc7e82010-03-30 05:39:52 +000031#include "llvm/Support/Timer.h"
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +000032#include "llvm/Support/raw_ostream.h"
Michael J. Spencer03013fa2010-11-29 18:12:39 +000033#include "llvm/Support/Host.h"
34#include "llvm/Support/Path.h"
35#include "llvm/Support/Program.h"
36#include "llvm/Support/Signals.h"
Michael J. Spencer3a321e22010-12-09 17:36:38 +000037#include "llvm/Support/system_error.h"
Douglas Gregor43d013d2011-01-17 19:15:43 +000038#include <cctype>
Daniel Dunbar4ad4b3e2009-03-12 08:55:43 +000039using namespace clang;
Daniel Dunbar1b3bb6e2009-03-04 20:49:20 +000040using namespace clang::driver;
Daniel Dunbar3ede8d02009-03-02 19:59:07 +000041
Benjamin Krameraeed3da2010-10-30 17:32:40 +000042llvm::sys::Path GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
Rafael Espindola0f4c59c2009-12-04 19:31:58 +000043 if (!CanonicalPrefixes)
44 return llvm::sys::Path(Argv0);
45
Daniel Dunbar734932c2009-03-18 20:25:53 +000046 // This just needs to be some symbol in the binary; C++ doesn't
47 // allow taking the address of ::main however.
48 void *P = (void*) (intptr_t) GetExecutablePath;
49 return llvm::sys::Path::GetMainExecutable(Argv0, P);
50}
51
Daniel Dunbar237a31b2009-07-17 18:10:27 +000052static const char *SaveStringInSet(std::set<std::string> &SavedStrings,
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +000053 llvm::StringRef S) {
Daniel Dunbarec9587d2009-04-17 01:54:00 +000054 return SavedStrings.insert(S).first->c_str();
55}
56
57/// ApplyQAOverride - Apply a list of edits to the input argument lists.
58///
59/// The input string is a space separate list of edits to perform,
60/// they are applied in order to the input argument lists. Edits
61/// should be one of the following forms:
62///
Daniel Dunbare3d60232009-07-16 21:32:51 +000063/// '#': Silence information about the changes to the command line arguments.
64///
Daniel Dunbarec9587d2009-04-17 01:54:00 +000065/// '^': Add FOO as a new argument at the beginning of the command line.
66///
67/// '+': Add FOO as a new argument at the end of the command line.
68///
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +000069/// 's/XXX/YYY/': Substitute the regular expression XXX with YYY in the command
70/// line.
Daniel Dunbarec9587d2009-04-17 01:54:00 +000071///
72/// 'xOPTION': Removes all instances of the literal argument OPTION.
73///
74/// 'XOPTION': Removes all instances of the literal argument OPTION,
75/// and the following argument.
76///
77/// 'Ox': Removes all flags matching 'O' or 'O[sz0-9]' and adds 'Ox'
78/// at the end of the command line.
Daniel Dunbare3d60232009-07-16 21:32:51 +000079///
80/// \param OS - The stream to write edit information to.
81/// \param Args - The vector of command line arguments.
82/// \param Edit - The override command to perform.
83/// \param SavedStrings - Set to use for storing string representations.
Chris Lattner30bc7e82010-03-30 05:39:52 +000084static void ApplyOneQAOverride(llvm::raw_ostream &OS,
Daniel Dunbare5d69672010-07-20 02:47:40 +000085 llvm::SmallVectorImpl<const char*> &Args,
Chris Lattner30bc7e82010-03-30 05:39:52 +000086 llvm::StringRef Edit,
87 std::set<std::string> &SavedStrings) {
Daniel Dunbarec9587d2009-04-17 01:54:00 +000088 // This does not need to be efficient.
89
Daniel Dunbar237a31b2009-07-17 18:10:27 +000090 if (Edit[0] == '^') {
91 const char *Str =
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +000092 SaveStringInSet(SavedStrings, Edit.substr(1));
Daniel Dunbar237a31b2009-07-17 18:10:27 +000093 OS << "### Adding argument " << Str << " at beginning\n";
94 Args.insert(Args.begin() + 1, Str);
95 } else if (Edit[0] == '+') {
96 const char *Str =
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +000097 SaveStringInSet(SavedStrings, Edit.substr(1));
Daniel Dunbar237a31b2009-07-17 18:10:27 +000098 OS << "### Adding argument " << Str << " at end\n";
99 Args.push_back(Str);
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +0000100 } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") &&
101 Edit.slice(2, Edit.size()-1).find('/') != llvm::StringRef::npos) {
102 llvm::StringRef MatchPattern = Edit.substr(2).split('/').first;
103 llvm::StringRef ReplPattern = Edit.substr(2).split('/').second;
104 ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1);
105
106 for (unsigned i = 1, e = Args.size(); i != e; ++i) {
107 std::string Repl = llvm::Regex(MatchPattern).sub(ReplPattern, Args[i]);
108
109 if (Repl != Args[i]) {
110 OS << "### Replacing '" << Args[i] << "' with '" << Repl << "'\n";
111 Args[i] = SaveStringInSet(SavedStrings, Repl);
112 }
113 }
Daniel Dunbar237a31b2009-07-17 18:10:27 +0000114 } else if (Edit[0] == 'x' || Edit[0] == 'X') {
115 std::string Option = Edit.substr(1, std::string::npos);
116 for (unsigned i = 1; i < Args.size();) {
117 if (Option == Args[i]) {
118 OS << "### Deleting argument " << Args[i] << '\n';
119 Args.erase(Args.begin() + i);
120 if (Edit[0] == 'X') {
121 if (i < Args.size()) {
122 OS << "### Deleting argument " << Args[i] << '\n';
123 Args.erase(Args.begin() + i);
124 } else
125 OS << "### Invalid X edit, end of command line!\n";
126 }
127 } else
128 ++i;
129 }
130 } else if (Edit[0] == 'O') {
131 for (unsigned i = 1; i < Args.size();) {
132 const char *A = Args[i];
133 if (A[0] == '-' && A[1] == 'O' &&
134 (A[2] == '\0' ||
135 (A[3] == '\0' && (A[2] == 's' || A[2] == 'z' ||
136 ('0' <= A[2] && A[2] <= '9'))))) {
137 OS << "### Deleting argument " << Args[i] << '\n';
138 Args.erase(Args.begin() + i);
139 } else
140 ++i;
141 }
142 OS << "### Adding argument " << Edit << " at end\n";
Daniel Dunbar0de9a7b2010-02-17 21:00:34 +0000143 Args.push_back(SaveStringInSet(SavedStrings, '-' + Edit.str()));
Daniel Dunbar237a31b2009-07-17 18:10:27 +0000144 } else {
145 OS << "### Unrecognized edit: " << Edit << "\n";
146 }
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000147}
148
149/// ApplyQAOverride - Apply a comma separate list of edits to the
150/// input argument lists. See ApplyOneQAOverride.
Daniel Dunbare5d69672010-07-20 02:47:40 +0000151static void ApplyQAOverride(llvm::SmallVectorImpl<const char*> &Args,
Chris Lattner30bc7e82010-03-30 05:39:52 +0000152 const char *OverrideStr,
153 std::set<std::string> &SavedStrings) {
Daniel Dunbare3d60232009-07-16 21:32:51 +0000154 llvm::raw_ostream *OS = &llvm::errs();
Daniel Dunbar237a31b2009-07-17 18:10:27 +0000155
Daniel Dunbare3d60232009-07-16 21:32:51 +0000156 if (OverrideStr[0] == '#') {
157 ++OverrideStr;
158 OS = &llvm::nulls();
159 }
160
161 *OS << "### QA_OVERRIDE_GCC3_OPTIONS: " << OverrideStr << "\n";
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000162
163 // This does not need to be efficient.
164
165 const char *S = OverrideStr;
166 while (*S) {
167 const char *End = ::strchr(S, ' ');
168 if (!End)
169 End = S + strlen(S);
170 if (End != S)
Daniel Dunbare3d60232009-07-16 21:32:51 +0000171 ApplyOneQAOverride(*OS, Args, std::string(S, End), SavedStrings);
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000172 S = End;
173 if (*S != '\0')
174 ++S;
175 }
176}
177
Daniel Dunbarc88aa792009-11-30 07:18:13 +0000178extern int cc1_main(const char **ArgBegin, const char **ArgEnd,
Daniel Dunbar545c2812009-11-29 20:58:32 +0000179 const char *Argv0, void *MainAddr);
Daniel Dunbar41b5b172010-05-20 17:49:16 +0000180extern int cc1as_main(const char **ArgBegin, const char **ArgEnd,
181 const char *Argv0, void *MainAddr);
Daniel Dunbar217acbf2009-11-19 07:37:51 +0000182
Rafael Espindola8a1af322010-07-19 15:20:12 +0000183static void ExpandArgsFromBuf(const char *Arg,
Daniel Dunbare5d69672010-07-20 02:47:40 +0000184 llvm::SmallVectorImpl<const char*> &ArgVector,
Rafael Espindola8a1af322010-07-19 15:20:12 +0000185 std::set<std::string> &SavedStrings) {
186 const char *FName = Arg + 1;
Michael J. Spencer4eeebc42010-12-16 03:28:14 +0000187 llvm::OwningPtr<llvm::MemoryBuffer> MemBuf;
188 if (llvm::MemoryBuffer::getFile(FName, MemBuf)) {
Rafael Espindola8a1af322010-07-19 15:20:12 +0000189 ArgVector.push_back(SaveStringInSet(SavedStrings, Arg));
190 return;
191 }
192
193 const char *Buf = MemBuf->getBufferStart();
194 char InQuote = ' ';
195 std::string CurArg;
196
197 for (const char *P = Buf; ; ++P) {
198 if (*P == '\0' || (isspace(*P) && InQuote == ' ')) {
199 if (!CurArg.empty()) {
200
201 if (CurArg[0] != '@') {
202 ArgVector.push_back(SaveStringInSet(SavedStrings, CurArg));
203 } else {
204 ExpandArgsFromBuf(CurArg.c_str(), ArgVector, SavedStrings);
205 }
206
207 CurArg = "";
208 }
209 if (*P == '\0')
210 break;
211 else
212 continue;
213 }
214
215 if (isspace(*P)) {
216 if (InQuote != ' ')
217 CurArg.push_back(*P);
218 continue;
219 }
220
221 if (*P == '"' || *P == '\'') {
222 if (InQuote == *P)
223 InQuote = ' ';
224 else if (InQuote == ' ')
225 InQuote = *P;
226 else
227 CurArg.push_back(*P);
228 continue;
229 }
230
231 if (*P == '\\') {
232 ++P;
233 if (*P != '\0')
234 CurArg.push_back(*P);
235 continue;
236 }
237 CurArg.push_back(*P);
238 }
Rafael Espindola8a1af322010-07-19 15:20:12 +0000239}
240
241static void ExpandArgv(int argc, const char **argv,
Daniel Dunbare5d69672010-07-20 02:47:40 +0000242 llvm::SmallVectorImpl<const char*> &ArgVector,
Rafael Espindola8a1af322010-07-19 15:20:12 +0000243 std::set<std::string> &SavedStrings) {
244 for (int i = 0; i < argc; ++i) {
245 const char *Arg = argv[i];
246 if (Arg[0] != '@') {
247 ArgVector.push_back(SaveStringInSet(SavedStrings, std::string(Arg)));
248 continue;
249 }
250
251 ExpandArgsFromBuf(Arg, ArgVector, SavedStrings);
252 }
253}
254
255int main(int argc_, const char **argv_) {
Daniel Dunbar3ede8d02009-03-02 19:59:07 +0000256 llvm::sys::PrintStackTraceOnErrorSignal();
Rafael Espindola8a1af322010-07-19 15:20:12 +0000257 llvm::PrettyStackTraceProgram X(argc_, argv_);
258
259 std::set<std::string> SavedStrings;
Daniel Dunbare5d69672010-07-20 02:47:40 +0000260 llvm::SmallVector<const char*, 256> argv;
Rafael Espindola8a1af322010-07-19 15:20:12 +0000261
262 ExpandArgv(argc_, argv_, argv, SavedStrings);
Daniel Dunbar3ede8d02009-03-02 19:59:07 +0000263
Daniel Dunbar41b5b172010-05-20 17:49:16 +0000264 // Handle -cc1 integrated tools.
Rafael Espindola8a1af322010-07-19 15:20:12 +0000265 if (argv.size() > 1 && llvm::StringRef(argv[1]).startswith("-cc1")) {
Daniel Dunbar41b5b172010-05-20 17:49:16 +0000266 llvm::StringRef Tool = argv[1] + 4;
267
268 if (Tool == "")
Daniel Dunbare5d69672010-07-20 02:47:40 +0000269 return cc1_main(argv.data()+2, argv.data()+argv.size(), argv[0],
Daniel Dunbar41b5b172010-05-20 17:49:16 +0000270 (void*) (intptr_t) GetExecutablePath);
271 if (Tool == "as")
Daniel Dunbare5d69672010-07-20 02:47:40 +0000272 return cc1as_main(argv.data()+2, argv.data()+argv.size(), argv[0],
Daniel Dunbar41b5b172010-05-20 17:49:16 +0000273 (void*) (intptr_t) GetExecutablePath);
274
275 // Reject unknown tools.
276 llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n";
277 return 1;
278 }
Daniel Dunbarc88aa792009-11-30 07:18:13 +0000279
Rafael Espindola0f4c59c2009-12-04 19:31:58 +0000280 bool CanonicalPrefixes = true;
Rafael Espindola8a1af322010-07-19 15:20:12 +0000281 for (int i = 1, size = argv.size(); i < size; ++i) {
Rafael Espindola0f4c59c2009-12-04 19:31:58 +0000282 if (llvm::StringRef(argv[i]) == "-no-canonical-prefixes") {
283 CanonicalPrefixes = false;
284 break;
285 }
286 }
287
288 llvm::sys::Path Path = GetExecutablePath(argv[0], CanonicalPrefixes);
289
Douglas Gregorbdbb0042010-08-18 22:29:43 +0000290 TextDiagnosticPrinter *DiagClient
291 = new TextDiagnosticPrinter(llvm::errs(), DiagnosticOptions());
Michael J. Spencerd5b08be2010-12-18 04:13:32 +0000292 DiagClient->setPrefix(llvm::sys::path::stem(Path.str()));
Argyrios Kyrtzidis33e4e702010-11-18 20:06:41 +0000293 llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
294 Diagnostic Diags(DiagID, DiagClient);
Daniel Dunbar510d7322009-03-18 02:11:26 +0000295
Daniel Dunbarf44c5852009-09-22 22:31:13 +0000296#ifdef CLANG_IS_PRODUCTION
Kovarththanan Rajaratnam240c7342010-03-08 18:33:04 +0000297 const bool IsProduction = true;
Daniel Dunbar5d93ed32010-04-01 18:21:41 +0000298# ifdef CLANGXX_IS_PRODUCTION
299 const bool CXXIsProduction = true;
300# else
301 const bool CXXIsProduction = false;
302# endif
Daniel Dunbarf44c5852009-09-22 22:31:13 +0000303#else
Kovarththanan Rajaratnam240c7342010-03-08 18:33:04 +0000304 const bool IsProduction = false;
Daniel Dunbar5d93ed32010-04-01 18:21:41 +0000305 const bool CXXIsProduction = false;
Daniel Dunbarf44c5852009-09-22 22:31:13 +0000306#endif
Daniel Dunbar0bbad512010-07-19 00:44:04 +0000307 Driver TheDriver(Path.str(), llvm::sys::getHostTriple(),
Daniel Dunbar5d93ed32010-04-01 18:21:41 +0000308 "a.out", IsProduction, CXXIsProduction,
309 Diags);
Daniel Dunbare5be6da2009-04-01 19:08:46 +0000310
Daniel Dunbaredf29b02010-08-01 22:29:51 +0000311 // Attempt to find the original path used to invoke the driver, to determine
312 // the installed path. We do this manually, because we want to support that
313 // path being a symlink.
Michael J. Spencerfbfd1802010-12-21 16:45:57 +0000314 {
315 llvm::SmallString<128> InstalledPath(argv[0]);
Daniel Dunbaredf29b02010-08-01 22:29:51 +0000316
Michael J. Spencerfbfd1802010-12-21 16:45:57 +0000317 // Do a PATH lookup, if there are no directory components.
318 if (llvm::sys::path::filename(InstalledPath) == InstalledPath) {
319 llvm::sys::Path Tmp = llvm::sys::Program::FindProgramByName(
320 llvm::sys::path::filename(InstalledPath.str()));
321 if (!Tmp.empty())
322 InstalledPath = Tmp.str();
323 }
324 llvm::sys::fs::make_absolute(InstalledPath);
325 InstalledPath = llvm::sys::path::parent_path(InstalledPath);
326 bool exists;
327 if (!llvm::sys::fs::exists(InstalledPath.str(), exists) && exists)
328 TheDriver.setInstalledDir(InstalledPath);
Daniel Dunbaredf29b02010-08-01 22:29:51 +0000329 }
Daniel Dunbaredf29b02010-08-01 22:29:51 +0000330
Daniel Dunbar8fa01c82009-11-10 18:47:41 +0000331 // Check for ".*++" or ".*++-[^-]*" to determine if we are a C++
332 // compiler. This matches things like "c++", "clang++", and "clang++-1.1".
333 //
334 // Note that we intentionally want to use argv[0] here, to support "clang++"
335 // being a symlink.
Benjamin Kramerd5dc9f32009-11-20 11:49:06 +0000336 //
337 // We use *argv instead of argv[0] to work around a bogus g++ warning.
Rafael Espindola8a1af322010-07-19 15:20:12 +0000338 const char *progname = argv_[0];
Michael J. Spencerd5b08be2010-12-18 04:13:32 +0000339 std::string ProgName(llvm::sys::path::stem(progname));
Daniel Dunbare26bd902009-11-11 10:10:25 +0000340 if (llvm::StringRef(ProgName).endswith("++") ||
Daniel Dunbar0dea4be2009-12-25 20:21:23 +0000341 llvm::StringRef(ProgName).rsplit('-').first.endswith("++")) {
Daniel Dunbar8fa01c82009-11-10 18:47:41 +0000342 TheDriver.CCCIsCXX = true;
Daniel Dunbar0dea4be2009-12-25 20:21:23 +0000343 }
Daniel Dunbar8fa01c82009-11-10 18:47:41 +0000344
Daniel Dunbar4c00fcd2010-03-20 08:01:59 +0000345 // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
346 TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
347 if (TheDriver.CCPrintOptions)
348 TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE");
349
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000350 // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a
351 // command line behind the scenes.
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000352 if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) {
353 // FIXME: Driver shouldn't take extra initial argument.
Rafael Espindola8a1af322010-07-19 15:20:12 +0000354 ApplyQAOverride(argv, OverrideStr, SavedStrings);
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000355 } else if (const char *Cur = ::getenv("CCC_ADD_ARGS")) {
Daniel Dunbare5be6da2009-04-01 19:08:46 +0000356 // FIXME: Driver shouldn't take extra initial argument.
Rafael Espindola8a1af322010-07-19 15:20:12 +0000357 std::vector<const char*> ExtraArgs;
Daniel Dunbare5be6da2009-04-01 19:08:46 +0000358
359 for (;;) {
360 const char *Next = strchr(Cur, ',');
Daniel Dunbar237a31b2009-07-17 18:10:27 +0000361
Daniel Dunbare5be6da2009-04-01 19:08:46 +0000362 if (Next) {
Rafael Espindola8a1af322010-07-19 15:20:12 +0000363 ExtraArgs.push_back(SaveStringInSet(SavedStrings,
364 std::string(Cur, Next)));
Daniel Dunbare5be6da2009-04-01 19:08:46 +0000365 Cur = Next + 1;
366 } else {
Daniel Dunbarec9587d2009-04-17 01:54:00 +0000367 if (*Cur != '\0')
Rafael Espindola8a1af322010-07-19 15:20:12 +0000368 ExtraArgs.push_back(SaveStringInSet(SavedStrings, Cur));
Daniel Dunbare5be6da2009-04-01 19:08:46 +0000369 break;
370 }
371 }
372
Daniel Dunbare5d69672010-07-20 02:47:40 +0000373 argv.insert(&argv[1], ExtraArgs.begin(), ExtraArgs.end());
Rafael Espindola06e35d32010-07-18 22:03:55 +0000374 }
Daniel Dunbar3ede8d02009-03-02 19:59:07 +0000375
Daniel Dunbar5633c1e2010-08-01 22:29:47 +0000376 llvm::OwningPtr<Compilation> C(TheDriver.BuildCompilation(argv.size(),
377 &argv[0]));
Daniel Dunbaraf96def2009-03-21 00:40:53 +0000378 int Res = 0;
379 if (C.get())
Daniel Dunbarc88a88f2009-07-01 20:03:04 +0000380 Res = TheDriver.ExecuteCompilation(*C);
Chris Lattner30bc7e82010-03-30 05:39:52 +0000381
382 // If any timers were active but haven't been destroyed yet, print their
383 // results now. This happens in -disable-free mode.
384 llvm::TimerGroup::printAll(llvm::errs());
385
Daniel Dunbar8f25c792009-03-18 01:38:48 +0000386 llvm::llvm_shutdown();
387
Daniel Dunbaraf96def2009-03-21 00:40:53 +0000388 return Res;
Daniel Dunbar3ede8d02009-03-02 19:59:07 +0000389}