dgoldman created this revision.
dgoldman added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

- Since `--sysroot` is a superset of the `-isysroot` argument, we shouldn't add 
the `-isysroot` if we detect a `--sysroot` flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72415

Files:
  clang-tools-extra/clangd/CompileCommands.cpp


Index: clang-tools-extra/clangd/CompileCommands.cpp
===================================================================
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -155,7 +155,9 @@
   if (ResourceDir && !Has("-resource-dir"))
     Cmd.push_back(("-resource-dir=" + *ResourceDir));
 
-  if (Sysroot && !Has("-isysroot")) {
+  // Don't set `-isysroot` if it is already set or if `--sysroot` is set.
+  // `--sysroot` is a superset of the `-isysroot` argument.
+  if (Sysroot && !Has("-isysroot") && !Has("--sysroot")) {
     Cmd.push_back("-isysroot");
     Cmd.push_back(*Sysroot);
   }


Index: clang-tools-extra/clangd/CompileCommands.cpp
===================================================================
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -155,7 +155,9 @@
   if (ResourceDir && !Has("-resource-dir"))
     Cmd.push_back(("-resource-dir=" + *ResourceDir));
 
-  if (Sysroot && !Has("-isysroot")) {
+  // Don't set `-isysroot` if it is already set or if `--sysroot` is set.
+  // `--sysroot` is a superset of the `-isysroot` argument.
+  if (Sysroot && !Has("-isysroot") && !Has("--sysroot")) {
     Cmd.push_back("-isysroot");
     Cmd.push_back(*Sysroot);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D72415: [cl... David Goldman via Phabricator via cfe-commits

Reply via email to