Decl *Expr::getReferencedDeclOfCallee() {
Expr *CEE = IgnoreParenImpCasts();
- while (SubstNonTypeTemplateParmExpr *NTTP =
- dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
+ while (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE))
CEE = NTTP->getReplacement()->IgnoreParenImpCasts();
- }
// If we're calling a dereference, look at the pointer instead.
while (true) {
- if (BinaryOperator *BO = dyn_cast<BinaryOperator>(CEE)) {
+ if (auto *BO = dyn_cast<BinaryOperator>(CEE)) {
if (BO->isPtrMemOp()) {
CEE = BO->getRHS()->IgnoreParenImpCasts();
continue;
}
- } else if (UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
+ } else if (auto *UO = dyn_cast<UnaryOperator>(CEE)) {
if (UO->getOpcode() == UO_Deref || UO->getOpcode() == UO_AddrOf ||
UO->getOpcode() == UO_Plus) {
CEE = UO->getSubExpr()->IgnoreParenImpCasts();
break;
}
- if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
+ if (auto *DRE = dyn_cast<DeclRefExpr>(CEE))
return DRE->getDecl();
- if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
+ if (auto *ME = dyn_cast<MemberExpr>(CEE))
return ME->getMemberDecl();
if (auto *BE = dyn_cast<BlockExpr>(CEE))
return BE->getBlockDecl();
/// If this is a call to a builtin, return the builtin ID. If not, return 0.
unsigned CallExpr::getBuiltinCallee() const {
- auto *FDecl = getDirectCallee();
+ const auto *FDecl = getDirectCallee();
return FDecl ? FDecl->getBuiltinID() : 0;
}
}
SourceLocation CallExpr::getBeginLoc() const {
- if (isa<CXXOperatorCallExpr>(this))
- return cast<CXXOperatorCallExpr>(this)->getBeginLoc();
+ if (const auto *OCE = dyn_cast<CXXOperatorCallExpr>(this))
+ return OCE->getBeginLoc();
SourceLocation begin = getCallee()->getBeginLoc();
if (begin.isInvalid() && getNumArgs() > 0 && getArg(0))
return begin;
}
SourceLocation CallExpr::getEndLoc() const {
- if (isa<CXXOperatorCallExpr>(this))
- return cast<CXXOperatorCallExpr>(this)->getEndLoc();
+ if (const auto *OCE = dyn_cast<CXXOperatorCallExpr>(this))
+ return OCE->getEndLoc();
SourceLocation end = getRParenLoc();
if (end.isInvalid() && getNumArgs() > 0 && getArg(getNumArgs() - 1))
namespace {
// Skip over implicit nodes produced as part of semantic analysis.
// Designed for use with IgnoreExprNodes.
-Expr *ignoreImplicitSemaNodes(Expr *E) {
+static Expr *ignoreImplicitSemaNodes(Expr *E) {
if (auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
return Materialize->getSubExpr();
bool BinaryOperator::isNullPointerArithmeticExtension(ASTContext &Ctx,
Opcode Opc,
- Expr *LHS, Expr *RHS) {
+ const Expr *LHS,
+ const Expr *RHS) {
if (Opc != BO_Add)
return false;
// Check that we have one pointer and one integer operand.
- Expr *PExp;
+ const Expr *PExp;
if (LHS->getType()->isPointerType()) {
if (!RHS->getType()->isIntegerType())
return false;