[clang] [clang][AST] Handle implicit first argument in CallExpr::getBeginLoc() (PR #135757)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 15 00:47:24 PDT 2025
================
@@ -1652,8 +1652,11 @@ SourceLocation CallExpr::getBeginLoc() const {
if (!isTypeDependent()) {
if (const auto *Method =
dyn_cast_if_present<const CXXMethodDecl>(getCalleeDecl());
- Method && Method->isExplicitObjectMemberFunction())
- return getArg(0)->getBeginLoc();
+ Method && Method->isExplicitObjectMemberFunction()) {
+ if (auto FirstArgLoc = getArg(0)->getBeginLoc(); FirstArgLoc.isValid()) {
----------------
HighCommander4 wrote:
Note, I took the approach of falling through if `FirstArgLoc` is invalid for any reason; presumably we never want to return an invalid location when we might fall through to a valid one in `getCallee()->getBeginLoc()`.
We could alternatively make the check more specific, to e.g. `!getArg(0)->isImplicitCXXThis()`.
https://github.com/llvm/llvm-project/pull/135757
More information about the cfe-commits
mailing list