summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling/ToolingTest.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-07-02 10:45:53 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-07-02 10:45:53 +0000
commit7d719b75eaf58162d44f11497a0d4765cd19ab55 (patch)
tree4a54c0dddc527985371288960fc87241b453007e /clang/unittests/Tooling/ToolingTest.cpp
parent2915b3988f4445244c3c09414500232b3ccaa416 (diff)
downloadbcm5719-llvm-7d719b75eaf58162d44f11497a0d4765cd19ab55.tar.gz
bcm5719-llvm-7d719b75eaf58162d44f11497a0d4765cd19ab55.zip
[clang][ArgumentAdjusters] Do not add fsyntax-only if already exists
Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64063 llvm-svn: 364904
Diffstat (limited to 'clang/unittests/Tooling/ToolingTest.cpp')
-rw-r--r--clang/unittests/Tooling/ToolingTest.cpp27
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(
OpenPOWER on IntegriCloud