diff options
author | Abramo Bagnara <abramo.bagnara@bugseng.com> | 2012-10-04 21:39:47 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@bugseng.com> | 2012-10-04 21:39:47 +0000 |
commit | 856c4076a4c032b9945b93a86f19d98496db647a (patch) | |
tree | 0a120222eb9259d68bb1a8e7295dcca3c930613c | |
parent | 71f32c14b1a87bdbd21bc684ae72a11bb61b134e (diff) | |
download | bcm5719-llvm-856c4076a4c032b9945b93a86f19d98496db647a.tar.gz bcm5719-llvm-856c4076a4c032b9945b93a86f19d98496db647a.zip |
Fixed friend decl source range.
llvm-svn: 165257
-rw-r--r-- | clang/include/clang/AST/DeclFriend.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/include/clang/AST/DeclFriend.h b/clang/include/clang/AST/DeclFriend.h index a5f736739b1..b40144388ad 100644 --- a/clang/include/clang/AST/DeclFriend.h +++ b/clang/include/clang/AST/DeclFriend.h @@ -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 @@ public: /// 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 |