Author: David Goldman Date: 2020-01-09T11:02:58-05:00 New Revision: ea9888b8f6f20887647b77ebf5864d647fd2ea44
URL: https://github.com/llvm/llvm-project/commit/ea9888b8f6f20887647b77ebf5864d647fd2ea44 DIFF: https://github.com/llvm/llvm-project/commit/ea9888b8f6f20887647b77ebf5864d647fd2ea44.diff LOG: [clangd] Respect `--sysroot` argument if it is set Summary: - Since `--sysroot` is a superset of the `-isysroot` argument, we shouldn't add the `-isysroot` if we detect a `--sysroot` flag. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72415 Added: Modified: clang-tools-extra/clangd/CompileCommands.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp index b1eca02813b3..f11b1236803c 100644 --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -155,7 +155,9 @@ void CommandMangler::adjust(std::vector<std::string> &Cmd) const { 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