Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11541

Handle failure in the Driver's getTemporaryFilePath helper

    XMLWordPrintable

    Details

      Description

      const char *
      ToolChain::JobContext::getTemporaryFilePath(const llvm::Twine &name,
                                                  StringRef suffix) const {
        SmallString<128> buffer;
        std::error_code EC = llvm::sys::fs::createTemporaryFile(name, suffix, buffer);
        if (EC) {
          // FIXME: This should not take down the entire process.
          llvm::report_fatal_error("unable to create temporary file for filelist");
        }
      
        C.addTemporaryFile(buffer.str(), PreserveOnSignal::Yes);
        // We can't just reference the data in the TemporaryFiles vector because
        // that could theoretically get copied to a new address.
        return C.getArgs().MakeArgString(buffer.str());
      }
      

      This is obviously not optimal. The immediate action is to return an llvm::Expected<const char *> instead, to represent the failure, but all of the callers are constructing command-lines for the jobs to run for this compilation. That's not currently something that can fail.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jrose Jordan Rose
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: