Fixed friend decl source range.

llvm-svn: 165257
This commit is contained in:
Abramo Bagnara 2012-10-04 21:39:47 +00:00
parent 71f32c14b1
commit 856c4076a4
1 changed files with 9 additions and 3 deletions

View File

@ -16,6 +16,7 @@
#define LLVM_CLANG_AST_DECLFRIEND_H #define LLVM_CLANG_AST_DECLFRIEND_H
#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -104,10 +105,15 @@ public:
/// Retrieves the source range for the friend declaration. /// Retrieves the source range for the friend declaration.
SourceRange getSourceRange() const LLVM_READONLY { SourceRange getSourceRange() const LLVM_READONLY {
// FIXME: If this is a friend function declaration, the 'friend' keyword if (NamedDecl *ND = getFriendDecl()) {
// might not be the first token of the declaration. if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(ND))
if (NamedDecl *ND = getFriendDecl()) return FTD->getSourceRange();
if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(ND)) {
if (DD->getOuterLocStart() != DD->getInnerLocStart())
return DD->getSourceRange();
}
return SourceRange(getFriendLoc(), ND->getLocEnd()); return SourceRange(getFriendLoc(), ND->getLocEnd());
}
else if (TypeSourceInfo *TInfo = getFriendType()) else if (TypeSourceInfo *TInfo = getFriendType())
return SourceRange(getFriendLoc(), TInfo->getTypeLoc().getEndLoc()); return SourceRange(getFriendLoc(), TInfo->getTypeLoc().getEndLoc());
else else