[llvm-branch-commits] [clang] 0fe369a - Strip preceeding -Xclang when stripping -fcolor-diagnostics or -fdiagnostics-color

Kadir Cetinkaya via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 26 00:38:14 PST 2020


Author: Kadir Cetinkaya
Date: 2020-02-26T09:28:39+01:00
New Revision: 0fe369ad5ff69394b9076b1a679502c3993488d1

URL: https://github.com/llvm/llvm-project/commit/0fe369ad5ff69394b9076b1a679502c3993488d1
DIFF: https://github.com/llvm/llvm-project/commit/0fe369ad5ff69394b9076b1a679502c3993488d1.diff

LOG: Strip preceeding -Xclang when stripping -fcolor-diagnostics or -fdiagnostics-color

Summary: Fixes https://github.com/clangd/clangd/issues/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 da236f235028c82c2f0e00eea1f6f9c689bcae4a)

Added: 
    

Modified: 
    clang/lib/Tooling/ArgumentsAdjusters.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index a609e4ed2469..ec15311d4bac 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -42,6 +42,12 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
       if (!Arg.startswith("-fcolor-diagnostics") &&
           !Arg.startswith("-fdiagnostics-color"))
         AdjustedArgs.push_back(Args[i]);
+      // If we strip a color option, make sure we strip any preceeding `-Xclang`
+      // option as well.
+      // FIXME: This should be added to most argument adjusters!
+      else if (!AdjustedArgs.empty() && AdjustedArgs.back() == "-Xclang")
+        AdjustedArgs.pop_back();
+
       if (Arg == "-fsyntax-only")
         HasSyntaxOnly = true;
     }


        


More information about the llvm-branch-commits mailing list