diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -220,10 +220,13 @@ ArgList = OptTable.ParseArgs( llvm::makeArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount, /*FlagsToInclude=*/ - IsCLMode ? (driver::options::CLOption | driver::options::CoreOption) + IsCLMode ? (driver::options::CLOption | driver::options::CoreOption | + driver::options::CLDXCOption) : /*everything*/ 0, /*FlagsToExclude=*/driver::options::NoDriverOption | - (IsCLMode ? 0 : driver::options::CLOption)); + (IsCLMode + ? 0 + : (driver::options::CLOption | driver::options::CLDXCOption))); llvm::SmallVector IndicesToDrop; // Having multiple architecture options (e.g. when building fat binaries) diff --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp --- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp +++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp @@ -415,6 +415,19 @@ // Make sure we don't crash. Mangler.adjust(Args, "foo.cc"); } + +TEST(CommandMangler, PathsAsPositional) { + const auto Mangler = CommandMangler::forTests(); + std::vector Args = { + "clang", + "--driver-mode=cl", + "-I", + "foo", + }; + // Make sure we don't crash. + Mangler.adjust(Args, "a.cc"); + EXPECT_THAT(Args, Contains("foo")); +} } // namespace } // namespace clangd } // namespace clang diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp --- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp +++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp @@ -165,8 +165,8 @@ const unsigned OldPos = Pos; std::unique_ptr Arg(OptTable.ParseOneArg( ArgList, Pos, - /* Include */ ClangCLMode ? CoreOption | CLOption : 0, - /* Exclude */ ClangCLMode ? 0 : CLOption)); + /* Include */ ClangCLMode ? CoreOption | CLOption | CLDXCOption : 0, + /* Exclude */ ClangCLMode ? 0 : CLOption | CLDXCOption)); if (!Arg) continue;