[cfe-commits] r89503 - in /cfe/trunk: include/clang/Frontend/CompilerInvocation.h lib/Driver/CC1Options.cpp tools/driver/cc1_main.cpp
Daniel Dunbar
daniel at zuster.org
Fri Nov 20 14:47:55 PST 2009
Author: ddunbar
Date: Fri Nov 20 16:47:55 2009
New Revision: 89503
URL: http://llvm.org/viewvc/llvm-project?rev=89503&view=rev
Log:
Switch CompilerInvocation::CreateFromArgs to take const char** arguments until Driver itself switches to StringRef.
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/lib/Driver/CC1Options.cpp
cfe/trunk/tools/driver/cc1_main.cpp
Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=89503&r1=89502&r2=89503&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Fri Nov 20 16:47:55 2009
@@ -81,8 +81,8 @@
///
/// \param Res [out] - The resulting invocation.
/// \param Args - The input argument strings.
- static void CreateFromArgs(CompilerInvocation &Res,
- const llvm::SmallVectorImpl<llvm::StringRef> &Args);
+ static void CreateFromArgs(CompilerInvocation &Res, const char **ArgBegin,
+ const char **ArgEnd);
/// toArgs - Convert the CompilerInvocation to a list of strings suitable for
/// passing to CreateFromArgs.
Modified: cfe/trunk/lib/Driver/CC1Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CC1Options.cpp?rev=89503&r1=89502&r2=89503&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/CC1Options.cpp (original)
+++ cfe/trunk/lib/Driver/CC1Options.cpp Fri Nov 20 16:47:55 2009
@@ -135,20 +135,13 @@
//
void CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
- const llvm::SmallVectorImpl<llvm::StringRef> &Args) {
- // This is gratuitous, but until we switch the driver to using StringRef we
- // need to get C strings.
- llvm::SmallVector<std::string, 16> StringArgs(Args.begin(), Args.end());
- llvm::SmallVector<const char *, 16> CStringArgs;
- for (unsigned i = 0, e = Args.size(); i != e; ++i)
- CStringArgs.push_back(StringArgs[i].c_str());
-
+ const char **ArgBegin,
+ const char **ArgEnd) {
// Parse the arguments.
llvm::OwningPtr<OptTable> Opts(createCC1OptTable());
unsigned MissingArgIndex, MissingArgCount;
llvm::OwningPtr<InputArgList> InputArgs(
- Opts->ParseArgs(CStringArgs.begin(), CStringArgs.end(),
- MissingArgIndex, MissingArgCount));
+ Opts->ParseArgs(ArgBegin, ArgEnd,MissingArgIndex, MissingArgCount));
// Check for missing argument error.
if (MissingArgCount) {
@@ -159,6 +152,8 @@
<< " value )\n";
}
- ParseCodeGenArgs(Res.getCodeGenOpts(), *InputArgs);
+ // FIXME: Disabled until the FIXMEs are resolved.
+ if (0)
+ ParseCodeGenArgs(Res.getCodeGenOpts(), *InputArgs);
ParseTargetArgs(Res.getTargetOpts(), *InputArgs);
}
Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=89503&r1=89502&r2=89503&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Fri Nov 20 16:47:55 2009
@@ -51,18 +51,17 @@
// Create a compiler invocation.
llvm::errs() << "cc1 creating invocation.\n";
CompilerInvocation Invocation;
- CompilerInvocation::CreateFromArgs(Invocation,
- llvm::SmallVector<llvm::StringRef, 32>(ArgBegin, ArgEnd));
+ CompilerInvocation::CreateFromArgs(Invocation, ArgBegin, ArgEnd);
// Convert the invocation back to argument strings.
std::vector<std::string> InvocationArgs;
Invocation.toArgs(InvocationArgs);
// Dump the converted arguments.
- llvm::SmallVector<llvm::StringRef, 32> Invocation2Args;
+ llvm::SmallVector<const char*, 32> Invocation2Args;
llvm::errs() << "invocation argv :";
for (unsigned i = 0, e = InvocationArgs.size(); i != e; ++i) {
- Invocation2Args.push_back(InvocationArgs[i]);
+ Invocation2Args.push_back(InvocationArgs[i].c_str());
llvm::errs() << " \"" << InvocationArgs[i] << '"';
}
llvm::errs() << "\n";
@@ -70,7 +69,8 @@
// Convert those arguments to another invocation, and check that we got the
// same thing.
CompilerInvocation Invocation2;
- CompilerInvocation::CreateFromArgs(Invocation2, Invocation2Args);
+ CompilerInvocation::CreateFromArgs(Invocation2, Invocation2Args.begin(),
+ Invocation2Args.end());
// FIXME: Implement CompilerInvocation comparison.
if (true) {
More information about the cfe-commits
mailing list