[clang] Add support for sysroot-relative system header search paths (PR #82084)

Evan Wilde via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 13:19:52 PDT 2024


================
@@ -3218,6 +3218,21 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
   bool IsIndexHeaderMap = false;
   bool IsSysrootSpecified =
       Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
+
+  // Expand a leading `=` to the sysroot if one was passed (and it's not a
+  // framework flag).
+  auto ConvertHeaderPath = [IsSysrootSpecified,
+                            &Opts](const llvm::opt::Arg *A,
+                                   bool IsFramework = false) -> std::string {
+    if (IsSysrootSpecified && !IsFramework && A->getValue()[0] == '=') {
----------------
etcwilde wrote:

Maybe? The thing coming from `Args.filtered` should be populated though? Even if it isn't, we shouldn't be entering the `for`-loop though. Perhaps `Args.filtered` should result in iterator that emits a const reference? That seems like a bigger, unrelated change though.

Added an assert and a test case. The arg parser will error out earlier if nothing is passed to `-I`; `argument to '-I' is missing`. Is that sufficient?

https://github.com/llvm/llvm-project/pull/82084


More information about the cfe-commits mailing list