[clang] [Clang][NFC] Remove CallExpr::CreateTemporary (PR #130919)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 00:53:15 PDT 2025


================
@@ -1655,14 +1645,8 @@ SourceLocation CallExpr::getBeginLoc() const {
   if (!isTypeDependent()) {
     if (const auto *Method =
             dyn_cast_if_present<const CXXMethodDecl>(getCalleeDecl());
-        Method && Method->isExplicitObjectMemberFunction()) {
-      // Note: while we typically expect the call to have a first argument
-      // here, we can't assert it because in some cases it does not, e.g.
-      // calls created with CallExpr::CreateTemporary() during overload
-      // resolution.
-      if (getNumArgs() > 0 && getArg(0))
-        return getArg(0)->getBeginLoc();
-    }
+        Method && Method->isExplicitObjectMemberFunction())
+      return getArg(0)->getBeginLoc();
----------------
zyn0217 wrote:

I think we can revert that to
```cpp
      bool HasFirstArg = getNumArgs() > 0 && getArg(0);
      assert(HasFirstArg);
      if (HasFirstArg)
        return getArg(0)->getBeginLoc();
```

so at least we have an assertion here. WDYT?

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


More information about the cfe-commits mailing list