]> granicus.if.org Git - clang/commitdiff
Added missing methods to get Designators source range.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Wed, 16 Mar 2011 15:08:46 +0000 (15:08 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Wed, 16 Mar 2011 15:08:46 +0000 (15:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127735 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/Expr.cpp

index 23e42768e8657acb937cd26af199881199ce3cd7..35264b820daff38d606f9a1bade95d3e96c5b38b 100644 (file)
@@ -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) {
index 9c4444225eed2336a7b0a5040d3e60350e878eef..59de3fe6eec037fc17744a5b6c9450dabb12bc4f 100644 (file)
@@ -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 =