summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2017-01-24 08:32:59 +0000
committerpatrick <patrick@openbsd.org>2017-01-24 08:32:59 +0000
commit53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch)
tree7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp
parentIn preparation of compiling our kernels with -ffreestanding, explicitly map (diff)
downloadwireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz
wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp')
-rw-r--r--gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp b/gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp
index 10ac0c33ed8..68b5ed21059 100644
--- a/gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp
+++ b/gnu/llvm/tools/clang/unittests/Tooling/ToolingTest.cpp
@@ -18,8 +18,9 @@
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Config/llvm-config.h"
-#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
#include "gtest/gtest.h"
#include <algorithm>
#include <string>
@@ -331,6 +332,44 @@ TEST(runToolOnCodeWithArgs, TestNoDepFile) {
EXPECT_FALSE(llvm::sys::fs::remove(DepFilePath.str()));
}
+struct CheckColoredDiagnosticsAction : public clang::ASTFrontendAction {
+ CheckColoredDiagnosticsAction(bool ShouldShowColor)
+ : ShouldShowColor(ShouldShowColor) {}
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef) override {
+ if (Compiler.getDiagnosticOpts().ShowColors != ShouldShowColor)
+ Compiler.getDiagnostics().Report(
+ Compiler.getDiagnostics().getCustomDiagID(
+ DiagnosticsEngine::Fatal,
+ "getDiagnosticOpts().ShowColors != ShouldShowColor"));
+ return llvm::make_unique<ASTConsumer>();
+ }
+
+private:
+ bool ShouldShowColor = true;
+};
+
+TEST(runToolOnCodeWithArgs, DiagnosticsColor) {
+
+ EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), "",
+ {"-fcolor-diagnostics"}));
+ EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false),
+ "", {"-fno-color-diagnostics"}));
+ EXPECT_TRUE(
+ runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), "",
+ {"-fno-color-diagnostics", "-fcolor-diagnostics"}));
+ EXPECT_TRUE(
+ runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false), "",
+ {"-fcolor-diagnostics", "-fno-color-diagnostics"}));
+ EXPECT_TRUE(runToolOnCodeWithArgs(
+ new CheckColoredDiagnosticsAction(true), "",
+ {"-fno-color-diagnostics", "-fdiagnostics-color=always"}));
+
+ // Check that this test would fail if ShowColors is not what it should.
+ EXPECT_FALSE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false),
+ "", {"-fcolor-diagnostics"}));
+}
+
TEST(ClangToolTest, ArgumentAdjusters) {
FixedCompilationDatabase Compilations("/", std::vector<std::string>());