1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- llvm/ADT/VectorExtras.h - Helpers for std::vector -------*- C++ -*-===//
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//                     The LLVM Compiler Infrastructure
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details.
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file contains helper functions which are useful for working with the
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// std::vector class.
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef LLVM_ADT_VECTOREXTRAS_H
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define LLVM_ADT_VECTOREXTRAS_H
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <cstdarg>
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <vector>
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm {
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// make_vector - Helper function which is useful for building temporary vectors
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// to pass into type construction of CallInst ctors.  This turns a null
25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// terminated list of pointers (or other value types) into a real live vector.
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman///
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantemplate<typename T>
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumaninline std::vector<T> make_vector(T A, ...) {
29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  va_list Args;
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  va_start(Args, A);
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  std::vector<T> Result;
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  Result.push_back(A);
33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  while (T Val = va_arg(Args, T))
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    Result.push_back(Val);
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  va_end(Args);
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  return Result;
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman}
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} // End llvm namespace
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
42