This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Don't display an invalid redefinition error when dealing with a redefinition of a function whose previous definition was typo-corrected
ClosedPublic

Authored by arphaman on Sep 30 2016, 11:35 AM.

Details

Summary

This patch improves the displayed diagnostics when encountering a redefinition of a function whose previous definition was typo-corrected.

For example, given a code sample like this:

class Foo {
  int* create_process(int pid, const char* name);
};

int *Foo::create_process2(int pid, const char* name) {
  return 0;
}

int *Foo::create_process(int pid, const char* name) {
  return 0;
}

Clang will now show only the error diagnostic for the definition of create_process2: "out-of-line definition of 'create_process2' does not match any declaration in 'Foo'; did you mean 'create_process'?". However, prior to this patch, clang would have also shown a second error diagnostic for the definition of create_process: "redefinition of 'create_process'". The second diagnostic shouldn't be presented as it's not true, and the automatic renaming of create_process2 shouldn't cause such an error.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman updated this revision to Diff 73103.Sep 30 2016, 11:35 AM
arphaman retitled this revision from to [Sema] Don't display an invalid redefinition error when dealing with a redefinition of a function whose previous definition was typo-corrected .
arphaman updated this object.
arphaman added a reviewer: rsmith.
arphaman set the repository for this revision to rL LLVM.
arphaman added a subscriber: cfe-commits.
arphaman updated this revision to Diff 96123.Apr 21 2017, 4:23 AM
arphaman added reviewers: ahatanak, v.g.vassilev.

Rebased the patch.

This revision was automatically updated to reflect the committed changes.