summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTCommon.h
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-02-07 03:11:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-02-07 03:11:11 +0000
commit2b5605751786a85f05da3b0a344aa832e582080f (patch)
tree6cc85ab594945f87cf525e7a5bbddff1b005d976 /clang/lib/Serialization/ASTCommon.h
parent635c2c4378c0ad112899810cb39248d4cc95e0cb (diff)
downloadbcm5719-llvm-2b5605751786a85f05da3b0a344aa832e582080f.tar.gz
bcm5719-llvm-2b5605751786a85f05da3b0a344aa832e582080f.zip
[modules] Treat friend declarations that are lexically within a dependent
context as anonymous for merging purposes. They can't be found by their names, so we merge them based on their position within the surrounding context. llvm-svn: 228485
Diffstat (limited to 'clang/lib/Serialization/ASTCommon.h')
-rw-r--r--clang/lib/Serialization/ASTCommon.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTCommon.h b/clang/lib/Serialization/ASTCommon.h
index 38a0ff5fbd4..88cdbcfe179 100644
--- a/clang/lib/Serialization/ASTCommon.h
+++ b/clang/lib/Serialization/ASTCommon.h
@@ -15,6 +15,7 @@
#define LLVM_CLANG_LIB_SERIALIZATION_ASTCOMMON_H
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclFriend.h"
#include "clang/Serialization/ASTBitCodes.h"
namespace clang {
@@ -85,6 +86,24 @@ bool isRedeclarableDeclKind(unsigned Kind);
/// declaration number.
bool needsAnonymousDeclarationNumber(const NamedDecl *D);
+/// \brief Visit each declaration within \c DC that needs an anonymous
+/// declaration number and call \p Visit with the declaration and its number.
+template<typename Fn> void numberAnonymousDeclsWithin(const DeclContext *DC,
+ Fn Visit) {
+ unsigned Index = 0;
+ for (Decl *LexicalD : DC->decls()) {
+ // For a friend decl, we care about the declaration within it, if any.
+ if (auto *FD = dyn_cast<FriendDecl>(LexicalD))
+ LexicalD = FD->getFriendDecl();
+
+ auto *ND = dyn_cast_or_null<NamedDecl>(LexicalD);
+ if (!ND || !needsAnonymousDeclarationNumber(ND))
+ continue;
+
+ Visit(ND, Index++);
+ }
+}
+
} // namespace serialization
} // namespace clang
OpenPOWER on IntegriCloud