Consolidate some note diagnostics

These note diags have the same message and can be unified further but for now
let's just bring them together.

Incidental change: Display a source range in the final attr diagnostic.

llvm-svn: 209728
This commit is contained in:
Alp Toker 2014-05-28 12:20:14 +00:00
parent a9c452121a
commit 2afa8780d6
7 changed files with 21 additions and 34 deletions

View File

@ -14,6 +14,11 @@
let Component = "Sema" in {
let CategoryName = "Semantic Issue" in {
def note_previous_decl : Note<"%0 declared here">;
def note_entity_declared_at : Note<"%0 declared here">;
def note_callee_decl : Note<"%0 declared here">;
def note_defined_here : Note<"%0 defined here">;
// For loop analysis
def warn_variables_not_in_loop_body : Warning<
"variable%select{s| %1|s %1 and %2|s %1, %2, and %3|s %1, %2, %3, and %4}0 "
@ -1222,10 +1227,9 @@ def warn_call_to_pure_virtual_member_function_from_ctor_dtor : Warning<
"call to pure virtual member function %0; overrides of %0 in subclasses are "
"not available in the %select{constructor|destructor}1 of %2">;
def note_field_decl : Note<"member is declared here">;
def note_member_declared_at : Note<"member is declared here">;
def note_ivar_decl : Note<"instance variable is declared here">;
def note_bitfield_decl : Note<"bit-field is declared here">;
def note_previous_decl : Note<"%0 declared here">;
def note_implicit_param_decl : Note<"%0 is an implicit parameter">;
def note_member_synthesized_at : Note<
"implicit %select{default constructor|copy constructor|move constructor|copy "
@ -3061,7 +3065,6 @@ def err_template_arg_list_different_arity : Error<
"%select{class template|function template|template template parameter"
"|template}1 %2">;
def note_template_decl_here : Note<"template is declared here">;
def note_member_of_template_here : Note<"member is declared here">;
def err_template_arg_must_be_type : Error<
"template argument for template type parameter must be a type">;
def err_template_arg_must_be_type_suggest : Error<
@ -3726,8 +3729,6 @@ def warn_static_local_in_extern_inline : Warning<
"in different files">, InGroup<StaticLocalInInline>;
def note_convert_inline_to_static : Note<
"use 'static' to give inline function %0 internal linkage">;
def note_internal_decl_declared_here : Note<
"%0 declared here">;
def warn_redefinition_of_typedef : ExtWarn<
"redefinition of typedef %0 is a C11 feature">,
@ -5352,8 +5353,6 @@ def err_typecheck_deleted_function : Error<
def err_expected_class_or_namespace : Error<"%0 is not a class"
"%select{ or namespace|, namespace, or scoped enumeration}1">;
def note_expected_class_or_namespace_declared_here : Note<
"%0 declared here">;
def err_invalid_declarator_scope : Error<"cannot define or redeclare %0 here "
"because namespace %1 does not enclose namespace %2">;
def err_invalid_declarator_global_scope : Error<
@ -5648,8 +5647,6 @@ def err_call_incomplete_return : Error<
"calling function with incomplete return type %0">;
def err_call_function_incomplete_return : Error<
"calling %0 with incomplete return type %1">;
def note_function_with_incomplete_return_type_declared_here : Note<
"%0 declared here">;
def err_call_incomplete_argument : Error<
"argument type %0 is incomplete">;
def err_typecheck_call_too_few_args : Error<
@ -5705,10 +5702,6 @@ def err_arc_typecheck_convert_incompatible_pointer : Error<
"incompatible pointer types passing retainable parameter of type %0"
"to a CF function expecting %1 type">;
def note_callee_decl : Note<
"%0 declared here">;
def note_defined_here : Note<"%0 defined here">;
def err_builtin_fn_use : Error<"builtin functions must be directly called">;
def warn_call_wrong_number_of_arguments : Warning<
@ -6060,8 +6053,6 @@ def err_reference_to_local_var_in_enclosing_lambda : Error<
def err_reference_to_local_var_in_enclosing_context : Error<
"reference to local variable %0 declared in enclosing context">;
def note_local_variable_declared_here : Note<
"%0 declared here">;
def err_static_data_member_not_allowed_in_local_class : Error<
"static data member %0 not allowed in local class %1">;

View File

@ -1252,7 +1252,8 @@ static void DiagnoseAccessPath(Sema &S,
<< (base->getAccessSpecifierAsWritten() == AS_none);
if (entity.isMemberAccess())
S.Diag(entity.getTargetDecl()->getLocation(), diag::note_field_decl);
S.Diag(entity.getTargetDecl()->getLocation(),
diag::note_member_declared_at);
}
static void DiagnoseBadAccess(Sema &S, SourceLocation Loc,

View File

@ -532,9 +532,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
Diag(R.getNameLoc(), diag::err_expected_class_or_namespace)
<< &Identifier << getLangOpts().CPlusPlus;
if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
Diag(ND->getLocation(),
diag::note_expected_class_or_namespace_declared_here)
<< &Identifier;
Diag(ND->getLocation(), diag::note_entity_declared_at) << &Identifier;
return true;
}
}
@ -718,9 +716,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
Diag(IdentifierLoc, diag::err_expected_class_or_namespace)
<< &Identifier << getLangOpts().CPlusPlus;
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
Diag(ND->getLocation(),
diag::note_expected_class_or_namespace_declared_here)
<< &Identifier;
Diag(ND->getLocation(), diag::note_entity_declared_at) << &Identifier;
}
} else if (SS.isSet())
Diag(IdentifierLoc, diag::err_no_member) << &Identifier << LookupCtx

