Skip to content

Commit d144eb1

Browse files
authored
[Clang] Back out the source location workaround for CXXConstructExpr (#145260)
This removes the workaround introduced in 3e1a9cf and 1ba7dc3. The workaround overwrote the right parenthesis location of the sub expression, which could be wrong when a CXXTemporaryObjectExpr occurs within a nested expression, e.g. `A(A(1, 2))`. To completely take it down, we now propagate the left parenthesis source location throughout SemaCast, such that the ParenOrBraceRange can be properly set at the point of its creation. Fixes #143711
1 parent 741e1ca commit d144eb1

File tree

4 files changed

+124
-86
lines changed

4 files changed

+124
-86
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ Bug Fixes to AST Handling
884884
- Fixed a malformed printout of ``CXXParenListInitExpr`` in certain contexts.
885885
- Fixed a malformed printout of certain calling convention function attributes. (#GH143160)
886886
- Fixed dependency calculation for TypedefTypes (#GH89774)
887+
- Fixed the right parenthesis source location of ``CXXTemporaryObjectExpr``. (#GH143711)
887888

888889
Miscellaneous Bug Fixes
889890
^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Sema/Initialization.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,12 @@ class InitializationKind {
676676
}
677677

678678
/// Create a direct initialization for a functional cast.
679-
static InitializationKind CreateFunctionalCast(SourceRange TypeRange,
679+
static InitializationKind CreateFunctionalCast(SourceLocation StartLoc,
680+
SourceRange ParenRange,
680681
bool InitList) {
681682
return InitializationKind(InitList ? IK_DirectList : IK_Direct,
682-
IC_FunctionalCast, TypeRange.getBegin(),
683-
TypeRange.getBegin(), TypeRange.getEnd());
683+
IC_FunctionalCast, StartLoc,
684+
ParenRange.getBegin(), ParenRange.getEnd());
684685
}
685686

686687
/// Create a copy initialization.

0 commit comments

Comments
 (0)