This is an archive of the discontinued LLVM Phabricator instance.

[clang] buildFixItInsertionLine should use Hints of the same FID and LineNo
ClosedPublic

Authored by chh on Jul 10 2017, 4:32 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

chh created this revision.Jul 10 2017, 4:32 PM
chh added a reviewer: bkramer.Jul 10 2017, 6:14 PM
alexfh added inline comments.Jul 11 2017, 6:03 AM
lib/Frontend/TextDiagnostic.cpp
1109–1110 ↗(On Diff #105937)

Did you figure out why the old code used to give up here? Why does your code just continue?

chh added inline comments.Jul 11 2017, 9:21 AM
lib/Frontend/TextDiagnostic.cpp
1109–1110 ↗(On Diff #105937)

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.

chh added inline comments.Jul 11 2017, 3:58 PM
lib/Frontend/TextDiagnostic.cpp
1109–1110 ↗(On Diff #105937)

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.
alexfh accepted this revision.Jul 12 2017, 6:29 AM

LG. Thank you for the fix!

This revision is now accepted and ready to land.Jul 12 2017, 6:29 AM
This revision was automatically updated to reflect the committed changes.