<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 7, 2012, at 6:20 PM, Kaelyn Uhrain wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Thu, Jun 7, 2012 at 5:15 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Jun 7, 2012, at 4:57 PM, Kaelyn Uhrain wrote:<br>
<br>
> Author: rikka<br>
> Date: Thu Jun  7 18:57:12 2012<br>
> New Revision: 158178<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=158178&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=158178&view=rev</a><br>
> Log:<br>
> Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the written<br>
> nested name specifiers in addition to the function's identifier when the<br>
> correction has a different nested name specifier.<br>
><br>
> Modified:<br>
>    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
>    cfe/trunk/test/FixIt/fixit.cpp<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=158178&r1=158177&r2=158178&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=158178&r1=158177&r2=158178&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun  7 18:57:12 2012<br>
> @@ -4742,15 +4742,19 @@<br>
>     }<br>
>   }<br>
><br>
> -  if (Correction)<br>
> -    SemaRef.Diag(NewFD->getLocation(), DiagMsg)<br>
> +  if (Correction) {<br>
> +    SourceRange FixItLoc(NewFD->getLocation());<br>
> +    CXXScopeSpec &SS = ExtraArgs.D.getCXXScopeSpec();<br>
> +    if (Correction.getCorrectionSpecifier() && SS.isValid())<br>
> +      FixItLoc.setBegin(SS.getBeginLoc());<br>
> +    SemaRef.Diag(NewFD->getLocStart(), DiagMsg)<br>
>         << Name << NewDC << Correction.getQuoted(SemaRef.getLangOpts())<br>
>         << FixItHint::CreateReplacement(<br>
> -            NewFD->getLocation(),<br>
> -            Correction.getAsString(SemaRef.getLangOpts()));<br>
> -  else<br>
> +            FixItLoc, Correction.getAsString(SemaRef.getLangOpts()));<br>
<br>
</div></div>Don't you also need to update D.getCXXScopeSpec() to the correction specifier?<br></blockquote><div><br></div><div>If I remember correctly from way back when I first added the namespace-aware typo correction support, changing that CXXScopeSpec broke things in unexpected ways.... though it may also have been that I did not (and still don't) know how update it with the freshly synthesized NestedNameSpecifier* that lacks location information--or even that things broke because I hadn't created a corresponding NestedNameSpecifierLoc with valid location info. Though from what I can tell e.g. with the test case I added to make sure the substitution didn't leave the old specifier in the code, updating D.getCXXScopeSpecifier() isn't necessary.</div>
</div></blockquote><br></div><div>Okay, thanks for clarifying.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>- Doug</div><br></body></html>