[cfe-commits] r92870 - in /cfe/trunk: lib/Frontend/FixItRewriter.cpp lib/Sema/SemaDeclObjC.cpp test/SemaObjC/undef-superclass-1.m
Douglas Gregor
dgregor at apple.com
Wed Jan 6 15:44:25 PST 2010
Author: dgregor
Date: Wed Jan 6 17:44:25 2010
New Revision: 92870
URL: http://llvm.org/viewvc/llvm-project?rev=92870&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Frontend/FixItRewriter.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/undef-superclass-1.m
Modified: cfe/trunk/lib/Frontend/FixItRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FixItRewriter.cpp?rev=92870&r1=92869&r2=92870&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FixItRewriter.cpp (original)
+++ cfe/trunk/lib/Frontend/FixItRewriter.cpp Wed Jan 6 17:44:25 2010
@@ -115,6 +115,9 @@
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
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=92870&r1=92869&r2=92870&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Jan 6 17:44:25 2010
@@ -701,11 +701,17 @@
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;
Modified: cfe/trunk/test/SemaObjC/undef-superclass-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/undef-superclass-1.m?rev=92870&r1=92869&r2=92870&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/undef-superclass-1.m (original)
+++ cfe/trunk/test/SemaObjC/undef-superclass-1.m Wed Jan 6 17:44:25 2010
@@ -13,7 +13,8 @@
@interface INTF2 : INTF1
@end
- at interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}}
+ at 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'}}
More information about the cfe-commits
mailing list