From 65b63ec1410f09e1f3cdb847018d678b8f8fc3f7 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 8 Sep 2010 21:32:35 +0000 Subject: [PATCH] Re-enable CheckAccessDeclContext and make sure it doesn't trigger assertions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113413 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclCXX.h | 5 +++++ lib/AST/DeclBase.cpp | 10 ++++++---- lib/Serialization/ASTReaderDecl.cpp | 3 +-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index a9802bfcaf..3db147c1ab 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -112,6 +112,8 @@ class AccessSpecDecl : public Decl { : Decl(AccessSpec, DC, ASLoc), ColonLoc(ColonLoc) { setAccess(AS); } + AccessSpecDecl(EmptyShell Empty) + : Decl(AccessSpec, Empty) { } public: /// getAccessSpecifierLoc - The location of the access specifier. SourceLocation getAccessSpecifierLoc() const { return getLocation(); } @@ -132,6 +134,9 @@ public: SourceLocation ColonLoc) { return new (C) AccessSpecDecl(AS, DC, ASLoc, ColonLoc); } + static AccessSpecDecl *Create(ASTContext &C, EmptyShell Empty) { + return new (C) AccessSpecDecl(Empty); + } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 0b958fe82b..7525b34d88 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -418,18 +418,20 @@ SourceLocation Decl::getBodyRBrace() const { #ifndef NDEBUG void Decl::CheckAccessDeclContext() const { - // FIXME: Disable this until rdar://8146294 "access specifier for inner class - // templates is not set or checked" is fixed. - return; // Suppress this check if any of the following hold: // 1. this is the translation unit (and thus has no parent) // 2. this is a template parameter (and thus doesn't belong to its context) // 3. the context is not a record // 4. it's invalid + // 5. it's a C++0x static_assert. if (isa(this) || isa(this) || !isa(getDeclContext()) || - isInvalidDecl()) + isInvalidDecl() || + isa(this) || + // FIXME: a ParmVarDecl can have ClassTemplateSpecialization + // as DeclContext (?). + isa(this)) return; assert(Access != AS_none && diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 653878209f..995139830d 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1308,8 +1308,7 @@ Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) { D = CXXConversionDecl::Create(*Context, Decl::EmptyShell()); break; case DECL_ACCESS_SPEC: - D = AccessSpecDecl::Create(*Context, AS_none, 0, SourceLocation(), - SourceLocation()); + D = AccessSpecDecl::Create(*Context, Decl::EmptyShell()); break; case DECL_FRIEND: D = FriendDecl::Create(*Context, Decl::EmptyShell()); -- 2.50.1