[clang] [clang] Remove source range from CXXOperatorCallExpr (PR #147028)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 4 12:52:26 PDT 2025
================
@@ -158,9 +158,9 @@ class CXXOperatorCallExpr final : public CallExpr {
: getOperatorLoc();
}
- SourceLocation getBeginLoc() const { return Range.getBegin(); }
- SourceLocation getEndLoc() const { return Range.getEnd(); }
- SourceRange getSourceRange() const { return Range; }
+ SourceLocation getBeginLoc() const { return BeginLoc; }
+ SourceLocation getEndLoc() const { return getSourceRangeImpl().getEnd(); }
----------------
hokein wrote:
We could do this, and apply the same approach to `getBeginLocImpl` as well. However, I’m not sure it’s a good idea to split `getSourceRangeImpl` across two places -- it makes the logic harder to follow and reason about.
I actually tried this approach in an earlier version of the patch, but didn’t observe any performance benefit. Personally, I prefer the current version, which keeps all the logic centralized in getSourceRangeImpl for better maintainability and clarity.
https://github.com/llvm/llvm-project/pull/147028
More information about the cfe-commits
mailing list