aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/DeclFriend.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/DeclFriend.h')
-rw-r--r--include/clang/AST/DeclFriend.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h
index be6f2eb3e3ad..12b93b408a70 100644
--- a/include/clang/AST/DeclFriend.h
+++ b/include/clang/AST/DeclFriend.h
@@ -17,6 +17,7 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/TypeLoc.h"
#include "llvm/Support/Compiler.h"
namespace clang {
@@ -91,7 +92,7 @@ private:
FriendDecl *getNextFriend() {
if (!NextFriend.isOffset())
- return cast_or_null<FriendDecl>(NextFriend.get(0));
+ return cast_or_null<FriendDecl>(NextFriend.get(nullptr));
return getNextFriendSlowCase();
}
FriendDecl *getNextFriendSlowCase();
@@ -132,10 +133,14 @@ public:
}
/// Retrieves the source range for the friend declaration.
- SourceRange getSourceRange() const LLVM_READONLY {
+ SourceRange getSourceRange() const override LLVM_READONLY {
if (NamedDecl *ND = getFriendDecl()) {
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND))
+ return FD->getSourceRange();
if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(ND))
return FTD->getSourceRange();
+ if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(ND))
+ return CTD->getSourceRange();
if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(ND)) {
if (DD->getOuterLocStart() != DD->getInnerLocStart())
return DD->getSourceRange();
@@ -224,7 +229,11 @@ inline CXXRecordDecl::friend_iterator CXXRecordDecl::friend_begin() const {
}
inline CXXRecordDecl::friend_iterator CXXRecordDecl::friend_end() const {
- return friend_iterator(0);
+ return friend_iterator(nullptr);
+}
+
+inline CXXRecordDecl::friend_range CXXRecordDecl::friends() const {
+ return friend_range(friend_begin(), friend_end());
}
inline void CXXRecordDecl::pushFriendDecl(FriendDecl *FD) {