diff options
| author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2011-03-16 15:08:46 +0000 |
|---|---|---|
| committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2011-03-16 15:08:46 +0000 |
| commit | 22f8cd71178069508df3d6ff41c64558d610847d (patch) | |
| tree | cd0b12187b5e43687aa26701875fec4159a8a356 | |
| parent | d60e4101e6468c3540484c8f61671e83de3a33b9 (diff) | |
| download | bcm5719-llvm-22f8cd71178069508df3d6ff41c64558d610847d.tar.gz bcm5719-llvm-22f8cd71178069508df3d6ff41c64558d610847d.zip | |
Added missing methods to get Designators source range.
llvm-svn: 127735
| -rw-r--r-- | clang/include/clang/AST/Expr.h | 8 | ||||
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 23e42768e86..35264b820da 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -3489,6 +3489,12 @@ public: else return getLBracketLoc(); } + SourceLocation getEndLocation() const { + return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc(); + } + SourceRange getSourceRange() const { + return SourceRange(getStartLocation(), getEndLocation()); + } }; static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators, @@ -3571,6 +3577,8 @@ public: void ExpandDesignator(ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last); + SourceRange getDesignatorsSourceRange() const; + SourceRange getSourceRange() const; static bool classof(const Stmt *T) { diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 9c4444225ee..59de3fe6eec 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2740,6 +2740,14 @@ void DesignatedInitExpr::setDesignators(ASTContext &C, Designators[I] = Desigs[I]; } +SourceRange DesignatedInitExpr::getDesignatorsSourceRange() const { + DesignatedInitExpr *DIE = const_cast<DesignatedInitExpr*>(this); + if (size() == 1) + return DIE->getDesignator(0)->getSourceRange(); + return SourceRange(DIE->getDesignator(0)->getStartLocation(), + DIE->getDesignator(size()-1)->getEndLocation()); +} + SourceRange DesignatedInitExpr::getSourceRange() const { SourceLocation StartLoc; Designator &First = |

