summaryrefslogtreecommitdiffstats
path: root/unittests/Tooling/ToolingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Tooling/ToolingTest.cpp')
-rw-r--r--unittests/Tooling/ToolingTest.cpp42
1 files changed, 35 insertions, 7 deletions
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp
index 186463f80a..34f68a6aeb 100644
--- a/unittests/Tooling/ToolingTest.cpp
+++ b/unittests/Tooling/ToolingTest.cpp
@@ -1,9 +1,8 @@
//===- unittest/Tooling/ToolingTest.cpp - Tooling unit tests --------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -383,7 +382,7 @@ TEST(ClangToolTest, ArgumentAdjusters) {
ArgumentsAdjuster CheckSyntaxOnlyAdjuster =
[&Found, &Ran](const CommandLineArguments &Args, StringRef /*unused*/) {
Ran = true;
- if (std::find(Args.begin(), Args.end(), "-fsyntax-only") != Args.end())
+ if (llvm::is_contained(Args, "-fsyntax-only"))
Found = true;
return Args;
};
@@ -441,8 +440,7 @@ TEST(ClangToolTest, StripDependencyFileAdjuster) {
Tool.run(Action.get());
auto HasFlag = [&FinalArgs](const std::string &Flag) {
- return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
- FinalArgs.end();
+ return llvm::find(FinalArgs, Flag) != FinalArgs.end();
};
EXPECT_FALSE(HasFlag("-MD"));
EXPECT_FALSE(HasFlag("-MMD"));
@@ -450,6 +448,36 @@ TEST(ClangToolTest, StripDependencyFileAdjuster) {
EXPECT_TRUE(HasFlag("-w"));
}
+// Check getClangStripPluginsAdjuster strips plugin related args.
+TEST(ClangToolTest, StripPluginsAdjuster) {
+ FixedCompilationDatabase Compilations(
+ "/", {"-Xclang", "-add-plugin", "-Xclang", "random-plugin"});
+
+ ClangTool Tool(Compilations, std::vector<std::string>(1, "/a.cc"));
+ Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+ std::unique_ptr<FrontendActionFactory> Action(
+ newFrontendActionFactory<SyntaxOnlyAction>());
+
+ CommandLineArguments FinalArgs;
+ ArgumentsAdjuster CheckFlagsAdjuster =
+ [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
+ FinalArgs = Args;
+ return Args;
+ };
+ Tool.clearArgumentsAdjusters();
+ Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
+ Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+ Tool.run(Action.get());
+
+ auto HasFlag = [&FinalArgs](const std::string &Flag) {
+ return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+ };
+ EXPECT_FALSE(HasFlag("-Xclang"));
+ EXPECT_FALSE(HasFlag("-add-plugin"));
+ EXPECT_FALSE(HasFlag("-random-plugin"));
+}
+
namespace {
/// Find a target name such that looking for it in TargetRegistry by that name
/// returns the same target. We expect that there is at least one target