[PATCH] D98554: Save strings for CC_PRINT env vars

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 12 20:03:37 PST 2021


hubert.reinterpretcast added inline comments.


================
Comment at: clang/include/clang/Driver/Driver.h:160
   /// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
-  const char *CCPrintStatReportFilename;
+  std::string CCPrintStatReportFilename;
 
----------------
I'm seeing code left unchanged like:
```
TheDriver.CCPrintOptionsFilename = ::getenv("CC_PRINT_OPTIONS_FILE");
```

Assigning to a `std::string` from a null `char *` is known to cause things like
```
Segmentation fault
```



================
Comment at: clang/lib/Driver/Compilation.cpp:173
     // output stream.
-    if (getDriver().CCPrintOptions && getDriver().CCPrintOptionsFilename) {
+    if (getDriver().CCPrintOptions && !getDriver().CCPrintOptionsFilename.empty()) {
       std::error_code EC;
----------------
Please update for the clang-format suggestions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98554/new/

https://reviews.llvm.org/D98554



More information about the cfe-commits mailing list