[cfe-commits] r165257 - /cfe/trunk/include/clang/AST/DeclFriend.h

Abramo Bagnara abramo.bagnara at bugseng.com
Thu Oct 4 14:39:47 PDT 2012


Author: abramo
Date: Thu Oct  4 16:39:47 2012
New Revision: 165257

URL: http://llvm.org/viewvc/llvm-project?rev=165257&view=rev
Log:
Fixed friend decl source range.

Modified:
    cfe/trunk/include/clang/AST/DeclFriend.h

Modified: cfe/trunk/include/clang/AST/DeclFriend.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclFriend.h?rev=165257&r1=165256&r2=165257&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclFriend.h (original)
+++ cfe/trunk/include/clang/AST/DeclFriend.h Thu Oct  4 16:39:47 2012
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_AST_DECLFRIEND_H
 
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {
@@ -104,10 +105,15 @@
 
   /// Retrieves the source range for the friend declaration.
   SourceRange getSourceRange() const LLVM_READONLY {
-    // FIXME: If this is a friend function declaration, the 'friend' keyword
-    // might not be the first token of the declaration.
-    if (NamedDecl *ND = getFriendDecl())
+    if (NamedDecl *ND = getFriendDecl()) {
+      if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(ND))
+        return FTD->getSourceRange();
+      if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(ND)) {
+        if (DD->getOuterLocStart() != DD->getInnerLocStart())
+          return DD->getSourceRange();
+      }
       return SourceRange(getFriendLoc(), ND->getLocEnd());
+    }
     else if (TypeSourceInfo *TInfo = getFriendType())
       return SourceRange(getFriendLoc(), TInfo->getTypeLoc().getEndLoc());
     else





More information about the cfe-commits mailing list