[all-commits] [llvm/llvm-project] f489fb: [clangd] Fix sysroot flag handling in CommandMangl...

Kon via All-commits all-commits at lists.llvm.org
Fri Jan 12 00:11:51 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f489fb3d75aaedf6f056113370a8b3b8659b9f17
      https://github.com/llvm/llvm-project/commit/f489fb3d75aaedf6f056113370a8b3b8659b9f17
  Author: Kon <kinsei0916 at gmail.com>
  Date:   2024-01-12 (Fri, 12 Jan 2024)

  Changed paths:
    M clang-tools-extra/clangd/CompileCommands.cpp
    M clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

  Log Message:
  -----------
  [clangd] Fix sysroot flag handling in CommandMangler to prevent duplicates (#75694)

CommandMangler should guess the sysroot path of the host system and add
that through `-isysroot` flag only when there is no `--sysroot` or
`-isysroot` flag in the original compile command to avoid duplicate
sysroot.

Previously, CommandMangler appropriately avoided adding a guessed
sysroot flag if the original command had an argument in the form of
`--sysroot=<sysroot>`, `--sysroot <sysroot>`, or `-isysroot <sysroot>`.
However, when presented as `-isysroot<sysroot>` (without spaces after
`-isysroot`), CommandMangler mistakenly appended the guessed sysroot
flag, resulting in duplicated sysroot in the final command.

This commit fixes it, ensuring the final command has no duplicate
sysroot flags. Also adds unit tests for this fix.




More information about the All-commits mailing list