[cfe-commits] r51803 - /cfe/trunk/Driver/clang.cpp

Ted Kremenek kremenek at apple.com
Fri May 30 17:27:06 PDT 2008


Author: kremenek
Date: Fri May 30 19:27:00 2008
New Revision: 51803

URL: http://llvm.org/viewvc/llvm-project?rev=51803&view=rev
Log:
Correctly preserve the order between -F and -I options.

Modified:
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=51803&r1=51802&r2=51803&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Fri May 30 19:27:00 2008
@@ -870,13 +870,23 @@
 /// HeaderSearch object.
 static void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers,
                                    FileManager &FM, const LangOptions &Lang) {
-  // Handle -F... options.
-  for (unsigned i = 0, e = F_dirs.size(); i != e; ++i)
-    AddPath(F_dirs[i], Angled, false, true, true, Headers);
-  
-  // Handle -I... options.
-  for (unsigned i = 0, e = I_dirs.size(); i != e; ++i)
-    AddPath(I_dirs[i], Angled, false, true, false, Headers);
+  // Handle -I... and -F... options, walking the lists in parallel.
+  unsigned Iidx = 0, Fidx = 0;
+  while (Iidx < I_dirs.size() && Fidx < F_dirs.size()) {
+    if (I_dirs.getPosition(Iidx) < F_dirs.getPosition(Fidx)) {
+      AddPath(I_dirs[Iidx], Angled, false, true, false, Headers);
+      ++Iidx;
+    } else {
+      AddPath(F_dirs[Fidx], Angled, false, true, true, Headers);
+      ++Fidx;
+    }
+  }
+  
+  // Consume what's left from whatever list was longer.
+  for (; Iidx != I_dirs.size(); ++Iidx)
+    AddPath(I_dirs[Iidx], Angled, false, true, false, Headers);
+  for (; Fidx != F_dirs.size(); ++Fidx)
+    AddPath(F_dirs[Fidx], Angled, false, true, true, Headers);
   
   // Handle -idirafter... options.
   for (unsigned i = 0, e = idirafter_dirs.size(); i != e; ++i)





More information about the cfe-commits mailing list