@@ -2916,7 +2916,7 @@ class CallExpr : public Expr {
29162916 // The layourt is as follow:
29172917 // CallExpr | Begin | 4 bytes left | Trailing Objects
29182918 // CXXMemberCallExpr | Trailing Objects
2919- // A bit in CallExprBitfields indicates if source locations are presents .
2919+ // A bit in CallExprBitfields indicates if source locations are present .
29202920
29212921protected:
29222922 static constexpr unsigned OffsetToTrailingObjects = 32 ;
@@ -3031,7 +3031,7 @@ class CallExpr : public Expr {
30313031
30323032 Expr *getCallee () { return cast<Expr>(getTrailingStmts ()[FN]); }
30333033 const Expr *getCallee () const { return cast<Expr>(getTrailingStmts ()[FN]); }
3034- void setCallee (Expr *F) { getTrailingStmts ()[FN] = F; }
3034+ void setCallee (Expr *F) { getTrailingStmts ()[FN] = F;}
30353035
30363036 ADLCallKind getADLCallKind () const {
30373037 return static_cast <ADLCallKind>(CallExprBits.UsesADL );
@@ -3217,19 +3217,21 @@ class CallExpr : public Expr {
32173217
32183218 SourceLocation getBeginLoc () const {
32193219 if (CallExprBits.HasTrailingSourceLoc ) {
3220- assert (CallExprBits.HasTrailingSourceLoc && " No trailing source loc" );
32213220 static_assert (sizeof (CallExpr) <=
32223221 OffsetToTrailingObjects + sizeof (SourceLocation));
32233222 return *reinterpret_cast <const SourceLocation *>(
32243223 reinterpret_cast <const char *>(this + 1 ));
32253224 }
32263225
3227- if (usesMemberSyntax ()) {
3228- if (auto FirstArgLoc = getArg (0 )->getBeginLoc (); FirstArgLoc.isValid ()) {
3226+ if (usesMemberSyntax ())
3227+ if (auto FirstArgLoc = getArg (0 )->getBeginLoc (); FirstArgLoc.isValid ())
32293228 return FirstArgLoc;
3230- }
3231- }
3232- return getCallee ()->getBeginLoc ();
3229+
3230+ // FIXME: Some builtins have no callee begin location
3231+ SourceLocation begin = getCallee ()->getBeginLoc ();
3232+ if (begin.isInvalid () && getNumArgs () > 0 && getArg (0 ))
3233+ begin = getArg (0 )->getBeginLoc ();
3234+ return begin;
32333235 }
32343236
32353237 SourceLocation getEndLoc () const { return getRParenLoc (); }
0 commit comments