summaryrefslogtreecommitdiff
path: root/include/clang/AST/Expr.h
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2018-11-20 16:09:45 +0000
committerBruno Ricci <riccibrun@gmail.com>2018-11-20 16:09:45 +0000
commit2e4589c2678110f3982adf08a904ad19caefe0a8 (patch)
treed4c6854e4a1e5778e49e07d27cb9c20fbc341bb4 /include/clang/AST/Expr.h
parentb03ce7b86b90fbdfd4f08e304f3f963ce9bfbe6f (diff)
downloadclang-2e4589c2678110f3982adf08a904ad19caefe0a8.tar.gz
[AST][NFC] Factor out some repeated code in ArraySubscriptExpr.
Factor out the test for whether the LHS is the base of the array subscript expression into a private method lhsIsBase. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/Expr.h')
-rw-r--r--include/clang/AST/Expr.h20
1 files changed, 6 insertions, 14 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index fbf8bc4cf2..c2aa8fd767 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -2318,6 +2318,8 @@ class ArraySubscriptExpr : public Expr {
enum { LHS, RHS, END_EXPR };
Stmt *SubExprs[END_EXPR];
+ bool lhsIsBase() const { return getRHS()->getType()->isIntegerType(); }
+
public:
ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t,
ExprValueKind VK, ExprObjectKind OK,
@@ -2355,21 +2357,11 @@ public:
const Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
void setRHS(Expr *E) { SubExprs[RHS] = E; }
- Expr *getBase() {
- return getRHS()->getType()->isIntegerType() ? getLHS() : getRHS();
- }
-
- const Expr *getBase() const {
- return getRHS()->getType()->isIntegerType() ? getLHS() : getRHS();
- }
+ Expr *getBase() { return lhsIsBase() ? getLHS() : getRHS(); }
+ const Expr *getBase() const { return lhsIsBase() ? getLHS() : getRHS(); }
- Expr *getIdx() {
- return getRHS()->getType()->isIntegerType() ? getRHS() : getLHS();
- }
-
- const Expr *getIdx() const {
- return getRHS()->getType()->isIntegerType() ? getRHS() : getLHS();
- }
+ Expr *getIdx() { return lhsIsBase() ? getRHS() : getLHS(); }
+ const Expr *getIdx() const { return lhsIsBase() ? getRHS() : getLHS(); }
SourceLocation getBeginLoc() const LLVM_READONLY {
return getLHS()->getBeginLoc();