[cfe-commits] r49645 - /cfe/trunk/Driver/clang.cpp
Sam Bishop
sam at bishop.dhs.org
Mon Apr 14 07:41:57 PDT 2008
Author: sbishop
Date: Mon Apr 14 09:41:57 2008
New Revision: 49645
URL: http://llvm.org/viewvc/llvm-project?rev=49645&view=rev
Log:
Handle -D and -U options in order, so that they can cancel each other out when
intermixed.
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=49645&r1=49644&r2=49645&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Apr 14 09:41:57 2008
@@ -598,14 +598,17 @@
return 0;
}
}
-
+
// Add macros from the command line.
- // FIXME: Should traverse the #define/#undef lists in parallel.
- for (unsigned i = 0, e = D_macros.size(); i != e; ++i)
- DefineBuiltinMacro(PredefineBuffer, D_macros[i].c_str());
- for (unsigned i = 0, e = U_macros.size(); i != e; ++i)
- DefineBuiltinMacro(PredefineBuffer, U_macros[i].c_str(), "#undef ");
-
+ unsigned d = 0, D = D_macros.size();
+ unsigned u = 0, U = U_macros.size();
+ while (d < D || u < U) {
+ if (u == U || (d < D && D_macros.getPosition(d) < U_macros.getPosition(u)))
+ DefineBuiltinMacro(PredefineBuffer, D_macros[d++].c_str());
+ else
+ DefineBuiltinMacro(PredefineBuffer, U_macros[u++].c_str(), "#undef ");
+ }
+
// FIXME: Read any files specified by -imacros.
// Add implicit #includes from -include.
More information about the cfe-commits
mailing list