From a2398d7da920b896001f385587e7f7d3366e5b17 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 9 Dec 2011 00:02:23 +0000 Subject: [PATCH] Separate the serialization library's diagnostics from the frontend's diagnostics. Conflating them was highly confusing and makes it harder to establish a firm layering separation between these two libraries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146207 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/CMakeLists.txt | 1 + include/clang/Basic/Diagnostic.td | 1 + .../clang/Basic/DiagnosticFrontendKinds.td | 44 -------------- include/clang/Basic/DiagnosticIDs.h | 17 +++--- .../Basic/DiagnosticSerializationKinds.td | 58 +++++++++++++++++++ .../Serialization/SerializationDiagnostic.h | 28 +++++++++ lib/Basic/DiagnosticIDs.cpp | 2 + lib/Serialization/ASTReader.cpp | 2 +- lib/Serialization/CMakeLists.txt | 2 +- 9 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 include/clang/Basic/DiagnosticSerializationKinds.td create mode 100644 include/clang/Serialization/SerializationDiagnostic.h diff --git a/include/clang/Basic/CMakeLists.txt b/include/clang/Basic/CMakeLists.txt index df49dc6a1c..3df88c7c4a 100644 --- a/include/clang/Basic/CMakeLists.txt +++ b/include/clang/Basic/CMakeLists.txt @@ -13,6 +13,7 @@ clang_diag_gen(Frontend) clang_diag_gen(Lex) clang_diag_gen(Parse) clang_diag_gen(Sema) +clang_diag_gen(Serialization) clang_tablegen(DiagnosticGroups.inc -gen-clang-diag-groups SOURCE Diagnostic.td TARGET ClangDiagnosticGroups) diff --git a/include/clang/Basic/Diagnostic.td b/include/clang/Basic/Diagnostic.td index 8ae69fef27..068cf08a5a 100644 --- a/include/clang/Basic/Diagnostic.td +++ b/include/clang/Basic/Diagnostic.td @@ -102,4 +102,5 @@ include "DiagnosticFrontendKinds.td" include "DiagnosticLexKinds.td" include "DiagnosticParseKinds.td" include "DiagnosticSemaKinds.td" +include "DiagnosticSerializationKinds.td" diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index ca15fee50b..ceef843409 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -56,19 +56,6 @@ def err_fe_unable_to_create_target : Error< "unable to create target: '%0'">; def err_fe_unable_to_interface_with_target : Error< "unable to interface with target machine">; -def err_fe_unable_to_read_pch_file : Error< - "unable to read PCH file: '%0'">; -def err_fe_not_a_pch_file : Error< - "input is not a PCH file: '%0'">; -def err_fe_pch_malformed : Error< - "malformed or corrupted PCH file: '%0'">, DefaultFatal; -def err_fe_pch_malformed_block : Error< - "malformed block record in PCH file: '%0'">, DefaultFatal; -def err_fe_pch_error_at_end_block : Error< - "error at end of module block in PCH file: '%0'">, DefaultFatal; -def err_fe_pch_file_modified : Error< - "file '%0' has been modified since the precompiled header was built">, - DefaultFatal; def err_fe_unable_to_open_output : Error< "unable to open output file '%0': '%1'">; def err_fe_unable_to_rename_temp : Error< @@ -115,38 +102,7 @@ def err_fe_invoking : Error<"error invoking%0: %1">, DefaultFatal; def err_relocatable_without_isysroot : Error< "must specify system root with -isysroot when building a relocatable " "PCH file">; -def warn_pch_target_triple : Error< - "PCH file was compiled for the target '%0' but the current translation " - "unit is being compiled for target '%1'">; -def err_pch_langopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in " - "PCH file but is currently %select{disabled|enabled}2">; -def err_pch_langopt_value_mismatch : Error< - "%0 differs in PCH file vs. current file">; - -def warn_pch_version_too_old : Error< - "PCH file uses an older PCH format that is no longer supported">; -def warn_pch_version_too_new : Error< - "PCH file uses a newer PCH format that cannot be read">; -def warn_pch_different_branch : Error< - "PCH file built from a different branch (%0) than the compiler (%1)">; -def warn_cmdline_conflicting_macro_def : Error< - "definition of the macro '%0' conflicts with the definition used to " - "build the precompiled header">; -def note_pch_macro_defined_as : Note< - "definition of macro '%0' in the precompiled header">; -def warn_cmdline_missing_macro_defs : Warning< - "macro definitions used to build the precompiled header are missing">; -def note_using_macro_def_from_pch : Note< - "using this macro definition from precompiled header">; -def warn_macro_name_used_in_pch : Error< - "definition of macro %0 conflicts with an identifier used in the " - "precompiled header">; -def warn_pch_compiler_options_mismatch : Error< - "compiler options used when building the precompiled header differ from " - "the options used when using the precompiled header">; -def err_not_a_pch_file : Error< - "'%0' does not appear to be a precompiled header file">, DefaultFatal; def warn_unknown_warning_option : Warning< "unknown warning option '%0'">, InGroup >; diff --git a/include/clang/Basic/DiagnosticIDs.h b/include/clang/Basic/DiagnosticIDs.h index fd31c17406..30fda59538 100644 --- a/include/clang/Basic/DiagnosticIDs.h +++ b/include/clang/Basic/DiagnosticIDs.h @@ -31,14 +31,15 @@ namespace clang { namespace diag { // Start position for diagnostics. enum { - DIAG_START_DRIVER = 300, - DIAG_START_FRONTEND = DIAG_START_DRIVER + 100, - DIAG_START_LEX = DIAG_START_FRONTEND + 120, - DIAG_START_PARSE = DIAG_START_LEX + 300, - DIAG_START_AST = DIAG_START_PARSE + 350, - DIAG_START_SEMA = DIAG_START_AST + 100, - DIAG_START_ANALYSIS = DIAG_START_SEMA + 3000, - DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS + 100 + DIAG_START_DRIVER = 300, + DIAG_START_FRONTEND = DIAG_START_DRIVER + 100, + DIAG_START_SERIALIZATION = DIAG_START_FRONTEND + 100, + DIAG_START_LEX = DIAG_START_SERIALIZATION + 120, + DIAG_START_PARSE = DIAG_START_LEX + 300, + DIAG_START_AST = DIAG_START_PARSE + 350, + DIAG_START_SEMA = DIAG_START_AST + 100, + DIAG_START_ANALYSIS = DIAG_START_SEMA + 3000, + DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS + 100 }; class CustomDiagInfo; diff --git a/include/clang/Basic/DiagnosticSerializationKinds.td b/include/clang/Basic/DiagnosticSerializationKinds.td new file mode 100644 index 0000000000..9a86ebfad8 --- /dev/null +++ b/include/clang/Basic/DiagnosticSerializationKinds.td @@ -0,0 +1,58 @@ +//==--- DiagnosticSerializationKinds.td - serialization diagnostics -------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +let Component = "Serialization" in { + +def err_fe_unable_to_read_pch_file : Error< + "unable to read PCH file: '%0'">; +def err_fe_not_a_pch_file : Error< + "input is not a PCH file: '%0'">; +def err_fe_pch_malformed : Error< + "malformed or corrupted PCH file: '%0'">, DefaultFatal; +def err_fe_pch_malformed_block : Error< + "malformed block record in PCH file: '%0'">, DefaultFatal; +def err_fe_pch_error_at_end_block : Error< + "error at end of module block in PCH file: '%0'">, DefaultFatal; +def err_fe_pch_file_modified : Error< + "file '%0' has been modified since the precompiled header was built">, + DefaultFatal; + +def warn_pch_target_triple : Error< + "PCH file was compiled for the target '%0' but the current translation " + "unit is being compiled for target '%1'">; +def err_pch_langopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in " + "PCH file but is currently %select{disabled|enabled}2">; +def err_pch_langopt_value_mismatch : Error< + "%0 differs in PCH file vs. current file">; + +def warn_pch_version_too_old : Error< + "PCH file uses an older PCH format that is no longer supported">; +def warn_pch_version_too_new : Error< + "PCH file uses a newer PCH format that cannot be read">; +def warn_pch_different_branch : Error< + "PCH file built from a different branch (%0) than the compiler (%1)">; +def warn_cmdline_conflicting_macro_def : Error< + "definition of the macro '%0' conflicts with the definition used to " + "build the precompiled header">; +def note_pch_macro_defined_as : Note< + "definition of macro '%0' in the precompiled header">; +def warn_cmdline_missing_macro_defs : Warning< + "macro definitions used to build the precompiled header are missing">; +def note_using_macro_def_from_pch : Note< + "using this macro definition from precompiled header">; +def warn_macro_name_used_in_pch : Error< + "definition of macro %0 conflicts with an identifier used in the " + "precompiled header">; +def warn_pch_compiler_options_mismatch : Error< + "compiler options used when building the precompiled header differ from " + "the options used when using the precompiled header">; + +def err_not_a_pch_file : Error< + "'%0' does not appear to be a precompiled header file">, DefaultFatal; +} diff --git a/include/clang/Serialization/SerializationDiagnostic.h b/include/clang/Serialization/SerializationDiagnostic.h new file mode 100644 index 0000000000..796a3282b5 --- /dev/null +++ b/include/clang/Serialization/SerializationDiagnostic.h @@ -0,0 +1,28 @@ +//===--- SerializationDiagnostic.h - Serialization Diagnostics -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_SERIALIZATIONDIAGNOSTIC_H +#define LLVM_CLANG_SERIALIZATIONDIAGNOSTIC_H + +#include "clang/Basic/Diagnostic.h" + +namespace clang { + namespace diag { + enum { +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\ + SFINAE,ACCESS,NOWERROR,SHOWINSYSHEADER,CATEGORY,BRIEF,FULL) ENUM, +#define SERIALIZATIONSTART +#include "clang/Basic/DiagnosticSerializationKinds.inc" +#undef DIAG + NUM_BUILTIN_SERIALIZATION_DIAGNOSTICS + }; + } // end namespace diag +} // end namespace clang + +#endif diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp index 6345ee22ea..1f7777873c 100644 --- a/lib/Basic/DiagnosticIDs.cpp +++ b/lib/Basic/DiagnosticIDs.cpp @@ -21,6 +21,7 @@ #include "clang/Lex/LexDiagnostic.h" #include "clang/Parse/ParseDiagnostic.h" #include "clang/Sema/SemaDiagnostic.h" +#include "clang/Serialization/SerializationDiagnostic.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/ErrorHandling.h" @@ -129,6 +130,7 @@ static const StaticDiagInfoRec StaticDiagInfo[] = { #include "clang/Basic/DiagnosticCommonKinds.inc" #include "clang/Basic/DiagnosticDriverKinds.inc" #include "clang/Basic/DiagnosticFrontendKinds.inc" +#include "clang/Basic/DiagnosticSerializationKinds.inc" #include "clang/Basic/DiagnosticLexKinds.inc" #include "clang/Basic/DiagnosticParseKinds.inc" #include "clang/Basic/DiagnosticASTKinds.inc" diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 236c2bd1f5..27dda857f5 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -14,9 +14,9 @@ #include "clang/Serialization/ASTReader.h" #include "clang/Serialization/ASTDeserializationListener.h" #include "clang/Serialization/ModuleManager.h" +#include "clang/Serialization/SerializationDiagnostic.h" #include "ASTCommon.h" #include "ASTReaderInternals.h" -#include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/Utils.h" #include "clang/Sema/Sema.h" #include "clang/Sema/Scope.h" diff --git a/lib/Serialization/CMakeLists.txt b/lib/Serialization/CMakeLists.txt index 5611056f01..62991a9f55 100644 --- a/lib/Serialization/CMakeLists.txt +++ b/lib/Serialization/CMakeLists.txt @@ -22,8 +22,8 @@ add_dependencies(clangSerialization ClangAttrList ClangAttrPCHRead ClangAttrPCHWrite - ClangDiagnosticFrontend ClangDiagnosticLex ClangDiagnosticSema + ClangDiagnosticSerialization ClangDeclNodes ClangStmtNodes)