aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWenju He <wenju.he@intel.com>2025-05-30 07:20:37 +0000
committerGitHub <noreply@github.com>2025-05-30 15:20:37 +0800
commitc7b8d6e1dcb0a277f95496cbc6bb27143afb80a6 (patch)
treef51d187a4a4ca3d86c501434a7ebe66c70d0a60f
parentb71255705bab3bba231c045a9fd101df438a7a72 (diff)
downloadllvm-c7b8d6e1dcb0a277f95496cbc6bb27143afb80a6.zip
llvm-c7b8d6e1dcb0a277f95496cbc6bb27143afb80a6.tar.gz
llvm-c7b8d6e1dcb0a277f95496cbc6bb27143afb80a6.tar.bz2
[Clang] Add resource_dir_EQ flag to CC1Option group (#140870)
This PR fixes ClangTool error in -cc1 mode in function injectResourceDir: error: unknown argument: '-resource-dir=
-rw-r--r--clang/include/clang/Driver/Options.td2
-rw-r--r--clang/unittests/Tooling/ToolingTest.cpp19
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index b66cc15..6e72576 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5897,7 +5897,7 @@ def resource_dir : Separate<["-"], "resource-dir">,
HelpText<"The directory which holds the compiler resource files">,
MarshallingInfoString<HeaderSearchOpts<"ResourceDir">>;
def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption]>,
- Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
+ Visibility<[ClangOption, CC1Option, CLOption, DXCOption, FlangOption]>,
Alias<resource_dir>;
def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>,
Visibility<[ClangOption, FlangOption]>;
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp
index 32af4b6..562f87d 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -771,6 +771,25 @@ TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
EXPECT_EQ(0, Tool.run(Action.get()));
}
+// Check -cc1 command doesn't fail.
+TEST(ClangToolTest, CC1Arg) {
+ FixedCompilationDatabase Compilations("/", {"-cc1"});
+ llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
+ new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+ llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
+ new llvm::vfs::InMemoryFileSystem);
+ OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
+ InMemoryFileSystem->addFile(
+ "a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
+
+ ClangTool Tool(Compilations, std::vector<std::string>(1, "a.cpp"),
+ std::make_shared<PCHContainerOperations>(), OverlayFileSystem);
+ std::unique_ptr<FrontendActionFactory> Action(
+ newFrontendActionFactory<SyntaxOnlyAction>());
+ EXPECT_EQ(0, Tool.run(Action.get()));
+}
+
// Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
TEST(ClangToolTest, StripDependencyFileAdjuster) {
FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});