forked from OSchip/llvm-project
Initial work to improve documentation for Clang's diagnostics, from Matthieu Monrocq
llvm-svn: 129614
This commit is contained in:
parent
f29216072e
commit
46ce91a964
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define ASTSTART
|
||||
#include "clang/Basic/DiagnosticASTKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define ANALYSISSTART
|
||||
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -17,6 +17,10 @@ clang_tablegen(DiagnosticGroups.inc -gen-clang-diag-groups
|
|||
SOURCE Diagnostic.td
|
||||
TARGET ClangDiagnosticGroups)
|
||||
|
||||
clang_tablegen(DiagnosticIndexName.inc -gen-clang-diags-index-name
|
||||
SOURCE Diagnostic.td
|
||||
TARGET ClangDiagnosticIndexName)
|
||||
|
||||
clang_tablegen(AttrList.inc -gen-clang-attr-list
|
||||
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
SOURCE Attr.td
|
||||
|
|
|
@ -60,6 +60,8 @@ class Diagnostic<string text, DiagClass DC, DiagMapping defaultmapping> {
|
|||
DiagMapping DefaultMapping = defaultmapping;
|
||||
DiagGroup Group;
|
||||
string CategoryName = "";
|
||||
string Brief = "";
|
||||
string Explanation = "";
|
||||
}
|
||||
|
||||
class Error<string str> : Diagnostic<str, CLASS_ERROR, MAP_ERROR>;
|
||||
|
@ -77,6 +79,12 @@ class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; }
|
|||
class NoSFINAE { bit SFINAE = 0; }
|
||||
class AccessControl { bit AccessControl = 1; }
|
||||
|
||||
class Brief<string str> { string Brief = str; }
|
||||
class FullExplanation<string brief, string full> {
|
||||
string Brief = brief;
|
||||
string Explanation = full;
|
||||
}
|
||||
|
||||
// Definitions for Diagnostics.
|
||||
include "DiagnosticASTKinds.td"
|
||||
include "DiagnosticAnalysisKinds.td"
|
||||
|
|
|
@ -42,7 +42,8 @@ namespace clang {
|
|||
|
||||
// Get typedefs for common diagnostics.
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#include "clang/Basic/DiagnosticCommonKinds.inc"
|
||||
NUM_BUILTIN_COMMON_DIAGNOSTICS
|
||||
#undef DIAG
|
||||
|
@ -99,7 +100,7 @@ public:
|
|||
/// issue.
|
||||
const char *getDescription(unsigned DiagID) const;
|
||||
|
||||
/// isNoteWarningOrExtension - Return true if the unmapped diagnostic
|
||||
/// isBuiltinWarningOrExtension - Return true if the unmapped diagnostic
|
||||
/// level of the specified diagnostic ID is a Warning or Extension.
|
||||
/// This only works on builtin diagnostics, not custom ones, and is not legal to
|
||||
/// call on NOTEs.
|
||||
|
@ -130,7 +131,7 @@ public:
|
|||
/// the diagnostic, this returns null.
|
||||
static const char *getWarningOptionForDiag(unsigned DiagID);
|
||||
|
||||
/// getWarningOptionForDiag - Return the category number that a specified
|
||||
/// getCategoryNumberForDiag - Return the category number that a specified
|
||||
/// DiagID belongs to, or 0 if no category.
|
||||
static unsigned getCategoryNumberForDiag(unsigned DiagID);
|
||||
|
||||
|
@ -174,6 +175,20 @@ public:
|
|||
/// are not SFINAE errors.
|
||||
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID);
|
||||
|
||||
/// getName - Given a diagnostic ID, return its name
|
||||
static const char *getName(unsigned DiagID);
|
||||
|
||||
/// getIdFromName - Given a diagnostic name, return its ID, or 0
|
||||
static unsigned getIdFromName(char const *Name);
|
||||
|
||||
/// getBriefExplanation - Given a diagnostic ID, return a brief explanation
|
||||
/// of the issue
|
||||
static const char *getBriefExplanation(unsigned DiagID);
|
||||
|
||||
/// getFullExplanation - Given a diagnostic ID, return a full explanation
|
||||
/// of the issue
|
||||
static const char *getFullExplanation(unsigned DiagID);
|
||||
|
||||
private:
|
||||
/// setDiagnosticGroupMapping - Change an entire diagnostic group (e.g.
|
||||
/// "unknown-pragmas" to have the specified mapping. This returns true and
|
||||
|
|
|
@ -4,7 +4,7 @@ BUILT_SOURCES = \
|
|||
DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \
|
||||
DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \
|
||||
DiagnosticParseKinds.inc DiagnosticSemaKinds.inc \
|
||||
DiagnosticGroups.inc AttrList.inc arm_neon.inc \
|
||||
DiagnosticIndexName.inc DiagnosticGroups.inc AttrList.inc arm_neon.inc \
|
||||
Version.inc
|
||||
|
||||
TABLEGEN_INC_FILES_COMMON = 1
|
||||
|
@ -33,6 +33,10 @@ $(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN)
|
|||
$(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
|
||||
|
||||
$(ObjDir)/DiagnosticIndexName.inc.tmp : Diagnostic.td $(INPUT_TDS) $(TBLGEN) $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang diagnostic name index with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-diags-index-name -o $(call SYSPATH, $@) $<
|
||||
|
||||
$(ObjDir)/DiagnosticGroups.inc.tmp : Diagnostic.td DiagnosticGroups.td $(INPUT_TDS) $(TBLGEN) $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang diagnostic groups with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-diag-groups -o $(call SYSPATH, $@) $<
|
||||
|
|
|
@ -230,8 +230,10 @@ def fdiagnostics_print_source_range_info : Flag<"-fdiagnostics-print-source-rang
|
|||
HelpText<"Print source range spans in numeric form">;
|
||||
def fdiagnostics_parseable_fixits : Flag<"-fdiagnostics-parseable-fixits">,
|
||||
HelpText<"Print fix-its in machine parseable form">;
|
||||
def fdiagnostics_show_name : Flag<"-fdiagnostics-show-name">,
|
||||
HelpText<"Print diagnostic name">;
|
||||
def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">,
|
||||
HelpText<"Print diagnostic name with mappable diagnostics">;
|
||||
HelpText<"Print option name with mappable diagnostics">;
|
||||
def fdiagnostics_show_category : Separate<"-fdiagnostics-show-category">,
|
||||
HelpText<"Print diagnostic category">;
|
||||
def fdiagnostics_show_note_include_stack :
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define DRIVERSTART
|
||||
#include "clang/Basic/DiagnosticDriverKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -272,6 +272,7 @@ def fdiagnostics_fixit_info : Flag<"-fdiagnostics-fixit-info">, Group<f_clang_Gr
|
|||
def fdiagnostics_print_source_range_info : Flag<"-fdiagnostics-print-source-range-info">, Group<f_clang_Group>;
|
||||
def fdiagnostics_parseable_fixits : Flag<"-fdiagnostics-parseable-fixits">, Group<f_clang_Group>;
|
||||
def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">, Group<f_Group>;
|
||||
def fdiagnostics_show_name : Flag<"-fdiagnostics-show-name">, Group<f_Group>;
|
||||
def fdiagnostics_show_note_include_stack : Flag<"-fdiagnostics-show-note-include-stack">, Group<f_Group>;
|
||||
def fdiagnostics_show_category_EQ : Joined<"-fdiagnostics-show-category=">, Group<f_clang_Group>;
|
||||
def fdollars_in_identifiers : Flag<"-fdollars-in-identifiers">, Group<f_Group>;
|
||||
|
@ -330,6 +331,7 @@ def fno_common : Flag<"-fno-common">, Group<f_Group>;
|
|||
def fno_constant_cfstrings : Flag<"-fno-constant-cfstrings">, Group<f_Group>;
|
||||
def fno_cxx_exceptions: Flag<"-fno-cxx-exceptions">, Group<f_Group>;
|
||||
def fno_diagnostics_fixit_info : Flag<"-fno-diagnostics-fixit-info">, Group<f_Group>;
|
||||
def fno_diagnostics_show_name : Flag<"-fno-diagnostics-show-name">, Group<f_Group>;
|
||||
def fno_diagnostics_show_option : Flag<"-fno-diagnostics-show-option">, Group<f_Group>;
|
||||
def fno_diagnostics_show_note_include_stack : Flag<"-fno-diagnostics-show-note-include-stack">, Group<f_Group>;
|
||||
def fno_dollars_in_identifiers : Flag<"-fno-dollars-in-identifiers">, Group<f_Group>;
|
||||
|
|
|
@ -31,7 +31,8 @@ public:
|
|||
unsigned ShowFixits : 1; /// Show fixit information.
|
||||
unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form.
|
||||
unsigned ShowParseableFixits : 1; /// Show machine parseable fix-its.
|
||||
unsigned ShowOptionNames : 1; /// Show the diagnostic name for mappable
|
||||
unsigned ShowNames : 1; /// Show the diagnostic name
|
||||
unsigned ShowOptionNames : 1; /// Show the option name for mappable
|
||||
/// diagnostics.
|
||||
unsigned ShowNoteIncludeStack : 1; /// Show include stacks for notes.
|
||||
unsigned ShowCategories : 2; /// Show categories: 0 -> none, 1 -> Number,
|
||||
|
@ -82,6 +83,7 @@ public:
|
|||
ShowColumn = 1;
|
||||
ShowFixits = 1;
|
||||
ShowLocation = 1;
|
||||
ShowNames = 0;
|
||||
ShowOptionNames = 0;
|
||||
ShowCategories = 0;
|
||||
ShowSourceRanges = 0;
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define FRONTENDSTART
|
||||
#include "clang/Basic/DiagnosticFrontendKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define LEXSTART
|
||||
#include "clang/Basic/DiagnosticLexKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define PARSESTART
|
||||
#include "clang/Basic/DiagnosticParseKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
namespace clang {
|
||||
namespace diag {
|
||||
enum {
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) ENUM,
|
||||
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) ENUM,
|
||||
#define SEMASTART
|
||||
#include "clang/Basic/DiagnosticSemaKinds.inc"
|
||||
#undef DIAG
|
||||
|
|
|
@ -40,5 +40,6 @@ add_dependencies(clangBasic
|
|||
ClangDiagnosticGroups
|
||||
ClangDiagnosticLex
|
||||
ClangDiagnosticParse
|
||||
ClangDiagnosticSema)
|
||||
ClangDiagnosticSema
|
||||
ClangDiagnosticIndexName)
|
||||
|
||||
|
|
|
@ -46,19 +46,41 @@ struct StaticDiagInfoRec {
|
|||
unsigned AccessControl : 1;
|
||||
unsigned Category : 5;
|
||||
|
||||
const char *Name;
|
||||
|
||||
const char *Description;
|
||||
const char *OptionGroup;
|
||||
|
||||
const char *BriefExplanation;
|
||||
const char *FullExplanation;
|
||||
|
||||
bool operator<(const StaticDiagInfoRec &RHS) const {
|
||||
return DiagID < RHS.DiagID;
|
||||
}
|
||||
};
|
||||
|
||||
struct StaticDiagNameIndexRec {
|
||||
const char *Name;
|
||||
unsigned short DiagID;
|
||||
|
||||
bool operator<(const StaticDiagNameIndexRec &RHS) const {
|
||||
assert(Name && RHS.Name && "Null Diagnostic Name");
|
||||
return strcmp(Name, RHS.Name) == -1;
|
||||
}
|
||||
|
||||
bool operator==(const StaticDiagNameIndexRec &RHS) const {
|
||||
assert(Name && RHS.Name && "Null Diagnostic Name");
|
||||
return strcmp(Name, RHS.Name) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static const StaticDiagInfoRec StaticDiagInfo[] = {
|
||||
#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,ACCESS,CATEGORY) \
|
||||
{ diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, ACCESS, CATEGORY, DESC, GROUP },
|
||||
#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP, \
|
||||
SFINAE,ACCESS,CATEGORY,BRIEF,FULL) \
|
||||
{ diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, \
|
||||
ACCESS, CATEGORY, #ENUM, DESC, GROUP, BRIEF, FULL },
|
||||
#include "clang/Basic/DiagnosticCommonKinds.inc"
|
||||
#include "clang/Basic/DiagnosticDriverKinds.inc"
|
||||
#include "clang/Basic/DiagnosticFrontendKinds.inc"
|
||||
|
@ -67,20 +89,32 @@ static const StaticDiagInfoRec StaticDiagInfo[] = {
|
|||
#include "clang/Basic/DiagnosticASTKinds.inc"
|
||||
#include "clang/Basic/DiagnosticSemaKinds.inc"
|
||||
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
#undef DIAG
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static const unsigned StaticDiagInfoSize =
|
||||
sizeof(StaticDiagInfo)/sizeof(StaticDiagInfo[0])-1;
|
||||
|
||||
/// To be sorted before first use (since it's splitted among multiple files)
|
||||
static StaticDiagNameIndexRec StaticDiagNameIndex[] = {
|
||||
#define DIAG_NAME_INDEX(ENUM) { #ENUM, diag::ENUM },
|
||||
#include "clang/Basic/DiagnosticIndexName.inc"
|
||||
#undef DIAG_NAME_INDEX
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const unsigned StaticDiagNameIndexSize =
|
||||
sizeof(StaticDiagNameIndex)/sizeof(StaticDiagNameIndex[0])-1;
|
||||
|
||||
/// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
|
||||
/// or null if the ID is invalid.
|
||||
static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
|
||||
unsigned NumDiagEntries = sizeof(StaticDiagInfo)/sizeof(StaticDiagInfo[0])-1;
|
||||
|
||||
// If assertions are enabled, verify that the StaticDiagInfo array is sorted.
|
||||
#ifndef NDEBUG
|
||||
static bool IsFirst = true;
|
||||
if (IsFirst) {
|
||||
for (unsigned i = 1; i != NumDiagEntries; ++i) {
|
||||
for (unsigned i = 1; i != StaticDiagInfoSize; ++i) {
|
||||
assert(StaticDiagInfo[i-1].DiagID != StaticDiagInfo[i].DiagID &&
|
||||
"Diag ID conflict, the enums at the start of clang::diag (in "
|
||||
"DiagnosticIDs.h) probably need to be increased");
|
||||
|
@ -93,11 +127,11 @@ static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
|
|||
#endif
|
||||
|
||||
// Search the diagnostic table with a binary search.
|
||||
StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0, 0, 0 };
|
||||
StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
const StaticDiagInfoRec *Found =
|
||||
std::lower_bound(StaticDiagInfo, StaticDiagInfo + NumDiagEntries, Find);
|
||||
if (Found == StaticDiagInfo + NumDiagEntries ||
|
||||
std::lower_bound(StaticDiagInfo, StaticDiagInfo + StaticDiagInfoSize, Find);
|
||||
if (Found == StaticDiagInfo + StaticDiagInfoSize ||
|
||||
Found->DiagID != DiagID)
|
||||
return 0;
|
||||
|
||||
|
@ -119,7 +153,7 @@ const char *DiagnosticIDs::getWarningOptionForDiag(unsigned DiagID) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// getWarningOptionForDiag - Return the category number that a specified
|
||||
/// getCategoryNumberForDiag - Return the category number that a specified
|
||||
/// DiagID belongs to, or 0 if no category.
|
||||
unsigned DiagnosticIDs::getCategoryNumberForDiag(unsigned DiagID) {
|
||||
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
|
||||
|
@ -167,7 +201,48 @@ DiagnosticIDs::getDiagnosticSFINAEResponse(unsigned DiagID) {
|
|||
return SFINAE_Report;
|
||||
}
|
||||
|
||||
/// getDiagClass - Return the class field of the diagnostic.
|
||||
/// getName - Given a diagnostic ID, return its name
|
||||
const char *DiagnosticIDs::getName(unsigned DiagID) {
|
||||
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
|
||||
return Info->Name;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// getIdFromName - Given a diagnostic name, return its ID, or 0
|
||||
unsigned DiagnosticIDs::getIdFromName(char const *Name) {
|
||||
StaticDiagNameIndexRec *StaticDiagNameIndexEnd =
|
||||
StaticDiagNameIndex + StaticDiagNameIndexSize;
|
||||
|
||||
if (Name == 0) { return diag::DIAG_UPPER_LIMIT; }
|
||||
|
||||
StaticDiagNameIndexRec Find = { Name, 0 };
|
||||
|
||||
const StaticDiagNameIndexRec *Found =
|
||||
std::lower_bound( StaticDiagNameIndex, StaticDiagNameIndexEnd, Find);
|
||||
if (Found == StaticDiagNameIndexEnd ||
|
||||
strcmp(Found->Name, Name) != 0)
|
||||
return diag::DIAG_UPPER_LIMIT;
|
||||
|
||||
return Found->DiagID;
|
||||
}
|
||||
|
||||
/// getBriefExplanation - Given a diagnostic ID, return a brief explanation
|
||||
/// of the issue
|
||||
const char *DiagnosticIDs::getBriefExplanation(unsigned DiagID) {
|
||||
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
|
||||
return Info->BriefExplanation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// getFullExplanation - Given a diagnostic ID, return a full explanation
|
||||
/// of the issue
|
||||
const char *DiagnosticIDs::getFullExplanation(unsigned DiagID) {
|
||||
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
|
||||
return Info->FullExplanation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// getBuiltinDiagClass - Return the class field of the diagnostic.
|
||||
///
|
||||
static unsigned getBuiltinDiagClass(unsigned DiagID) {
|
||||
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
|
||||
|
|
|
@ -1737,6 +1737,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info,
|
||||
options::OPT_fno_diagnostics_fixit_info))
|
||||
CmdArgs.push_back("-fno-diagnostics-fixit-info");
|
||||
|
||||
// Enable -fdiagnostics-show-name by default.
|
||||
if (Args.hasFlag(options::OPT_fdiagnostics_show_name,
|
||||
options::OPT_fno_diagnostics_show_name, false))
|
||||
CmdArgs.push_back("-fdiagnostics-show-name");
|
||||
|
||||
// Enable -fdiagnostics-show-option by default.
|
||||
if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
|
||||
|
|
|
@ -263,6 +263,8 @@ static void DiagnosticOptsToArgs(const DiagnosticOptions &Opts,
|
|||
Res.push_back("-fcolor-diagnostics");
|
||||
if (Opts.VerifyDiagnostics)
|
||||
Res.push_back("-verify");
|
||||
if (Opts.ShowNames)
|
||||
Res.push_back("-fdiagnostics-show-name");
|
||||
if (Opts.ShowOptionNames)
|
||||
Res.push_back("-fdiagnostics-show-option");
|
||||
if (Opts.ShowCategories == 1)
|
||||
|
@ -997,6 +999,7 @@ static void ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
|
|||
Opts.ShowColumn = !Args.hasArg(OPT_fno_show_column);
|
||||
Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
|
||||
Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
|
||||
Opts.ShowNames = Args.hasArg(OPT_fdiagnostics_show_name);
|
||||
Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
|
||||
|
||||
// Default behavior is to not to show note include stacks.
|
||||
|
|
|
@ -908,6 +908,13 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
|
|||
llvm::SmallString<100> OutStr;
|
||||
Info.FormatDiagnostic(OutStr);
|
||||
|
||||
if (DiagOpts->ShowNames &&
|
||||
!DiagnosticIDs::isBuiltinNote(Info.getID())) {
|
||||
OutStr += " [";
|
||||
OutStr += DiagnosticIDs::getName(Info.getID());
|
||||
OutStr += "]";
|
||||
}
|
||||
|
||||
std::string OptionName;
|
||||
if (DiagOpts->ShowOptionNames) {
|
||||
// Was this a warning mapped to an error using -Werror or pragma?
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// RUN: %clang -Wunused-parameter -fdiagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 1
|
||||
// RUN: %clang -Wunused-parameter -fno-diagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 0
|
||||
int main(int argc, char *argv[]) {
|
||||
return argc;
|
||||
}
|
Loading…
Reference in New Issue