Enhance ClangDiagnosticsEmitter to reject diagnostics that are errors that are also

included in warning groups.  Warning groups can only contain warnings, because only
warnings can be mapped to errors or ignored.

This caught a few diagnostics that were incorrectly in diagnostic groups, and
could have resulted in a compiler crash when those diagnostic groups were mapped.

Fixes <rdar://problem/12044436>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161389 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2012-08-07 05:01:49 +00:00
Родитель 8ae4ec2845
Коммит 4a535368eb
3 изменённых файлов: 20 добавлений и 6 удалений

Просмотреть файл

@ -332,8 +332,7 @@ def err_feature_check_malformed : Error<
"builtin feature check macro requires a parenthesized identifier">;
def err_warning_check_malformed : Error<
"builtin warning check macro requires a parenthesized string">,
InGroup<MalformedWarningCheck>;
"builtin warning check macro requires a parenthesized string">;
def warn_has_warning_invalid_option :
ExtWarn<"__has_warning expected option name (e.g. \"-Wundef\")">,
InGroup<MalformedWarningCheck>;

Просмотреть файл

@ -3567,8 +3567,7 @@ def err_arc_autoreleasing_capture : Error<
def err_arc_thread_ownership : Error<
"thread-local variable has non-trivial ownership: type is %0">;
def err_arc_indirect_no_ownership : Error<
"%select{pointer|reference}1 to non-const type %0 with no explicit ownership">,
InGroup<AutomaticReferenceCounting>;
"%select{pointer|reference}1 to non-const type %0 with no explicit ownership">;
def err_arc_array_param_no_ownership : Error<
"must explicitly describe intended ownership of an object array parameter">;
def err_arc_pseudo_dtor_inconstant_quals : Error<
@ -5491,8 +5490,7 @@ def err_builtin_annotation_second_arg : Error<
// CFString checking
def err_cfstring_literal_not_string_constant : Error<
"CFString literal is not a string constant">,
InGroup<DiagGroup<"CFString-literal">>;
"CFString literal is not a string constant">;
def warn_cfstring_truncated : Warning<
"input conversion stopped due to an input byte that does not "
"belong to the input codeset UTF-8">,

Просмотреть файл

@ -339,6 +339,11 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
// Warning Tables (.inc file) generation.
//===----------------------------------------------------------------------===//
static bool isError(const Record &Diag) {
const std::string &ClsName = Diag.getValueAsDef("Class")->getName();
return ClsName == "CLASS_ERROR";
}
/// ClangDiagsDefsEmitter - The top-level class emits .def files containing
/// declarations of Clang diagnostics.
namespace clang {
@ -373,6 +378,18 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
const Record &R = *Diags[i];
// Check if this is an error that is accidentally in a warning
// group.
if (isError(R)) {
if (DefInit *Group = dynamic_cast<DefInit*>(R.getValueInit("Group"))) {
const Record *GroupRec = Group->getDef();
const std::string &GroupName = GroupRec->getValueAsString("GroupName");
throw "Error " + R.getName() + " cannot be in a warning group [" +
GroupName + "]";
}
}
// Filter by component.
if (!Component.empty() && Component != R.getValueAsString("Component"))
continue;