Files
swift-mirror/include/swift/AST/DefineDiagnosticMacros.h
Owen Voorhees fdb6eabb0a [Diagnostics] Move macros used in diagnostic definitions to their own header
These were duplicated in 11 different files, and as they've gotten more
complex a few inconsistencies have snuck in. Sharing them should make future
changes easier and less bug-prone.
2020-04-14 18:10:30 -07:00

71 lines
1.8 KiB
C++

//===--- DefineDiagnosticMacros.h - Shared Diagnostic Macros ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros shared across diagnostic definition files.
//
//===----------------------------------------------------------------------===//
// Define macros
#ifdef DEFINE_DIAGNOSTIC_MACROS
#if !(defined(DIAG) || (defined(ERROR) && defined(WARNING) && defined(NOTE) && \
defined(REMARK)))
#error Must define either DIAG or the set {ERROR,WARNING,NOTE,REMARK}
#endif
#ifndef ERROR
#define ERROR(ID, Options, Text, Signature) \
DIAG(ERROR, ID, Options, Text, Signature)
#endif
#ifndef WARNING
#define WARNING(ID, Options, Text, Signature) \
DIAG(WARNING, ID, Options, Text, Signature)
#endif
#ifndef NOTE
#define NOTE(ID, Options, Text, Signature) \
DIAG(NOTE, ID, Options, Text, Signature)
#endif
#ifndef REMARK
#define REMARK(ID, Options, Text, Signature) \
DIAG(REMARK, ID, Options, Text, Signature)
#endif
#ifndef FIXIT
#define FIXIT(ID, Text, Signature)
#endif
#undef DEFINE_DIAGNOSTIC_MACROS
#endif
// Undefine macros
#ifdef UNDEFINE_DIAGNOSTIC_MACROS
#ifndef DIAG_NO_UNDEF
#if defined(DIAG)
#undef DIAG
#endif
#undef REMARK
#undef NOTE
#undef WARNING
#undef ERROR
#undef FIXIT
#endif
#undef UNDEFINE_DIAGNOSTIC_MACROS
#endif