Skip to content

Commit 0fe369a

Browse files
committed
Strip preceeding -Xclang when stripping -fcolor-diagnostics or -fdiagnostics-color
Summary: Fixes clangd/clangd#279. We were removing the color options but not the preceeding -Xclang which causes errors since the -Xclang would now apply to the next option in the list of options. Now, when removing a color option, we check if there was a preceeding -Xclang and remove it as well. Patch By @DaanDeMeyer ! Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: ilya-biryukov, usaxena95 Differential Revision: https://reviews.llvm.org/D75019 (cherry picked from commit da236f2)
1 parent 002af01 commit 0fe369a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clang/lib/Tooling/ArgumentsAdjusters.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
4242
if (!Arg.startswith("-fcolor-diagnostics") &&
4343
!Arg.startswith("-fdiagnostics-color"))
4444
AdjustedArgs.push_back(Args[i]);
45+
// If we strip a color option, make sure we strip any preceeding `-Xclang`
46+
// option as well.
47+
// FIXME: This should be added to most argument adjusters!
48+
else if (!AdjustedArgs.empty() && AdjustedArgs.back() == "-Xclang")
49+
AdjustedArgs.pop_back();
50+
4551
if (Arg == "-fsyntax-only")
4652
HasSyntaxOnly = true;
4753
}

0 commit comments

Comments
 (0)