[PATCH] D73500: [driver] Add a -builtininc flag that lets Darwin driver include Clang builtin headers even with -nostdinc

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 14:43:14 PST 2020


dexonsmith requested changes to this revision.
dexonsmith added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/include/clang/Driver/Options.td:503-504
 def bind__at__load : Flag<["-"], "bind_at_load">;
+def builtininc : Flag<["-"], "builtininc">,
+  HelpText<"Enable builtin #include directories even when -nostdinc is used">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
----------------
I think `-ibuiltininc` might be better, since we already have lots of options that start with `-i` related to include paths.  Please also clarify in the HelpText that this overrules `-nostdinc` even if `-nostdinc` comes later.


================
Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:1883-1888
   // Add the Clang builtin headers (<resource>/include)
-  if (!NoStdInc && !NoBuiltinInc) {
+  if (!(NoStdInc && !ForceBuiltinInc) && !NoBuiltinInc) {
     SmallString<128> P(D.ResourceDir);
     llvm::sys::path::append(P, "include");
     addSystemInclude(DriverArgs, CC1Args, P);
   }
----------------
It's probably better to let `-ibuiltininc` and `-nobuiltininc` cancel each other out, via a "last one wins" rule.  If you agree, consider documenting the behaviour also in the HelpText.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73500





More information about the cfe-commits mailing list