aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Compilation.cpp
diff options
context:
space:
mode:
authorSean Perry <perry@ca.ibm.com>2021-03-26 16:37:29 -0400
committerMuiez Ahmed <muiez@ibm.com>2021-03-26 16:38:36 -0400
commit7e0cc45ced230b4ef3a9d8eaedfbe92e75f21916 (patch)
tree4d0f2fb1c1b3c34cbe18c2ed943ce07c7952bc74 /clang/lib/Driver/Compilation.cpp
parent4622648a069a988d3b7b3ecd3f1b6993518d85b5 (diff)
downloadllvm-7e0cc45ced230b4ef3a9d8eaedfbe92e75f21916.zip
llvm-7e0cc45ced230b4ef3a9d8eaedfbe92e75f21916.tar.gz
llvm-7e0cc45ced230b4ef3a9d8eaedfbe92e75f21916.tar.bz2
[SystemZ][z/OS] Save strings for CC_PRINT env vars
The contents of the string returned by getenv() is not guaranteed across calls to getenv(). The code to handle the CC_PRINT etc env vars calls getenv() and saves the results in just a char *. The string returned by getenv() needs to be copied and saved. Switching the type of the strings from char * to std::string will do this and manage the alloated memory. Differential Revision: https://reviews.llvm.org/D98554
Diffstat (limited to 'clang/lib/Driver/Compilation.cpp')
-rw-r--r--clang/lib/Driver/Compilation.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index d330557..f28c23a 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -170,10 +170,11 @@ int Compilation::ExecuteCommand(const Command &C,
// Follow gcc implementation of CC_PRINT_OPTIONS; we could also cache the
// output stream.
- if (getDriver().CCPrintOptions && getDriver().CCPrintOptionsFilename) {
+ if (getDriver().CCPrintOptions &&
+ !getDriver().CCPrintOptionsFilename.empty()) {
std::error_code EC;
OwnedStream.reset(new llvm::raw_fd_ostream(
- getDriver().CCPrintOptionsFilename, EC,
+ getDriver().CCPrintOptionsFilename.c_str(), EC,
llvm::sys::fs::OF_Append | llvm::sys::fs::OF_Text));
if (EC) {
getDriver().Diag(diag::err_drv_cc_print_options_failure)