From 741602461d2079c682916bce6701c39acb08bbd3 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Fri, 28 Feb 2014 09:11:08 +0000 Subject: Add 'remark' diagnostic type in 'clang' A 'remark' is information that is not an error or a warning, but rather some additional information provided to the user. In contrast to a 'note' a 'remark' is an independent diagnostic, whereas a 'note' always depends on another diagnostic. A typical use case for remark nodes is information provided to the user, e.g. information provided by the vectorizer about loops that have been vectorized. This patch provides the initial implementation of 'remarks'. It includes the actual definiton of the remark nodes, their printing as well as basic parameter handling. We are reusing the existing diagnostic parameters which means a remark can be enabled with normal '-Wdiagnostic-name' flags and can be upgraded to an error using '-Werror=diagnostic-name'. '-Werror' alone does not upgrade remarks. This patch is by intention minimal in terms of parameter handling. More experience and more discussions will most likely lead to further enhancements in the parameter handling. llvm-svn: 202475 --- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'clang/utils/TableGen/ClangDiagnosticsEmitter.cpp') diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index db159d102cd..2c265aff62c 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -472,6 +472,11 @@ static bool isError(const Record &Diag) { return ClsName == "CLASS_ERROR"; } +static bool isRemark(const Record &Diag) { + const std::string &ClsName = Diag.getValueAsDef("Class")->getName(); + return ClsName == "CLASS_REMARK"; +} + /// ClangDiagsDefsEmitter - The top-level class emits .def files containing /// declarations of Clang diagnostics. namespace clang { @@ -518,6 +523,14 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, } } + // Check that all remarks have an associated diagnostic group. + if (isRemark(R)) { + if (!isa(R.getValueInit("Group"))) { + PrintFatalError(R.getLoc(), "Error " + R.getName() + + " not in any diagnostic group"); + } + } + // Filter by component. if (!Component.empty() && Component != R.getValueAsString("Component")) continue; -- cgit v1.2.3