[PATCH] D146797: [llvm-rc] Remove transitional preprocessing fallback logic

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 03:29:30 PDT 2023


mstorsjo created this revision.
mstorsjo added reviewers: aganea, alvinhochun, thieta.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

When preprocessing was integrated to llvm-rc in 2021, this was a
new requirement (previously one could execute llvm-rc without a
suitable preprocessing tool to be available).

As a transitional helper, llvm-rc fell back on skipping preprocessing
if no suitable tool was found (with a warning printed), but users
could pass an llvm-rc specific option to silence the warning, if they
explicitly want to run the tool without preprocessing.

Now 2 years later, remove the transitional helper - error out if
preprocessing failed. The option for disabling preprocessing remains.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146797

Files:
  llvm/tools/llvm-rc/llvm-rc.cpp


Index: llvm/tools/llvm-rc/llvm-rc.cpp
===================================================================
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -228,7 +228,7 @@
   unsigned LangId = (/*PrimaryLangId*/ 0x09) | (/*SubLangId*/ 0x01 << 10);
 };
 
-bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
+void preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
                 const char *Argv0) {
   std::string Clang;
   if (Opts.PrintCmdAndExit || !Opts.PreprocessCmd.empty()) {
@@ -238,15 +238,12 @@
     if (ClangOrErr) {
       Clang = *ClangOrErr;
     } else {
-      errs() << "llvm-rc: Unable to find clang, skipping preprocessing."
+      errs() << "llvm-rc: Unable to find clang for preprocessing."
              << "\n";
       StringRef OptionName =
           Opts.IsWindres ? "--no-preprocess" : "-no-preprocess";
-      errs()
-          << "Pass " << OptionName
-          << " to disable preprocessing. This will be an error in the future."
-          << "\n";
-      return false;
+      errs() << "Pass " << OptionName << " to disable preprocessing.\n";
+      fatalError("llvm-rc: Unable to preprocess.");
     }
   }
 
@@ -278,7 +275,6 @@
   if (Res) {
     fatalError("llvm-rc: Preprocessing failed.");
   }
-  return true;
 }
 
 static std::pair<bool, std::string> isWindres(llvm::StringRef Argv0) {
@@ -612,8 +608,8 @@
   if (Opts.Preprocess) {
     std::string OutFile = createTempFile("preproc", "rc");
     TempPreprocFile.setFile(OutFile);
-    if (preprocess(Src, OutFile, Opts, Argv0))
-      PreprocessedFile = OutFile;
+    preprocess(Src, OutFile, Opts, Argv0);
+    PreprocessedFile = OutFile;
   }
 
   // Read and tokenize the input file.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146797.508023.patch
Type: text/x-patch
Size: 1735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230324/a04433fa/attachment.bin>


More information about the llvm-commits mailing list