summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/llvm-c-test/diagnostic.c
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
commitb64793999546ed8adebaeebd9d8345d18db8927d (patch)
tree4357c27b561d73b0e089727c6ed659f2ceff5f47 /gnu/llvm/tools/llvm-c-test/diagnostic.c
parentAdd support for UTF-8 DISPLAY-HINTs with octet length. For now only (diff)
downloadwireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.tar.xz
wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.zip
Remove LLVM 8.0.1 files.
Diffstat (limited to 'gnu/llvm/tools/llvm-c-test/diagnostic.c')
-rw-r--r--gnu/llvm/tools/llvm-c-test/diagnostic.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/gnu/llvm/tools/llvm-c-test/diagnostic.c b/gnu/llvm/tools/llvm-c-test/diagnostic.c
deleted file mode 100644
index 16d51747323..00000000000
--- a/gnu/llvm/tools/llvm-c-test/diagnostic.c
+++ /dev/null
@@ -1,89 +0,0 @@
-//===-- diagnostic.cpp - tool for testing libLLVM and llvm-c API ----------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the --test-diagnostic-handler command in llvm-c-test.
-//
-// This command uses the C API to read a module with a custom diagnostic
-// handler set to test the diagnostic handler functionality.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm-c-test.h"
-#include "llvm-c/BitReader.h"
-#include "llvm-c/Core.h"
-
-#include <stdio.h>
-
-static void diagnosticHandler(LLVMDiagnosticInfoRef DI, void *C) {
- fprintf(stderr, "Executing diagnostic handler\n");
-
- fprintf(stderr, "Diagnostic severity is of type ");
- switch (LLVMGetDiagInfoSeverity(DI)) {
- case LLVMDSError:
- fprintf(stderr, "error");
- break;
- case LLVMDSWarning:
- fprintf(stderr, "warning");
- break;
- case LLVMDSRemark:
- fprintf(stderr, "remark");
- break;
- case LLVMDSNote:
- fprintf(stderr, "note");
- break;
- }
- fprintf(stderr, "\n");
-
- (*(int *)C) = 1;
-}
-
-static int handlerCalled = 0;
-
-int llvm_test_diagnostic_handler(void) {
- LLVMContextRef C = LLVMGetGlobalContext();
- LLVMContextSetDiagnosticHandler(C, diagnosticHandler, &handlerCalled);
-
- if (LLVMContextGetDiagnosticHandler(C) != diagnosticHandler) {
- fprintf(stderr, "LLVMContext{Set,Get}DiagnosticHandler failed\n");
- return 1;
- }
-
- int *DC = (int *)LLVMContextGetDiagnosticContext(C);
- if (DC != &handlerCalled || *DC) {
- fprintf(stderr, "LLVMContextGetDiagnosticContext failed\n");
- return 1;
- }
-
- LLVMMemoryBufferRef MB;
- char *msg = NULL;
- if (LLVMCreateMemoryBufferWithSTDIN(&MB, &msg)) {
- fprintf(stderr, "Error reading file: %s\n", msg);
- LLVMDisposeMessage(msg);
- return 1;
- }
-
-
- LLVMModuleRef M;
- int Ret = LLVMGetBitcodeModule2(MB, &M);
- if (Ret) {
- // We do not return if the bitcode was invalid, as we want to test whether
- // the diagnostic handler was executed.
- fprintf(stderr, "Error parsing bitcode: %s\n", msg);
- }
-
- LLVMDisposeMemoryBuffer(MB);
-
- if (handlerCalled) {
- fprintf(stderr, "Diagnostic handler was called while loading module\n");
- } else {
- fprintf(stderr, "Diagnostic handler was not called while loading module\n");
- }
-
- return 0;
-}