mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-03 19:32:35 +00:00
74d28bd084
This commit 'introduces' a slightly different way to restore the state of the AST object. It makes PCHDeclReader/PCHDeclWriter friends and gives them access to the private members of the object. The rationale is to avoid using/modifying the AST interfaces for PCH read/write so that to: -Avoid complications with objects that have side-effects during creation or when using some setters. -Not 'pollute' the AST interface with methods only used by the PCH reader/writer -Allow AST objects to be read-only. llvm-svn: 107219
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
//===--- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation --===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the AST classes related to C++ friend
|
|
// declarations.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/AST/DeclFriend.h"
|
|
#include "clang/AST/DeclTemplate.h"
|
|
using namespace clang;
|
|
|
|
FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
|
|
SourceLocation L,
|
|
FriendUnion Friend,
|
|
SourceLocation FriendL) {
|
|
#ifndef NDEBUG
|
|
if (Friend.is<NamedDecl*>()) {
|
|
NamedDecl *D = Friend.get<NamedDecl*>();
|
|
assert(isa<FunctionDecl>(D) ||
|
|
isa<CXXRecordDecl>(D) ||
|
|
isa<FunctionTemplateDecl>(D) ||
|
|
isa<ClassTemplateDecl>(D));
|
|
|
|
// As a temporary hack, we permit template instantiation to point
|
|
// to the original declaration when instantiating members.
|
|
assert(D->getFriendObjectKind() ||
|
|
(cast<CXXRecordDecl>(DC)->getTemplateSpecializationKind()));
|
|
}
|
|
#endif
|
|
|
|
FriendDecl *FD = new (C) FriendDecl(DC, L, Friend, FriendL);
|
|
cast<CXXRecordDecl>(DC)->pushFriendDecl(FD);
|
|
return FD;
|
|
}
|
|
|
|
FriendDecl *FriendDecl::Create(ASTContext &C, EmptyShell Empty) {
|
|
return new (C) FriendDecl(Empty);
|
|
}
|