Skip to content

Commit 77a08a7

Browse files
authored
[Clang] Fix wrong call location of DefaultArgExpr (#119212)
Fix #119129.
1 parent 52da2db commit 77a08a7

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

clang-tools-extra/test/clang-tidy/checkers/fuchsia/default-arguments-calls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void S::x(int i = 12) {}
2626
int main() {
2727
S s;
2828
s.x();
29-
// CHECK-NOTES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]
29+
// CHECK-NOTES: [[@LINE-1]]:5: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]
3030
// CHECK-NOTES: [[@LINE-6]]:11: note: default parameter was declared here
3131
// CHECK-NEXT: void S::x(int i = 12) {}
3232
x();

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ Bug Fixes to Compiler Builtins
698698

699699
- Fix ``__has_builtin`` incorrectly returning ``false`` for some C++ type traits. (#GH111477)
700700

701+
- Fix ``__builtin_source_location`` incorrectly returning wrong column for method chains. (#GH119129)
702+
701703
Bug Fixes to Attribute Support
702704
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
703705

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5948,7 +5948,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
59485948
SmallVector<Expr *, 8> AllArgs;
59495949
VariadicCallType CallType = getVariadicCallType(FDecl, Proto, Fn);
59505950

5951-
Invalid = GatherArgumentsForCall(Call->getBeginLoc(), FDecl, Proto, 0, Args,
5951+
Invalid = GatherArgumentsForCall(Call->getExprLoc(), FDecl, Proto, 0, Args,
59525952
AllArgs, CallType);
59535953
if (Invalid)
59545954
return true;

clang/test/SemaCXX/source_location.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,3 +1012,21 @@ int h = Var<int>;
10121012

10131013

10141014
}
1015+
1016+
namespace GH119129 {
1017+
struct X{
1018+
constexpr int foo(std::source_location loc = std::source_location::current()) {
1019+
return loc.line();
1020+
}
1021+
};
1022+
static_assert(X{}.foo() == __LINE__);
1023+
static_assert(X{}.
1024+
foo() == __LINE__);
1025+
static_assert(X{}.
1026+
1027+
1028+
foo() == __LINE__);
1029+
#line 10000
1030+
static_assert(X{}.
1031+
foo() == 10001);
1032+
}

0 commit comments

Comments
 (0)