diaggroup categories should take precedence over diag-specific groups.
authorChris Lattner <sabre@nondot.org>
Mon, 24 May 2010 21:55:47 +0000 (21:55 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 24 May 2010 21:55:47 +0000 (21:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104567 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/ClangDiagnosticsEmitter.cpp

index b2ddf93e111811f8fef21998121b4a02cb28cc7c..75b6252c4f9f70961d40bbab9b4c3033c903ff0e 100644 (file)
@@ -70,15 +70,16 @@ getCategoryFromDiagGroup(const Record *Group,
 /// lives in.
 static std::string getDiagnosticCategory(const Record *R,
                                          DiagGroupParentMap &DiagGroupParents) {
-  // If the diagnostic itself has a category, get it.
-  std::string CatName = R->getValueAsString("CategoryName");
-  if (!CatName.empty()) return CatName;
-  
-  DefInit *Group = dynamic_cast<DefInit*>(R->getValueInit("Group"));
-  if (Group == 0) return "";
+  // If the diagnostic is in a group, and that group has a category, use it.
+  if (DefInit *Group = dynamic_cast<DefInit*>(R->getValueInit("Group"))) {
+    // Check the diagnostic's diag group for a category.
+    std::string CatName = getCategoryFromDiagGroup(Group->getDef(),
+                                                   DiagGroupParents);
+    if (!CatName.empty()) return CatName;
+  }
   
-  // Check the diagnostic's diag group for a category.
-  return getCategoryFromDiagGroup(Group->getDef(), DiagGroupParents);
+  // If the diagnostic itself has a category, get it.
+  return R->getValueAsString("CategoryName");
 }
 
 namespace {