[PATCH] D106789: [clang][Driver] Expose driver mode detection logic

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 27 05:12:28 PDT 2021


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/include/clang/Driver/Driver.h:643
 
+/// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p
+/// Args doesn't mention one explicitly, tries to deduce from `ProgName`.
----------------
List the "good" values, and explicitly mention that it need not be one?


================
Comment at: clang/lib/Driver/Driver.cpp:1018
   // how other options are parsed.
-  ParseDriverMode(ClangExecutable, ArgList.slice(1));
+  setDriverMode(getDriverMode(ClangExecutable, ArgList.slice(1)));
 
----------------
can we do this only if we have a value to set to, and remove the "" special case?


================
Comment at: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp:149
         TmpArgv.push_back(S.c_str());
+      ClangCLMode = !TmpArgv.empty() &&
+                    driver::getDriverMode(TmpArgv.front(),
----------------
could consider adding isClangCL(StringRef)... up to you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106789



More information about the cfe-commits mailing list