View File

@ -1398,8 +1398,8 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
<< CXXBaseDecl->getDeclName()
<< FA->isSpelledAsSealed();
Diag(CXXBaseDecl->getLocation(), diag::note_previous_decl)
<< CXXBaseDecl->getDeclName();
Diag(CXXBaseDecl->getLocation(), diag::note_entity_declared_at)
<< CXXBaseDecl->getDeclName() << FA->getRange();
return nullptr;
}

View File

@ -223,9 +223,8 @@ static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S,
S.MaybeSuggestAddingStaticToDecl(Current);
S.Diag(D->getCanonicalDecl()->getLocation(),
diag::note_internal_decl_declared_here)
<< D;
S.Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
<< D;
}
void Sema::MaybeSuggestAddingStaticToDecl(const FunctionDecl *Cur) {
@ -11469,8 +11468,8 @@ diagnoseUncapturableValueReference(Sema &S, SourceLocation loc,
<< var->getIdentifier();
}
S.Diag(var->getLocation(), diag::note_local_variable_declared_here)
<< var->getIdentifier();
S.Diag(var->getLocation(), diag::note_entity_declared_at)
<< var->getIdentifier();
// FIXME: Add additional diagnostic info about class etc. which prevents
// capture.
@ -12586,9 +12585,8 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
S.Diag(Loc, diag::err_call_function_incomplete_return)
<< CE->getSourceRange() << FD->getDeclName() << T;
S.Diag(FD->getLocation(),
diag::note_function_with_incomplete_return_type_declared_here)
<< FD->getDeclName();
S.Diag(FD->getLocation(), diag::note_entity_declared_at)
<< FD->getDeclName();
}
} Diagnoser(FD, CE);

View File

@ -6588,7 +6588,8 @@ bool InitializationSequence::Diagnose(Sema &S,
<< S.Context.getTypeDeclType(Constructor->getParent())
<< /*member=*/1
<< Entity.getName();
S.Diag(Entity.getDecl()->getLocation(), diag::note_field_decl);
S.Diag(Entity.getDecl()->getLocation(),
diag::note_member_declared_at);
if (const RecordType *Record
= Entity.getType()->getAs<RecordType>())

View File

@ -1850,7 +1850,7 @@ static bool DiagnoseUninstantiableTemplate(Sema &S,
S.Diag(PointOfInstantiation,
diag::err_implicit_instantiate_member_undefined)
<< S.Context.getTypeDeclType(Instantiation);
S.Diag(Pattern->getLocation(), diag::note_member_of_template_here);
S.Diag(Pattern->getLocation(), diag::note_member_declared_at);
} else {
S.Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
<< (TSK != TSK_ImplicitInstantiation)