diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h b/contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h index 38a0ff5..79d1817 100644 --- a/contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h +++ b/contrib/llvm/tools/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 { @@ -28,12 +29,14 @@ enum DeclUpdateKind { UPD_CXX_ADDED_FUNCTION_DEFINITION, UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER, UPD_CXX_INSTANTIATED_CLASS_DEFINITION, + UPD_CXX_RESOLVED_DTOR_DELETE, UPD_CXX_RESOLVED_EXCEPTION_SPEC, UPD_CXX_DEDUCED_RETURN_TYPE, UPD_DECL_MARKED_USED, UPD_MANGLING_NUMBER, UPD_STATIC_LOCAL_NUMBER, - UPD_DECL_MARKED_OPENMP_THREADPRIVATE + UPD_DECL_MARKED_OPENMP_THREADPRIVATE, + UPD_DECL_EXPORTED }; TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT); @@ -85,6 +88,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 |