diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-30 07:18:13 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-30 07:18:13 +0000 |
commit | c88aa79a6bdfd445df800006f723f83f39934e98 (patch) | |
tree | 658b9891bef54036f0c97d158fe7adde05bed252 /tools/driver/cc1_main.cpp | |
parent | 6e2901407bff59aeb4cc301cc58b034723d0eb49 (diff) |
Put CompilerInvocation testing code in clang-cc instead of clang for now, I can't bear to link all of clang into 'clang' yet. :)
- Still triggered by a magic leading -cc1 argument, as before.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90114 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver/cc1_main.cpp')
-rw-r--r-- | tools/driver/cc1_main.cpp | 69 |
1 files changed, 1 insertions, 68 deletions
diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index 3b8757b528..a9d27efb1c 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -11,81 +11,14 @@ // //===----------------------------------------------------------------------===// -#include "clang/Driver/Arg.h" -#include "clang/Driver/ArgList.h" -#include "clang/Driver/CC1Options.h" -#include "clang/Driver/DriverDiagnostic.h" -#include "clang/Driver/OptTable.h" -#include "clang/Driver/Option.h" -#include "clang/Frontend/CompilerInvocation.h" #include "llvm/Support/raw_ostream.h" -#include <cstdlib> -#include <vector> -using namespace clang; -using namespace clang::driver; - -int cc1_main(Diagnostic &Diags, const char **ArgBegin, const char **ArgEnd, +int cc1_main(const char **ArgBegin, const char **ArgEnd, const char *Argv0, void *MainAddr) { llvm::errs() << "cc1 argv:"; for (const char **i = ArgBegin; i != ArgEnd; ++i) llvm::errs() << " \"" << *i << '"'; llvm::errs() << "\n"; - // Parse the arguments. - OptTable *Opts = createCC1OptTable(); - unsigned MissingArgIndex, MissingArgCount; - InputArgList *Args = Opts->ParseArgs(ArgBegin, ArgEnd, - MissingArgIndex, MissingArgCount); - - // Check for missing argument error. - if (MissingArgCount) - Diags.Report(clang::diag::err_drv_missing_argument) - << Args->getArgString(MissingArgIndex) << MissingArgCount; - - // Dump the parsed arguments. - llvm::errs() << "cc1 parsed options:\n"; - for (ArgList::const_iterator it = Args->begin(), ie = Args->end(); - it != ie; ++it) - (*it)->dump(); - - // Create a compiler invocation. - llvm::errs() << "cc1 creating invocation.\n"; - CompilerInvocation Invocation; - CompilerInvocation::CreateFromArgs(Invocation, ArgBegin, ArgEnd, - Argv0, MainAddr, Diags); - - // Convert the invocation back to argument strings. - std::vector<std::string> InvocationArgs; - Invocation.toArgs(InvocationArgs); - - // Dump the converted arguments. - 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].c_str()); - llvm::errs() << " \"" << InvocationArgs[i] << '"'; - } - llvm::errs() << "\n"; - - // Convert those arguments to another invocation, and check that we got the - // same thing. - CompilerInvocation Invocation2; - CompilerInvocation::CreateFromArgs(Invocation2, Invocation2Args.begin(), - Invocation2Args.end(), Argv0, MainAddr, - Diags); - - // FIXME: Implement CompilerInvocation comparison. - if (true) { - //llvm::errs() << "warning: Invocations differ!\n"; - - std::vector<std::string> Invocation2Args; - Invocation2.toArgs(Invocation2Args); - llvm::errs() << "invocation2 argv:"; - for (unsigned i = 0, e = Invocation2Args.size(); i != e; ++i) - llvm::errs() << " \"" << Invocation2Args[i] << '"'; - llvm::errs() << "\n"; - } - return 0; } |