Skip to content

Commit fd278cd

Browse files
committed
Address more feedback
1 parent 3c34d90 commit fd278cd

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

clang/include/clang/AST/Expr.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

29212921
protected:
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(); }

clang/include/clang/AST/Stmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ class alignas(void *) Stmt {
566566
LLVM_PREFERRED_TYPE(bool)
567567
unsigned IsCoroElideSafe : 1;
568568

569-
/// Tracks When CallExpr is used to represent an explicit object
569+
/// Tracks when CallExpr is used to represent an explicit object
570570
/// member function, in order to adjust the begin location.
571571
LLVM_PREFERRED_TYPE(bool)
572572
unsigned ExplicitObjectMemFunUsingMemberSyntax : 1;

clang/lib/AST/Expr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ OverloadedOperatorKind UnaryOperator::getOverloadedOperator(Opcode Opc) {
14491449
//===----------------------------------------------------------------------===//
14501450
// Postfix Operators.
14511451
//===----------------------------------------------------------------------===//
1452-
1452+
#ifndef NDEBUG
14531453
static unsigned SizeOfCallExprInstance(Expr::StmtClass SC) {
14541454
switch (SC) {
14551455
case Expr::CallExprClass:
@@ -1466,6 +1466,7 @@ static unsigned SizeOfCallExprInstance(Expr::StmtClass SC) {
14661466
llvm_unreachable("unexpected class deriving from CallExpr!");
14671467
}
14681468
}
1469+
#endif
14691470

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

0 commit comments

Comments
 (0)