Skip to content

Commit c7b8d6e

Browse files
authored
[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=
1 parent b712557 commit c7b8d6e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5897,7 +5897,7 @@ def resource_dir : Separate<["-"], "resource-dir">,
58975897
HelpText<"The directory which holds the compiler resource files">,
58985898
MarshallingInfoString<HeaderSearchOpts<"ResourceDir">>;
58995899
def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption]>,
5900-
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
5900+
Visibility<[ClangOption, CC1Option, CLOption, DXCOption, FlangOption]>,
59015901
Alias<resource_dir>;
59025902
def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>,
59035903
Visibility<[ClangOption, FlangOption]>;

clang/unittests/Tooling/ToolingTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,25 @@ TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
771771
EXPECT_EQ(0, Tool.run(Action.get()));
772772
}
773773

774+
// Check -cc1 command doesn't fail.
775+
TEST(ClangToolTest, CC1Arg) {
776+
FixedCompilationDatabase Compilations("/", {"-cc1"});
777+
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
778+
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
779+
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
780+
new llvm::vfs::InMemoryFileSystem);
781+
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
782+
783+
InMemoryFileSystem->addFile(
784+
"a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
785+
786+
ClangTool Tool(Compilations, std::vector<std::string>(1, "a.cpp"),
787+
std::make_shared<PCHContainerOperations>(), OverlayFileSystem);
788+
std::unique_ptr<FrontendActionFactory> Action(
789+
newFrontendActionFactory<SyntaxOnlyAction>());
790+
EXPECT_EQ(0, Tool.run(Action.get()));
791+
}
792+
774793
// Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
775794
TEST(ClangToolTest, StripDependencyFileAdjuster) {
776795
FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});

0 commit comments

Comments
 (0)