]> granicus.if.org Git - clang/commitdiff
add the ability to associate 'category' names with diagnostics
authorChris Lattner <sabre@nondot.org>
Tue, 4 May 2010 20:44:26 +0000 (20:44 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 4 May 2010 20:44:26 +0000 (20:44 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103051 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 2d314913469ed1a7d5fb05eb7d5b72357d24c2ff..7cbf3a5117054bd0afdd8f67f150ac242e4a2f2a 100644 (file)
@@ -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
index 114ae74b0c061a4abe96cff5b0065733c9ac2aa5..e98a3df472a83bd89db488e6c14a3b438a555244 100644 (file)
@@ -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
index 38fb4285ffbfc053559c6d82f7793773898629f7..6b2912e2e8c2024e85ea54a14c5b0d14e582bf67 100644 (file)
@@ -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
index 6aa3b438abd876808f907cb74b19d254da86eeb6..f6b5d9c5b308b42b4004bdf95481bfaa3c2e6e1b 100644 (file)
@@ -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>;
index c74a48c445fe7c14f5fa063767f2d210698b91de..1012e91baa771b49c1836b60f74fea9a4c8936a6 100644 (file)
@@ -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]>;
index d4a9da7b6d8028115dcab7f059ab54e54c866baa..c20d807b5811d182f376d5b7448e84293dcee55a 100644 (file)
@@ -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
index a044586a8c0a17994bb3f618e8c6e678cfa2b0d7..61ad22cabb0d3f5fad6d492fb86247c2fcd5804b 100644 (file)
@@ -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
index a470aa0924fbc18eccaf7363451edd443b6dd12e..2d941e4cf4fea1393fdbf46d2dc5fa9efea67f4a 100644 (file)
@@ -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
index c702e2fe65b86006fb8f23077190b296fce4062f..d7c5eee8d916790e86b0461c4f1ab4515d8bba67 100644 (file)
@@ -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
index d026339b5caf98acff9a96861adcf303d644a11f..a5a136427fb9d615f0dc27382b07739563b5f088 100644 (file)
@@ -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
index 1870195ded036cdc57ea76f58bd20f6ccdc437a5..9e6f168f1711ed8b41a271e48043ea5fd08b5cb1 100644 (file)
@@ -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);