diff options
Diffstat (limited to 'clang/unittests/Tooling/ToolingTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/ToolingTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index 34f68a6aeb6..f9f4de3d9a1 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -400,6 +400,33 @@ TEST(ClangToolTest, ArgumentAdjusters) { EXPECT_FALSE(Found); } +TEST(ClangToolTest, NoDoubleSyntaxOnly) { + FixedCompilationDatabase Compilations("/", {"-fsyntax-only"}); + + ClangTool Tool(Compilations, std::vector<std::string>(1, "/a.cc")); + Tool.mapVirtualFile("/a.cc", "void a() {}"); + + std::unique_ptr<FrontendActionFactory> Action( + newFrontendActionFactory<SyntaxOnlyAction>()); + + size_t SyntaxOnlyCount = 0; + ArgumentsAdjuster CheckSyntaxOnlyAdjuster = + [&SyntaxOnlyCount](const CommandLineArguments &Args, + StringRef /*unused*/) { + for (llvm::StringRef Arg : Args) { + if (Arg == "-fsyntax-only") + ++SyntaxOnlyCount; + } + return Args; + }; + + Tool.clearArgumentsAdjusters(); + Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); + Tool.appendArgumentsAdjuster(CheckSyntaxOnlyAdjuster); + Tool.run(Action.get()); + EXPECT_EQ(SyntaxOnlyCount, 1U); +} + TEST(ClangToolTest, BaseVirtualFileSystemUsage) { FixedCompilationDatabase Compilations("/", std::vector<std::string>()); llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem( |