]> granicus.if.org Git - clang/commitdiff
Fixed end location of FriendDecl.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Fri, 4 Mar 2011 10:59:18 +0000 (10:59 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Fri, 4 Mar 2011 10:59:18 +0000 (10:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126993 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclFriend.h

index 20d6da19b8ca0d95c57d0a5897be63db1be3b843..b84e5bba86b7e47c97d552c6d8e992578fa26939 100644 (file)
@@ -98,6 +98,17 @@ public:
     return FriendLoc;
   }
 
+  /// Retrieves the source range for the friend declaration.
+  SourceRange getSourceRange() const {
+    /* FIXME: consider the case of templates wrt start of range. */
+    if (NamedDecl *ND = getFriendDecl())
+      return SourceRange(getFriendLoc(), ND->getLocEnd());
+    else if (TypeSourceInfo *TInfo = getFriendType())
+      return SourceRange(getFriendLoc(), TInfo->getTypeLoc().getEndLoc());
+    else
+      return SourceRange(getFriendLoc(), getLocation());
+  }
+
   /// Determines if this friend kind is unsupported.
   bool isUnsupportedFriend() const {
     return UnsupportedFriend;