summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-13 00:06:24 +0000
committerChris Lattner <sabre@nondot.org>2006-10-13 00:06:24 +0000
commit5af1cbc5cf32b8ddec9033bf81fb1663dcd0346c (patch)
treee2fd0f9d65b1bb00b927fe3b12e60b5adb6679a3 /llvm/lib
parent78d838186c54c4a1365656221bb9b3382de07f2c (diff)
downloadbcm5719-llvm-5af1cbc5cf32b8ddec9033bf81fb1663dcd0346c.tar.gz
bcm5719-llvm-5af1cbc5cf32b8ddec9033bf81fb1663dcd0346c.zip
avoid a ctor/dtor issue with the ProgramName global.
llvm-svn: 30925
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/CommandLine.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index cd903126f5b..39d388cbeae 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -57,8 +57,9 @@ void parser<std::string>::anchor() {}
//===----------------------------------------------------------------------===//
-// Globals for name and overview of program
-static std::string ProgramName = "<premain>";
+// Globals for name and overview of program. Program name is not a string to
+// avoid static ctor/dtor issues.
+static char ProgramName[80] = "<premain>";
static const char *ProgramOverview = 0;
// This collects additional help to be printed.
@@ -303,7 +304,12 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
"No options specified, or ParseCommandLineOptions called more"
" than once!");
sys::Path progname(argv[0]);
- ProgramName = sys::Path(argv[0]).getLast();
+
+ // Copy the program name into ProgName, making sure not to overflow it.
+ std::string ProgName = sys::Path(argv[0]).getLast();
+ if (ProgName.size() > 79) ProgName.resize(79);
+ strcpy(ProgramName, ProgName.c_str());
+
ProgramOverview = Overview;
bool ErrorParsing = false;
OpenPOWER on IntegriCloud