This is an archive of the discontinued LLVM Phabricator instance.

[clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)
ClosedPublic

Authored by tahonermann on Jul 2 2019, 10:14 AM.

Details

Summary

[clang] Correct source locations for instantiations of function templates.

This change corrects some cases where the source location for an instantiated specialization of a function template or a member function of a class template was assigned the location of a non-defining declaration rather than the location of the definition the specialization was instantiated from.

Fixes https://github.com/llvm/llvm-project/issues/26057

Diff Detail

Event Timeline

tahonermann created this revision.Jul 2 2019, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 2 2019, 10:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

See PR25683 (https://bugs.llvm.org/show_bug.cgi?id=25683) for more details. The patch posted here differs slightly from what is posted in the PR; getLocation() is called instead of getBeginLoc() since the latter may return a customized begin location.

I believe the impact to the two tests is a desirable change; the instantiation note seems like it should be correlated with the definition, not the declaration.

Endill added a reviewer: Restricted Project.Sep 10 2023, 11:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2023, 11:02 PM
Endill added a subscriber: Endill.Sep 10 2023, 11:02 PM

@tahonermann Do you mind rebasing this on top of trunk if it's necessary?
Might be a good idea to resubmit this as PR.

cor3ntin accepted this revision.Sep 11 2023, 12:19 AM
cor3ntin added a subscriber: cor3ntin.

LGTM (assuming rebase goes well)
@tahonermann ping folks in the future, and apologies for taking... 4 years!

This revision is now accepted and ready to land.Sep 11 2023, 12:19 AM
tahonermann edited the summary of this revision. (Show Details)

Rebased patch uploaded. This retains the same code change, but includes additional test updates for tests added since the first patch was submitted, as well as an additional patch to exercise a test case from https://github.com/llvm/llvm-project/issues/26057.

The changes made effectively complete changes originally made in commit 12dcbf3eaa6d2c8b9ee814ddb8bf23bef644bfaf (Fixed implicit instantiations source range.)

@Endill, thank you for the reminder about this old patch!

@cor3ntin, I added an additional test and updated a few other recently (relative to the original patch!) added tests. Would you be so kind as to give this another quick review?

Moved the added release note to the correct section.

@cor3ntin, any concerns or suggestions per my recent updates? I'll plan to land this in the next couple of days otherwise.

cor3ntin accepted this revision.Sep 18 2023, 9:28 AM

1 nit but still LGTM

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
4993–4994

Addressed review feedback.

This revision was landed with ongoing or failed builds.Sep 18 2023, 12:52 PM
This revision was automatically updated to reflect the committed changes.

This patch appears to introduce a bug in some source ranges.
Reported the regression at https://github.com/llvm/llvm-project/issues/71161.