blob: aaba406f14923d679ade778b694719592a30c7a5 [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
33bool ArgList::hasArg(options::ID Id) const {
34 // 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))
39 return true;
40
41 return false;
42}