[cfe-commits] r84220 - /cfe/trunk/tools/CIndex/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Thu Oct 15 16:21:22 PDT 2009
Author: kremenek
Date: Thu Oct 15 18:21:22 2009
New Revision: 84220
URL: http://llvm.org/viewvc/llvm-project?rev=84220&view=rev
Log:
Use an std::vector<> instead of an array of ARG_MAX size, as ARG_MAX may not be defined everywhere.
Modified:
cfe/trunk/tools/CIndex/CIndex.cpp
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=84220&r1=84219&r2=84220&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Thu Oct 15 18:21:22 2009
@@ -25,6 +25,7 @@
#include <cstdio>
#include <dlfcn.h>
#include <sys/wait.h>
+#include <vector>
#include "llvm/System/Path.h"
using namespace clang;
@@ -293,26 +294,25 @@
const char *source_filename,
int num_command_line_args, const char **command_line_args)
{
- // Build up the arguments for involking clang.
- int argc = 0;
- const char * argv[ARG_MAX];
- argv[argc++] = clangPath;
- argv[argc++] = "-emit-ast";
- argv[argc++] = source_filename;
- argv[argc++] = "-o";
+ // Build up the arguments for involing clang.
+ std::vector<const char *> argv;
+ argv.push_back(clangPath);
+ argv.push_back("-emit-ast");
+ argv.push_back(source_filename);
+ argv.push_back("-o");
// Generate a temporary name for the AST file.
char astTmpFile[L_tmpnam];
- argv[argc++] = tmpnam(astTmpFile);
+ argv.push_back(tmpnam(astTmpFile));
for (int i = num_command_line_args; i < num_command_line_args; i++)
- argv[argc++] = command_line_args[i];
- argv[argc] = 0;
-
+ argv.push_back(command_line_args[i]);
+ argv.push_back(NULL);
+
// Generate the AST file in a separate process.
pid_t child_pid = fork();
if (child_pid == 0) { // Child process
// Execute the command, passing the appropriate arguments.
- execv(argv[0], (char *const *)argv);
+ execv(argv[0], (char *const *)&argv[0]);
// If execv returns, it failed.
assert(0 && "execv() failed");
More information about the cfe-commits
mailing list