]> granicus.if.org Git - clang/commitdiff
Refactor the code a bit so that there is only one call to BuildCompilation. The
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 18 Jul 2010 22:03:55 +0000 (22:03 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 18 Jul 2010 22:03:55 +0000 (22:03 +0000)
StringPointers vector will also be used in the normal case to handle @file
arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108660 91177308-0d34-0410-b5e6-96231b3b80d8

tools/driver/driver.cpp

index c4b12cba0f7a3467d8a5797fbd6989d4f218e528..8df42246ab0b2d3838a91811e684eef19ca03513 100644 (file)
@@ -248,18 +248,13 @@ int main(int argc, const char **argv) {
   // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a
   // command line behind the scenes.
   std::set<std::string> SavedStrings;
+  std::vector<const char*> StringPointers(argv, argv + argc);
   if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) {
     // FIXME: Driver shouldn't take extra initial argument.
-    std::vector<const char*> StringPointers(argv, argv + argc);
-
     ApplyQAOverride(StringPointers, OverrideStr, SavedStrings);
-
-    C.reset(TheDriver.BuildCompilation(StringPointers.size(),
-                                       &StringPointers[0]));
   } else if (const char *Cur = ::getenv("CCC_ADD_ARGS")) {
-    std::vector<const char*> StringPointers;
-
     // FIXME: Driver shouldn't take extra initial argument.
+    StringPointers.clear();
     StringPointers.push_back(argv[0]);
 
     for (;;) {
@@ -277,11 +272,9 @@ int main(int argc, const char **argv) {
     }
 
     StringPointers.insert(StringPointers.end(), argv + 1, argv + argc);
-
-    C.reset(TheDriver.BuildCompilation(StringPointers.size(),
-                                       &StringPointers[0]));
-  } else
-    C.reset(TheDriver.BuildCompilation(argc, argv));
+  }
+  C.reset(TheDriver.BuildCompilation(StringPointers.size(),
+                                     &StringPointers[0]));
 
   int Res = 0;
   if (C.get())