================
@@ -3187,9 +3216,59 @@ class CallExpr : public Expr {
   SourceLocation getRParenLoc() const { return RParenLoc; }
   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
 
-  SourceLocation getBeginLoc() const LLVM_READONLY;
-  SourceLocation getEndLoc() const LLVM_READONLY;
+  template <unsigned N> SourceLocation getTrailingSourceLoc() const {
+    static_assert(N <= 1);
+    assert(CallExprBits.HasTrailingSourceLocs && "No trailing source loc");
+    static_assert(sizeof(CallExpr) <=
+                  offsetToTrailingObjects + 2 * sizeof(SourceLocation));
+    return *reinterpret_cast<const SourceLocation *>(
+        reinterpret_cast<const char *>(this) + sizeof(CallExpr) +
+        sizeof(SourceLocation) * N);
+  }
+
+  SourceLocation getBeginLoc() const {
+    if (CallExprBits.HasTrailingSourceLocs)
+      return getTrailingSourceLoc<0>();
+
+    if (usesMemberSyntax()) {
+      if (auto FirstArgLoc = getArg(0)->getBeginLoc(); FirstArgLoc.isValid()) {
+        return FirstArgLoc;
+      }
+    }
+    return getCallee()->getBeginLoc();
+  }
+
+  SourceLocation getEndLoc() const {
+    if (CallExprBits.HasTrailingSourceLocs)
+      return getTrailingSourceLoc<0>();
+
+    SourceLocation end = getRParenLoc();
----------------
AaronBallman wrote:

```suggestion
    SourceLocation End = getRParenLoc();
```

https://github.com/llvm/llvm-project/pull/141058
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to