Skip to content

Commit

Permalink
[clang-tblgen][NFC] renames Diagnostic.Text to Diagnostic.Summary
Browse files Browse the repository at this point in the history
The [Improving Clang's Diagnostics RFC][1] identifies eight broad fields
for Clang to surface, two of which are text-based. Since the current
diagnostics more closely map to the diagnostic summary (or headline), we
should rename them to ensure that there's no confusion when
Diagnostic.Reason is introduced in the near future.

[1]: https://discourse.llvm.org/t/rfc-improving-clang-s-diagnostics/62584

Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D135820
  • Loading branch information
cjdb committed Nov 21, 2022
1 parent f6d411f commit eb3f788
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/Diagnostic.td
Expand Up @@ -75,10 +75,10 @@ include "DiagnosticGroups.td"


// All diagnostics emitted by the compiler are an indirect subclass of this.
class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
class Diagnostic<string summary, DiagClass DC, Severity defaultmapping> {
/// Component is specified by the file with a big let directive.
string Component = ?;
string Text = text;
string Summary = summary;
DiagClass Class = DC;
SFINAEResponse SFINAE = SFINAE_Suppress;
bit AccessControl = 0;
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticCommonKinds.td
Expand Up @@ -269,7 +269,7 @@ def note_constexpr_invalid_template_arg : Note<
"%select{type_info object|string literal|temporary object|"
"predefined '%3' variable}2 is not allowed in a template argument">;
def err_constexpr_invalid_template_arg : Error<
note_constexpr_invalid_template_arg.Text>;
note_constexpr_invalid_template_arg.Summary>;

// Sema && Frontend
let CategoryName = "Inline Assembly Issue" in {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticFrontendKinds.td
Expand Up @@ -276,7 +276,7 @@ def warn_avx_calling_convention
: Warning<"AVX vector %select{return|argument}0 of type %1 without '%2' "
"enabled changes the ABI">,
InGroup<DiagGroup<"psabi">>;
def err_avx_calling_convention : Error<warn_avx_calling_convention.Text>;
def err_avx_calling_convention : Error<warn_avx_calling_convention.Summary>;

def err_alias_to_undefined : Error<
"%select{alias|ifunc}0 must point to a defined "
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/DiagnosticLexKinds.td
Expand Up @@ -461,7 +461,7 @@ def ext_pp_gnu_line_directive : Extension<
def err_pp_invalid_directive : Error<
"invalid preprocessing directive%select{|, did you mean '#%1'?}0">;
def warn_pp_invalid_directive : Warning<
err_pp_invalid_directive.Text>, InGroup<DiagGroup<"unknown-directives">>;
err_pp_invalid_directive.Summary>, InGroup<DiagGroup<"unknown-directives">>;
def err_pp_directive_required : Error<
"%0 must be used within a preprocessing directive">;
def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
Expand Down Expand Up @@ -704,7 +704,7 @@ def ext_pp_bad_paste_ms : ExtWarn<
def err_pp_operator_used_as_macro_name : Error<
"C++ operator %0 (aka %1) used as a macro name">;
def ext_pp_operator_used_as_macro_name : Extension<
err_pp_operator_used_as_macro_name.Text>, InGroup<MicrosoftCppMacro>;
err_pp_operator_used_as_macro_name.Summary>, InGroup<MicrosoftCppMacro>;
def err_pp_illegal_floating_literal : Error<
"floating point literal in preprocessor expression">;
def err_pp_line_requires_integer : Error<
Expand Down
94 changes: 47 additions & 47 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clang/test/TableGen/DiagnosticBase.inc
Expand Up @@ -67,10 +67,10 @@ class InGroup<DiagGroup G> { DiagGroup Group = G; }
include "DiagnosticDocs.inc"

// All diagnostics emitted by the compiler are an indirect subclass of this.
class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
class Diagnostic<string summary, DiagClass DC, Severity defaultmapping> {
/// Component is specified by the file with a big let directive.
string Component = ?;
string Text = text;
string Summary = summary;
DiagClass Class = DC;
SFINAEResponse SFINAE = SFINAE_Suppress;
bit AccessControl = 0;
Expand Down
6 changes: 3 additions & 3 deletions clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
Expand Up @@ -1165,7 +1165,7 @@ std::vector<std::string>
DiagnosticTextBuilder::buildForDocumentation(StringRef Severity,
const Record *R) {
EvaluatingRecordGuard Guard(&EvaluatingRecord, R);
StringRef Text = R->getValueAsString("Text");
StringRef Text = R->getValueAsString("Summary");

DiagText D(*this, Text);
TextPiece *Prefix = D.New<TextPiece>(Severity, Severity);
Expand All @@ -1184,7 +1184,7 @@ DiagnosticTextBuilder::buildForDocumentation(StringRef Severity,

std::string DiagnosticTextBuilder::buildForDefinition(const Record *R) {
EvaluatingRecordGuard Guard(&EvaluatingRecord, R);
StringRef Text = R->getValueAsString("Text");
StringRef Text = R->getValueAsString("Summary");
DiagText D(*this, Text);
std::string Result;
DiagTextPrinter{*this, Result}.Visit(D.Root);
Expand Down Expand Up @@ -1702,7 +1702,7 @@ void writeHeader(StringRef Str, raw_ostream &OS, char Kind = '-') {

void writeDiagnosticText(DiagnosticTextBuilder &Builder, const Record *R,
StringRef Role, raw_ostream &OS) {
StringRef Text = R->getValueAsString("Text");
StringRef Text = R->getValueAsString("Summary");
if (Text == "%0")
OS << "The text of this diagnostic is not controlled by Clang.\n\n";
else {
Expand Down

0 comments on commit eb3f788

Please sign in to comment.