diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-01-06 23:44:25 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-01-06 23:44:25 +0000 | 
| commit | 10f1e4dda8a81defe476bc25b4d70bb1fdd345a6 (patch) | |
| tree | c5f0c274910f3e7f789519f5952b328a247ebe4d /clang/lib | |
| parent | 2a43fd58ee98b7e411474fbc5c574981895cf641 (diff) | |
| download | bcm5719-llvm-10f1e4dda8a81defe476bc25b4d70bb1fdd345a6.tar.gz bcm5719-llvm-10f1e4dda8a81defe476bc25b4d70bb1fdd345a6.zip  | |
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
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/FixItRewriter.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 8 | 
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Frontend/FixItRewriter.cpp b/clang/lib/Frontend/FixItRewriter.cpp index 4fa2b3c51eb..0b04cf2b44d 100644 --- a/clang/lib/Frontend/FixItRewriter.cpp +++ b/clang/lib/Frontend/FixItRewriter.cpp @@ -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 diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index f627c23d769..e5526746d9d 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -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;  | 

