-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Incorrect source range for instantiations of out-of-line defaulted special member functions of class templates #26057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I updated the summary as this issue occurs for all instantiated out-of-line defaulted special member function definitions, not just constructors. It does not occur for non-defaulted definitions (the following test case includes a member function for comparison purposes):
For each of the special member function declarations within the instantiated class template specialization, note that the begin location corresponds to the out-of-line definition, but that the end location corresponds to the in-class declaration. The instantiation of the 'mf' member function illustrates the expected behavior. |
Debugging revelations from the following minimal test case:
With a break point set on That third instance is created here:
Debugging revealed that 'D' corresponds to the first constructed What ends up happening is that a call to
Lines 4018-4019 above were added via the change in the following link to correct source locations for such instantiations. The call to
The same inconsistent location issue occurs here for non-defaulted functions as well. However, for functions with bodies, the end location gets corrected later by a call to
However, even in this case, the non-inner begin location is never updated with the result being: I'm not sure what the ramifications are of the begin and inner-begin locations being out of sync like this. The following change appears to suffice to work around this issue:
With the above change, I get 9 test failures in the Clang test suite. I haven't yet looked at the details of those failures.
|
A proposed fix has been posted for review: |
@llvm/issue-subscribers-clang-frontend |
@llvm/issue-subscribers-c-1 |
I asked Tom to rebase and added Clang language WG as reviewers. Let's see if we can have some progress with this. |
…ates. 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 llvm#26057 Reviewed By: cor3ntin Differential Revision: https://reviews.llvm.org/D64087
…ates. 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 llvm#26057 Reviewed By: cor3ntin Differential Revision: https://reviews.llvm.org/D64087
…ates. 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 llvm#26057 Reviewed By: cor3ntin Differential Revision: https://reviews.llvm.org/D64087
…ates. 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 llvm#26057 Reviewed By: cor3ntin Differential Revision: https://reviews.llvm.org/D64087
…ates. 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 llvm#26057 Reviewed By: cor3ntin Differential Revision: https://reviews.llvm.org/D64087
Extended Description
The following snippet produces an AST in which the starting source location appears after the end location:
In particular, note the line numbers on the second CXXConstructorDecl:
This doesn't seem to cause any problems in clang proper, but passing this range to clang::PreprocessingRecord::getPreprocessedEntitiesInRange triggers an assertion, since the start of the range occurs after the end.
The text was updated successfully, but these errors were encountered: