Skip to content

Commit 62072e7

Browse files
HighCommander4tstellar
authored andcommitted
[clang][AST] Handle implicit first argument in CallExpr::getBeginLoc()
1 parent 581772e commit 62072e7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

clang/lib/AST/Expr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,8 +1665,11 @@ SourceLocation CallExpr::getBeginLoc() const {
16651665
Method && Method->isExplicitObjectMemberFunction()) {
16661666
bool HasFirstArg = getNumArgs() > 0 && getArg(0);
16671667
assert(HasFirstArg);
1668-
if (HasFirstArg)
1669-
return getArg(0)->getBeginLoc();
1668+
if (HasFirstArg) {
1669+
if (auto FirstArgLoc = getArg(0)->getBeginLoc(); FirstArgLoc.isValid()) {
1670+
return FirstArgLoc;
1671+
}
1672+
}
16701673
}
16711674
}
16721675

clang/test/SemaCXX/cxx2b-deducing-this.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,3 +1134,10 @@ struct S {
11341134
static_assert((S{} << 11) == a);
11351135
// expected-error@-1 {{use of undeclared identifier 'a'}}
11361136
}
1137+
1138+
namespace GH135522 {
1139+
struct S {
1140+
auto f(this auto) -> S;
1141+
bool g() { return f(); } // expected-error {{no viable conversion from returned value of type 'S' to function return type 'bool'}}
1142+
};
1143+
}

0 commit comments

Comments
 (0)