summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-04 20:44:26 +0000
committerChris Lattner <sabre@nondot.org>2010-05-04 20:44:26 +0000
commit216c33bebaeca38dbf1dd98a7094875bf8ad78d1 (patch)
tree5fa7a698aed365db420cb88ac874283190d48cfa
parentb3d221964bf01f4770115216c0899405bf4a6e72 (diff)
downloadbcm5719-llvm-216c33bebaeca38dbf1dd98a7094875bf8ad78d1.tar.gz
bcm5719-llvm-216c33bebaeca38dbf1dd98a7094875bf8ad78d1.zip
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. llvm-svn: 103051
-rw-r--r--clang/include/clang/AST/ASTDiagnostic.h2
-rw-r--r--clang/include/clang/Analysis/AnalysisDiagnostic.h2
-rw-r--r--clang/include/clang/Basic/Diagnostic.h2
-rw-r--r--clang/include/clang/Basic/Diagnostic.td8
-rw-r--r--clang/include/clang/Basic/DiagnosticGroups.td10
-rw-r--r--clang/include/clang/Driver/DriverDiagnostic.h2
-rw-r--r--clang/include/clang/Frontend/FrontendDiagnostic.h2
-rw-r--r--clang/include/clang/Lex/LexDiagnostic.h2
-rw-r--r--clang/include/clang/Parse/ParseDiagnostic.h2
-rw-r--r--clang/include/clang/Sema/SemaDiagnostic.h2
-rw-r--r--clang/lib/Basic/Diagnostic.cpp10
11 files changed, 27 insertions, 17 deletions
diff --git a/clang/include/clang/AST/ASTDiagnostic.h b/clang/include/clang/AST/ASTDiagnostic.h
index 2d314913469..7cbf3a51170 100644
--- a/clang/include/clang/AST/ASTDiagnostic.h
+++ b/clang/include/clang/AST/ASTDiagnostic.h
@@ -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
diff --git a/clang/include/clang/Analysis/AnalysisDiagnostic.h b/clang/include/clang/Analysis/AnalysisDiagnostic.h
index 114ae74b0c0..e98a3df472a 100644
--- a/clang/include/clang/Analysis/AnalysisDiagnostic.h
+++ b/clang/include/clang/Analysis/AnalysisDiagnostic.h
@@ -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
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 38fb4285ffb..6b2912e2e8c 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -60,7 +60,7 @@ namespace clang {
// 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
diff --git a/clang/include/clang/Basic/Diagnostic.td b/clang/include/clang/Basic/Diagnostic.td
index 6aa3b438abd..f6b5d9c5b30 100644
--- a/clang/include/clang/Basic/Diagnostic.td
+++ b/clang/include/clang/Basic/Diagnostic.td
@@ -26,10 +26,17 @@ def CLASS_WARNING : DiagClass;
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 @@ class Diagnostic<string text, DiagClass DC, DiagMapping defaultmapping> {
bit SFINAE = 1;
DiagMapping DefaultMapping = defaultmapping;
DiagGroup Group;
+ string CategoryName = "";
}
class Error<string str> : Diagnostic<str, CLASS_ERROR, MAP_ERROR>;
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index c74a48c445f..1012e91baa7 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -15,8 +15,6 @@ def Implicit : DiagGroup<"implicit", [
ImplicitFunctionDeclare,
ImplicitInt
]>;
-
-
// Empty DiagGroups are recognized by clang but ignored.
def : DiagGroup<"address">;
@@ -102,7 +100,7 @@ def : DiagGroup<"strict-prototypes">;
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 @@ def Parentheses : DiagGroup<"parentheses", [DiagGroup<"idiomatic-parentheses">]>
// -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 @@ def Unused : DiagGroup<"unused",
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]>;
diff --git a/clang/include/clang/Driver/DriverDiagnostic.h b/clang/include/clang/Driver/DriverDiagnostic.h
index d4a9da7b6d8..c20d807b581 100644
--- a/clang/include/clang/Driver/DriverDiagnostic.h
+++ b/clang/include/clang/Driver/DriverDiagnostic.h
@@ -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
diff --git a/clang/include/clang/Frontend/FrontendDiagnostic.h b/clang/include/clang/Frontend/FrontendDiagnostic.h
index a044586a8c0..61ad22cabb0 100644
--- a/clang/include/clang/Frontend/FrontendDiagnostic.h
+++ b/clang/include/clang/Frontend/FrontendDiagnostic.h
@@ -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
diff --git a/clang/include/clang/Lex/LexDiagnostic.h b/clang/include/clang/Lex/LexDiagnostic.h
index a470aa0924f..2d941e4cf4f 100644
--- a/clang/include/clang/Lex/LexDiagnostic.h
+++ b/clang/include/clang/Lex/LexDiagnostic.h
@@ -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
diff --git a/clang/include/clang/Parse/ParseDiagnostic.h b/clang/include/clang/Parse/ParseDiagnostic.h
index c702e2fe65b..d7c5eee8d91 100644
--- a/clang/include/clang/Parse/ParseDiagnostic.h
+++ b/clang/include/clang/Parse/ParseDiagnostic.h
@@ -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
diff --git a/clang/include/clang/Sema/SemaDiagnostic.h b/clang/include/clang/Sema/SemaDiagnostic.h
index d026339b5ca..a5a136427fb 100644
--- a/clang/include/clang/Sema/SemaDiagnostic.h
+++ b/clang/include/clang/Sema/SemaDiagnostic.h
@@ -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
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 1870195ded0..9e6f168f171 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -51,6 +51,8 @@ struct StaticDiagInfoRec {
unsigned Mapping : 3;
unsigned Class : 3;
bool SFINAE : 1;
+ unsigned Category : 5;
+
const char *Description;
const char *OptionGroup;
@@ -63,8 +65,8 @@ struct StaticDiagInfoRec {
};
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 @@ 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, 0, 0, 0, 0, 0}
};
#undef DIAG
@@ -99,7 +101,7 @@ static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
#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);
OpenPOWER on IntegriCloud