[clang] [Clang] Optimize some `getBeginLoc` implementations (PR #141058)

via cfe-commits cfe-commits at lists.llvm.org
Thu May 22 06:59:45 PDT 2025


================
@@ -3028,6 +3043,19 @@ class CallExpr : public Expr {
 
   bool hasStoredFPFeatures() const { return CallExprBits.HasFPFeatures; }
 
+  bool usesMemberSyntax() const {
+    return CallExprBits.ExplicitObjectMemFunUsingMemberSyntax;
+  }
+  void setUsesMemberSyntax(bool V = true) {
+    CallExprBits.ExplicitObjectMemFunUsingMemberSyntax = V;
+    // Because the source location may be different for explicit
+    // member, we reset the cached values.
+    if (CallExprBits.HasTrailingSourceLoc) {
+      CallExprBits.HasTrailingSourceLoc = false;
+      updateTrailingSourceLoc();
----------------
cor3ntin wrote:

I have not benchmarked - it avoids a branch in getBeginLoc (we would have to check that we _can_ cache, as subclasses can't)

https://github.com/llvm/llvm-project/pull/141058


More information about the cfe-commits mailing list