Skip to content

Commit f2d2b83

Browse files
committed
Get rid of the Range in CXXOperatorCallExpr.
1 parent 67c3a59 commit f2d2b83

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

clang/include/clang/AST/Expr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,19 +2905,19 @@ class CallExpr : public Expr {
29052905
//
29062906
// * An optional of type FPOptionsOverride.
29072907
//
2908-
// CallExpr subclasses are asssumed to be 40 bytes or less, and CallExpr
2908+
// CallExpr subclasses are asssumed to be 32 bytes or less, and CallExpr
29092909
// itself is 24 bytes. To avoid having to recompute or store the offset of the
2910-
// trailing objects, we put it at 40 bytes (such that it is suitable for all
2910+
// trailing objects, we put it at 32 bytes (such that it is suitable for all
29112911
// subclasses) We use the 8 bytes gap left for instances of CallExpr to store
29122912
// the begin source location, which has a significant impact on perf as
29132913
// getBeginLoc is assumed to be cheap.
29142914
// The layourt is as follow:
2915-
// CallExpr | Begin | 8 bytes left | Trailing Objects
2915+
// CallExpr | Begin | Trailing Objects
29162916
// CXXMemberCallExpr | Trailing Objects
29172917
// A bit in CallExprBitfields indicates if source locations are present.
29182918

29192919
protected:
2920-
static constexpr unsigned OffsetToTrailingObjects = 40;
2920+
static constexpr unsigned OffsetToTrailingObjects = 32;
29212921
template <typename T>
29222922
static constexpr unsigned
29232923
sizeToAllocateForCallExprSubclass(unsigned SizeOfTrailingObjects) {

clang/include/clang/AST/ExprCXX.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CXXOperatorCallExpr final : public CallExpr {
8484
friend class ASTStmtReader;
8585
friend class ASTStmtWriter;
8686

87-
SourceRange Range;
87+
SourceLocation BeginLoc;
8888

8989
// CXXOperatorCallExpr has some trailing objects belonging
9090
// to CallExpr. See CallExpr for the details.
@@ -158,9 +158,9 @@ class CXXOperatorCallExpr final : public CallExpr {
158158
: getOperatorLoc();
159159
}
160160

161-
SourceLocation getBeginLoc() const { return Range.getBegin(); }
162-
SourceLocation getEndLoc() const { return Range.getEnd(); }
163-
SourceRange getSourceRange() const { return Range; }
161+
SourceLocation getBeginLoc() const { return BeginLoc; }
162+
SourceLocation getEndLoc() const { return getSourceRangeImpl().getEnd(); }
163+
SourceRange getSourceRange() const { return getSourceRangeImpl(); }
164164

165165
static bool classof(const Stmt *T) {
166166
return T->getStmtClass() == CXXOperatorCallExprClass;

clang/lib/AST/Expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,8 @@ static unsigned SizeOfCallExprInstance(Expr::StmtClass SC) {
14661466

14671467
// changing the size of SourceLocation, CallExpr, and
14681468
// subclasses requires careful considerations
1469-
static_assert(sizeof(SourceLocation) == 8 && sizeof(CXXOperatorCallExpr) <= 40,
1470-
"we assume CXXOperatorCallExpr is at most 40 bytes");
1469+
static_assert(sizeof(SourceLocation) == 8 && sizeof(CXXOperatorCallExpr) <= 32,
1470+
"we assume CXXOperatorCallExpr is at most 32 bytes");
14711471

14721472
CallExpr::CallExpr(StmtClass SC, Expr *Fn, ArrayRef<Expr *> PreArgs,
14731473
ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,

clang/lib/AST/ExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
600600
assert(
601601
(CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
602602
"OperatorKind overflow!");
603-
Range = getSourceRangeImpl();
603+
BeginLoc = getSourceRangeImpl().getBegin();
604604
}
605605

606606
CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures,

clang/lib/Serialization/ASTReaderStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
17351735
void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
17361736
VisitCallExpr(E);
17371737
E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1738-
E->Range = Record.readSourceRange();
1738+
E->BeginLoc = Record.readSourceLocation();
17391739
}
17401740

17411741
void ASTStmtReader::VisitCXXRewrittenBinaryOperator(

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2933,7 +2933,6 @@ void ASTWriter::WriteDeclAbbrevs() {
29332933
// CXXOperatorCallExpr
29342934
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
29352935
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2936-
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
29372936
CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
29382937

29392938
// Abbreviation for EXPR_CXX_MEMBER_CALL

clang/lib/Serialization/ASTWriterStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
17021702
void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
17031703
VisitCallExpr(E);
17041704
Record.push_back(E->getOperator());
1705-
Record.AddSourceRange(E->Range);
1705+
Record.AddSourceLocation(E->BeginLoc);
17061706

17071707
if (!E->hasStoredFPFeatures() && !static_cast<bool>(E->getADLCallKind()))
17081708
AbbrevToUse = Writer.getCXXOperatorCallExprAbbrev();

0 commit comments

Comments
 (0)