When suggesting a typo correction for an @implementation without a

corresponding @interface, provide a note showing which interface we're
referring to. This note has the fix-it hint on it.

Also, don't automatically apply fix-it hints for notes. They're meant
to express fix-its that would change semantics.

llvm-svn: 92870
This commit is contained in:
Douglas Gregor 2010-01-06 23:44:25 +00:00
parent 2a43fd58ee
commit 10f1e4dda8
3 changed files with 12 additions and 2 deletions

View File

@ -115,6 +115,9 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
if (!AcceptableLocation)
return;
} else if (DiagLevel == Diagnostic::Note) {
// Don't apply fix-it modifications in notes.
return;
}
// Make sure that we can perform all of the modifications we

View File

@ -701,11 +701,17 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
LookupResult R(*this, ClassName, ClassLoc, LookupOrdinaryName);
if (CorrectTypo(R, TUScope, 0) &&
(IDecl = R.getAsSingle<ObjCInterfaceDecl>())) {
// Suggest the (potentially) correct interface name. However, don't
// Suggest the (potentially) correct interface name. However, put the
// fix-it hint itself in a separate note, since changing the name in
// the warning would make the fix-it change semantics.However, don't
// provide a code-modification hint or use the typo name for recovery,
// because this is just a warning. The program may actually be correct.
Diag(ClassLoc, diag::warn_undef_interface_suggest)
<< ClassName << R.getLookupName();
Diag(IDecl->getLocation(), diag::note_previous_decl)
<< R.getLookupName()
<< CodeModificationHint::CreateReplacement(ClassLoc,
R.getLookupName().getAsString());
IDecl = 0;
} else {
Diag(ClassLoc, diag::warn_undef_interface) << ClassName;

View File

@ -13,7 +13,8 @@
@interface INTF2 : INTF1
@end
@interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}}
@interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}} \
// expected-note{{'INTF3' declared here}}
@end
@interface INTF1 // expected-error {{duplicate interface definition for class 'INTF1'}}