[PATCH] D35230: [clang] buildFixItInsertionLine should use Hints of the same FID and LineNo

Chih-Hung Hsieh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 15:58:43 PDT 2017


chh added inline comments.


================
Comment at: lib/Frontend/TextDiagnostic.cpp:1109-1110
-      } else {
-        FixItInsertionLine.clear();
-        break;
       }
----------------
chh wrote:
> alexfh wrote:
> > Did you figure out why the old code used to give up here? Why does your code just continue?
> I don't know. It does not make sense to me for the use cases I think should work.
> Hints can contain suggested changes for different files and lines.
> If those hints can be in any order, resetting FixItInsertLine and break from the loop would lose the collected line.
> 
I found the old code introduced in https://reviews.llvm.org/rL70656
to fix the problem in https://bugs.llvm.org/show_bug.cgi?id=4084
This change does not have the problem in PR4084.


```
$ cat /tmp/t.c
int f0(char *a, char *b) {
  return ("a" !=
          "b");
}

$ clang -Wall -fsyntax-only /tmp/t.c
/tmp/t.c:2:15: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
  return ("a" !=
          ~~~ ^
1 warning generated.

```


https://reviews.llvm.org/D35230





More information about the cfe-commits mailing list