Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -782,6 +782,7 @@ add_subdirectory(utils/PerfectShuffle) add_subdirectory(utils/count) add_subdirectory(utils/not) + add_subdirectory(utils/llvm-echo) add_subdirectory(utils/llvm-lit) add_subdirectory(utils/yaml-bench) add_subdirectory(utils/unittest) Index: utils/llvm-echo/CMakeLists.txt =================================================================== --- /dev/null +++ utils/llvm-echo/CMakeLists.txt @@ -0,0 +1,3 @@ +add_llvm_utility(llvm-echo llvm-echo.cpp) + +target_link_libraries(llvm-echo LLVMSupport) Index: utils/llvm-echo/llvm-echo.cpp =================================================================== --- /dev/null +++ utils/llvm-echo/llvm-echo.cpp @@ -0,0 +1,44 @@ +//===- llvm-echo.cpp - The 'echo' command --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is an implementation of a portable "echo" command. +// It tokenizes command line arguments in the Unix style even on Windows. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/StringSaver.h" +#include "llvm/Support/raw_ostream.h" + +#if LLVM_ON_WIN32 +#include +#endif + +using namespace llvm; + +int main(int Argc, const char **Argv) { + SmallVector Args; + +#if LLVM_ON_WIN32 + const char *Cmdline = GetCommandLineA(); + BumpPtrAllocator Alloc; + StringSaver Saver(Alloc); + llvm::cl::TokenizeGNUCommandLine(Cmdline, Saver, Args); +#else + Args.insert(Args.begin(), Argv, Argv + Argc); +#endif + + for (int I = 1, E = Args.size(); I < E; ++I) { + if (I != 1) + llvm::outs() << " "; + llvm::outs() << Args[I]; + } + llvm::outs() << "\n"; + return 0; +}