[cfe-commits] r127735 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp

Abramo Bagnara abramo.bagnara at gmail.com
Wed Mar 16 08:08:46 PDT 2011


Author: abramo
Date: Wed Mar 16 10:08:46 2011
New Revision: 127735

URL: http://llvm.org/viewvc/llvm-project?rev=127735&view=rev
Log:
Added missing methods to get Designators source range.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=127735&r1=127734&r2=127735&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Mar 16 10:08:46 2011
@@ -3489,6 +3489,12 @@
       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 @@
   void ExpandDesignator(ASTContext &C, unsigned Idx, const Designator *First,
                         const Designator *Last);
 
+  SourceRange getDesignatorsSourceRange() const;
+
   SourceRange getSourceRange() const;
 
   static bool classof(const Stmt *T) {

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=127735&r1=127734&r2=127735&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Mar 16 10:08:46 2011
@@ -2740,6 +2740,14 @@
     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 =





More information about the cfe-commits mailing list