Skip to content

Commit 7472299

Browse files
committed
revert changes to explicit object member functions
1 parent 21cf4b4 commit 7472299

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

clang/include/clang/AST/Expr.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,7 +3227,19 @@ class CallExpr : public Expr {
32273227
return getCallee()->getBeginLoc();
32283228
}
32293229

3230-
SourceLocation getEndLoc() const LLVM_READONLY;
3230+
SourceLocation getEndLoc() const {
3231+
if(CallExprBits.HasTrailingSourceLoc) {
3232+
static_assert(sizeof(CallExpr) <= offsetToTrailingObjects + 2 * sizeof(SourceLocation));
3233+
return *reinterpret_cast<const SourceLocation*>(reinterpret_cast<const char *>(this) +
3234+
sizeof(CallExpr) + sizeof(SourceLocation));
3235+
}
3236+
3237+
SourceLocation end = getRParenLoc();
3238+
if (end.isInvalid() && getNumArgs() > 0 && getArg(getNumArgs() - 1))
3239+
end = getArg(getNumArgs() - 1)->getEndLoc();
3240+
return end;
3241+
}
3242+
32313243

32323244
private:
32333245
friend class ASTStmtReader;
@@ -3239,8 +3251,8 @@ class CallExpr : public Expr {
32393251
static_assert(sizeof(CallExpr) <= offsetToTrailingObjects + 2 * sizeof(SourceLocation));
32403252
SourceLocation* Locs = reinterpret_cast<SourceLocation*>(reinterpret_cast<char *>(this) +
32413253
sizeof(CallExpr));
3242-
Locs[0] = getBeginLoc();
3243-
Locs[1] = getEndLoc();
3254+
new (Locs) SourceLocation(getBeginLoc());
3255+
new (Locs+1) SourceLocation(getEndLoc());
32443256
CallExprBits.HasTrailingSourceLoc = true;
32453257
}
32463258

clang/include/clang/AST/NestedNameSpecifier.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ class NestedNameSpecifierLoc {
283283
/// For example, if this instance refers to a nested-name-specifier
284284
/// \c \::std::vector<int>::, the returned source range would cover
285285
/// from the initial '::' to the last '::'.
286-
SourceRange getSourceRange() const LLVM_READONLY;
286+
SourceRange getSourceRange() const LLVM_READONLY {
287+
return SourceRange(getBeginLoc(), getEndLoc());
288+
}
287289

288290
/// Retrieve the source range covering just the last part of
289291
/// this nested-name-specifier, not including the prefix.
@@ -296,13 +298,19 @@ class NestedNameSpecifierLoc {
296298
/// Retrieve the location of the beginning of this
297299
/// nested-name-specifier.
298300
SourceLocation getBeginLoc() const {
299-
return getSourceRange().getBegin();
301+
if (!Qualifier)
302+
return SourceLocation();
303+
304+
NestedNameSpecifierLoc First = *this;
305+
while (NestedNameSpecifierLoc Prefix = First.getPrefix())
306+
First = Prefix;
307+
return First.getLocalSourceRange().getBegin();
300308
}
301309

302310
/// Retrieve the location of the end of this
303311
/// nested-name-specifier.
304312
SourceLocation getEndLoc() const {
305-
return getSourceRange().getEnd();
313+
return getLocalSourceRange().getEnd();
306314
}
307315

308316
/// Retrieve the location of the beginning of this

clang/lib/AST/Expr.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,15 +1627,6 @@ CallExpr::getUnusedResultAttr(const ASTContext &Ctx) const {
16271627
return {nullptr, nullptr};
16281628
}
16291629

1630-
SourceLocation CallExpr::getEndLoc() const {
1631-
if (const auto *OCE = dyn_cast<CXXOperatorCallExpr>(this))
1632-
return OCE->getEndLoc();
1633-
1634-
SourceLocation end = getRParenLoc();
1635-
if (end.isInvalid() && getNumArgs() > 0 && getArg(getNumArgs() - 1))
1636-
end = getArg(getNumArgs() - 1)->getEndLoc();
1637-
return end;
1638-
}
16391630

16401631
OffsetOfExpr *OffsetOfExpr::Create(const ASTContext &C, QualType type,
16411632
SourceLocation OperatorLoc,

clang/lib/AST/NestedNameSpecifier.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -407,18 +407,6 @@ static void *LoadPointer(void *Data, unsigned Offset) {
407407
return Result;
408408
}
409409

410-
SourceRange NestedNameSpecifierLoc::getSourceRange() const {
411-
if (!Qualifier)
412-
return SourceRange();
413-
414-
NestedNameSpecifierLoc First = *this;
415-
while (NestedNameSpecifierLoc Prefix = First.getPrefix())
416-
First = Prefix;
417-
418-
return SourceRange(First.getLocalSourceRange().getBegin(),
419-
getLocalSourceRange().getEnd());
420-
}
421-
422410
SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const {
423411
if (!Qualifier)
424412
return SourceRange();

0 commit comments

Comments
 (0)