[cfe-commits] r103051 - in /cfe/trunk: include/clang/AST/ASTDiagnostic.h include/clang/Analysis/AnalysisDiagnostic.h include/clang/Basic/Diagnostic.h include/clang/Basic/Diagnostic.td include/clang/Basic/DiagnosticGroups.td include/clang/Driver/DriverDiagnostic.h include/clang/Frontend/FrontendDiagnostic.h include/clang/Lex/LexDiagnostic.h include/clang/Parse/ParseDiagnostic.h include/clang/Sema/SemaDiagnostic.h lib/Basic/Diagnostic.cpp
Chris Lattner
sabre at nondot.org
Tue May 4 13:44:26 PDT 2010
Author: lattner
Date: Tue May 4 15:44:26 2010
New Revision: 103051
URL: http://llvm.org/viewvc/llvm-project?rev=103051&view=rev
Log:
add the ability to associate 'category' names with diagnostics
and diagnostic groups. This allows the compiler to group
diagnostics together (e.g. "Logic Warning",
"Format String Warning", etc) like the static analyzer does.
This is not exposed through anything in the compiler yet.
Modified:
cfe/trunk/include/clang/AST/ASTDiagnostic.h
cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/Diagnostic.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Driver/DriverDiagnostic.h
cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
cfe/trunk/include/clang/Lex/LexDiagnostic.h
cfe/trunk/include/clang/Parse/ParseDiagnostic.h
cfe/trunk/include/clang/Sema/SemaDiagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp
Modified: cfe/trunk/include/clang/AST/ASTDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define ASTSTART
#include "clang/Basic/DiagnosticASTKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define ANALYSISSTART
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue May 4 15:44:26 2010
@@ -60,7 +60,7 @@
// Get typedefs for common diagnostics.
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#include "clang/Basic/DiagnosticCommonKinds.inc"
NUM_BUILTIN_COMMON_DIAGNOSTICS
#undef DIAG
Modified: cfe/trunk/include/clang/Basic/Diagnostic.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.td?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.td (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.td Tue May 4 15:44:26 2010
@@ -26,10 +26,17 @@
def CLASS_EXTENSION : DiagClass;
def CLASS_ERROR : DiagClass;
+// Diagnostic Categories. These can be applied to groups or individual
+// diagnostics to specify a category.
+class DiagCategory<string Name> {
+ string CategoryName = Name;
+}
+
// Diagnostic Groups.
class DiagGroup<string Name, list<DiagGroup> subgroups = []> {
string GroupName = Name;
list<DiagGroup> SubGroups = subgroups;
+ string CategoryName = "";
}
class InGroup<DiagGroup G> { DiagGroup Group = G; }
//class IsGroup<string Name> { DiagGroup Group = DiagGroup<Name>; }
@@ -48,6 +55,7 @@
bit SFINAE = 1;
DiagMapping DefaultMapping = defaultmapping;
DiagGroup Group;
+ string CategoryName = "";
}
class Error<string str> : Diagnostic<str, CLASS_ERROR, MAP_ERROR>;
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue May 4 15:44:26 2010
@@ -15,8 +15,6 @@
ImplicitFunctionDeclare,
ImplicitInt
]>;
-
-
// Empty DiagGroups are recognized by clang but ignored.
def : DiagGroup<"address">;
@@ -102,7 +100,7 @@
def : DiagGroup<"strict-selector-match">;
def SwitchEnum : DiagGroup<"switch-enum">;
def Switch : DiagGroup<"switch", [SwitchEnum]>;
-def Trigraphs : DiagGroup<"trigraphs">;
+def Trigraphs : DiagGroup<"trigraphs">;
def : DiagGroup<"type-limits">;
def Uninitialized : DiagGroup<"uninitialized">;
@@ -135,7 +133,8 @@
// -Wconversion has its own warnings, but we split this one out for
// legacy reasons.
def Conversion : DiagGroup<"conversion",
- [DiagGroup<"shorten-64-to-32">]>;
+ [DiagGroup<"shorten-64-to-32">]>,
+ DiagCategory<"Value Conversion">;
def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
@@ -143,7 +142,8 @@
UnusedValue, UnusedVariable]>;
// Format settings.
-def Format : DiagGroup<"format", [FormatExtraArgs, FormatZeroLength, NonNull]>;
+def Format : DiagGroup<"format", [FormatExtraArgs, FormatZeroLength, NonNull]>,
+ DiagCategory<"Format String">;
def FormatSecurity : DiagGroup<"format-security", [Format]>;
def FormatNonLiteral : DiagGroup<"format-nonliteral", [FormatSecurity]>;
def FormatY2K : DiagGroup<"format-y2k", [Format]>;
Modified: cfe/trunk/include/clang/Driver/DriverDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/DriverDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/DriverDiagnostic.h (original)
+++ cfe/trunk/include/clang/Driver/DriverDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define DRIVERSTART
#include "clang/Basic/DiagnosticDriverKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define FRONTENDSTART
#include "clang/Basic/DiagnosticFrontendKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Lex/LexDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LexDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LexDiagnostic.h (original)
+++ cfe/trunk/include/clang/Lex/LexDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define LEXSTART
#include "clang/Basic/DiagnosticLexKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Parse/ParseDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/ParseDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/ParseDiagnostic.h (original)
+++ cfe/trunk/include/clang/Parse/ParseDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define PARSESTART
#include "clang/Basic/DiagnosticParseKinds.inc"
#undef DIAG
Modified: cfe/trunk/include/clang/Sema/SemaDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaDiagnostic.h?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/SemaDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/SemaDiagnostic.h Tue May 4 15:44:26 2010
@@ -15,7 +15,7 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
+#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE,CATEGORY) ENUM,
#define SEMASTART
#include "clang/Basic/DiagnosticSemaKinds.inc"
#undef DIAG
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=103051&r1=103050&r2=103051&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Tue May 4 15:44:26 2010
@@ -51,6 +51,8 @@
unsigned Mapping : 3;
unsigned Class : 3;
bool SFINAE : 1;
+ unsigned Category : 5;
+
const char *Description;
const char *OptionGroup;
@@ -63,8 +65,8 @@
};
static const StaticDiagInfoRec StaticDiagInfo[] = {
-#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) \
- { diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, DESC, GROUP },
+#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP,SFINAE, CATEGORY) \
+ { diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, CATEGORY, DESC, GROUP },
#include "clang/Basic/DiagnosticCommonKinds.inc"
#include "clang/Basic/DiagnosticDriverKinds.inc"
#include "clang/Basic/DiagnosticFrontendKinds.inc"
@@ -73,7 +75,7 @@
#include "clang/Basic/DiagnosticASTKinds.inc"
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
- { 0, 0, 0, 0, 0, 0}
+ { 0, 0, 0, 0, 0, 0, 0}
};
#undef DIAG
@@ -99,7 +101,7 @@
#endif
// Search the diagnostic table with a binary search.
- StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0 };
+ StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0, 0 };
const StaticDiagInfoRec *Found =
std::lower_bound(StaticDiagInfo, StaticDiagInfo + NumDiagEntries, Find);
More information about the cfe-commits
mailing list