blob: e29977fb0e9f73f23d67e6e107711c228c444838 [file] [log] [blame]
Daniel Dunbard77aac92009-03-04 17:10:42 +00001//===--- ArgList.cpp - Argument List Management -------------------------*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/Driver/ArgList.h"
11#include "clang/Driver/Arg.h"
Daniel Dunbar12d474a2009-03-04 22:40:08 +000012#include "clang/Driver/Option.h"
Daniel Dunbard77aac92009-03-04 17:10:42 +000013
14using namespace clang::driver;
15
16ArgList::ArgList(const char **ArgBegin, const char **ArgEnd) {
17 ArgStrings.append(ArgBegin, ArgEnd);
18}
19
20ArgList::~ArgList() {
21 for (iterator it = begin(), ie = end(); it != ie; ++ie)
22 delete *it;
23}
Daniel Dunbar12d474a2009-03-04 22:40:08 +000024
25void ArgList::append(Arg *A) {
26 if (A->getOption().isUnsupported()) {
27 assert(0 && "FIXME: unsupported unsupported.");
28 }
29
30 Args.push_back(A);
31}
Daniel Dunbarf01869c2009-03-12 01:36:44 +000032
Daniel Dunbar08a0ae42009-03-12 16:03:38 +000033Arg *ArgList::getLastArg(options::ID Id) const {
Daniel Dunbarf01869c2009-03-12 01:36:44 +000034 // FIXME: Make search efficient?
35
36 // FIXME: This needs to not require loading of the option.
Daniel Dunbar133862c2009-03-12 08:45:11 +000037 for (const_iterator it = begin(), ie = end(); it != ie; ++it)
Daniel Dunbarf01869c2009-03-12 01:36:44 +000038 if ((*it)->getOption().matches(Id))
Daniel Dunbar08a0ae42009-03-12 16:03:38 +000039 return *it;
Daniel Dunbarf01869c2009-03-12 01:36:44 +000040
Daniel Dunbar08a0ae42009-03-12 16:03:38 +000041 return 0;
Daniel Dunbarf01869c2009-03-12 01:36:44 +000042}