@@ -2911,11 +2911,10 @@ class CallExpr : public Expr {
29112911 // itself is 24 bytes. To avoid having to recompute or store the offset of the
29122912 // trailing objects, we put it at 32 bytes (such that it is suitable for all
29132913 // subclasses) We use the 8 bytes gap left for instances of CallExpr to store
2914- // the begin and end source locations. Caching the begin source location in
2915- // particular as a significant impact on perf as getBeginLoc is assumed to be
2916- // cheap.
2914+ // the begin source location, which has a significant impact on perf as
2915+ // getBeginLoc is assumed to be cheap.
29172916 // The layourt is as follow:
2918- // CallExpr | Begin | End | Trailing Objects
2917+ // CallExpr | Begin | 4 bytes left | Trailing Objects
29192918 // CXXMemberCallExpr | Trailing Objects
29202919 // A bit in CallExprBitfields indicates if source locations are presents.
29212920
@@ -3051,9 +3050,9 @@ class CallExpr : public Expr {
30513050 CallExprBits.ExplicitObjectMemFunUsingMemberSyntax = V;
30523051 // Because the source location may be different for explicit
30533052 // member, we reset the cached values.
3054- if (CallExprBits.HasTrailingSourceLocs ) {
3055- CallExprBits.HasTrailingSourceLocs = false ;
3056- updateTrailingSourceLocs ();
3053+ if (CallExprBits.HasTrailingSourceLoc ) {
3054+ CallExprBits.HasTrailingSourceLoc = false ;
3055+ updateTrailingSourceLoc ();
30573056 }
30583057 }
30593058
@@ -3216,19 +3215,14 @@ class CallExpr : public Expr {
32163215 SourceLocation getRParenLoc () const { return RParenLoc; }
32173216 void setRParenLoc (SourceLocation L) { RParenLoc = L; }
32183217
3219- template <unsigned N> SourceLocation getTrailingSourceLoc () const {
3220- static_assert (N <= 1 );
3221- assert (CallExprBits.HasTrailingSourceLocs && " No trailing source loc" );
3222- static_assert (sizeof (CallExpr) <=
3223- offsetToTrailingObjects + 2 * sizeof (SourceLocation));
3224- return *reinterpret_cast <const SourceLocation *>(
3225- reinterpret_cast <const char *>(this ) + sizeof (CallExpr) +
3226- sizeof (SourceLocation) * N);
3227- }
3228-
32293218 SourceLocation getBeginLoc () const {
3230- if (CallExprBits.HasTrailingSourceLocs )
3231- return getTrailingSourceLoc<0 >();
3219+ if (CallExprBits.HasTrailingSourceLoc ) {
3220+ assert (CallExprBits.HasTrailingSourceLoc && " No trailing source loc" );
3221+ static_assert (sizeof (CallExpr) <=
3222+ offsetToTrailingObjects + sizeof (SourceLocation));
3223+ return *reinterpret_cast <const SourceLocation *>(
3224+ reinterpret_cast <const char *>(this ) + sizeof (CallExpr));
3225+ }
32323226
32333227 if (usesMemberSyntax ()) {
32343228 if (auto FirstArgLoc = getArg (0 )->getBeginLoc (); FirstArgLoc.isValid ()) {
@@ -3239,22 +3233,17 @@ class CallExpr : public Expr {
32393233 }
32403234
32413235 SourceLocation getEndLoc () const {
3242- if (CallExprBits.HasTrailingSourceLocs )
3243- return getTrailingSourceLoc<0 >();
3244-
3245- SourceLocation end = getRParenLoc ();
3246- if (end.isInvalid () && getNumArgs () > 0 && getArg (getNumArgs () - 1 ))
3247- end = getArg (getNumArgs () - 1 )->getEndLoc ();
3248- return end;
3236+ return getRParenLoc ();
32493237 }
32503238
32513239private:
3240+ friend class ASTStmtReader ;
32523241 bool hasTrailingSourceLoc () const {
3253- return CallExprBits.HasTrailingSourceLocs ;
3242+ return CallExprBits.HasTrailingSourceLoc ;
32543243 }
32553244
3256- void updateTrailingSourceLocs () {
3257- assert (!CallExprBits.HasTrailingSourceLocs &&
3245+ void updateTrailingSourceLoc () {
3246+ assert (!CallExprBits.HasTrailingSourceLoc &&
32583247 " Trailing source loc already set?" );
32593248 assert (getStmtClass () == CallExprClass &&
32603249 " Calling setTrailingSourceLocs on a subclass of CallExpr" );
@@ -3264,8 +3253,7 @@ class CallExpr : public Expr {
32643253 SourceLocation *Locs = reinterpret_cast <SourceLocation *>(
32653254 reinterpret_cast <char *>(this ) + sizeof (CallExpr));
32663255 new (Locs) SourceLocation (getBeginLoc ());
3267- new (Locs + 1 ) SourceLocation (getEndLoc ());
3268- CallExprBits.HasTrailingSourceLocs = true ;
3256+ CallExprBits.HasTrailingSourceLoc = true ;
32693257 }
32703258
32713259public:
0 commit comments