Home | History | Annotate | Download | only in AST

Lines Matching refs:Decl

10 // This file implements the Decl and DeclContext classes.
18 #include "clang/AST/Decl.h"
40 #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
41 #define ABSTRACT_DECL(DECL)
44 void Decl::updateOutOfDate(IdentifierInfo &II) const {
48 #define DECL(DERIVED, BASE) \
49 static_assert(llvm::AlignOf<Decl>::Alignment >= \
50 llvm::AlignOf<DERIVED##Decl>::Alignment, \
52 #define ABSTRACT_DECL(DECL)
55 void *Decl::operator new(std::size_t Size, const ASTContext &Context,
59 static_assert(sizeof(unsigned) * 2 >= llvm::AlignOf<Decl>::Alignment,
60 "Decl won't be misaligned");
75 void *Decl::operator new(std::size_t Size, const ASTContext &Ctx,
85 llvm::AlignOf<Decl>::Alignment);
94 Module *Decl::getOwningModuleSlow() const {
99 bool Decl::hasLocalOwningModuleStorage() const {
103 const char *Decl::getDeclKindName() const {
106 #define DECL(DERIVED, BASE) case DERIVED: return #DERIVED;
107 #define ABSTRACT_DECL(DECL)
112 void Decl::setInvalidDecl(bool Invalid) {
126 #define DECL(DERIVED, BASE) case Decl::DERIVED: return #DERIVED;
127 #define ABSTRACT_DECL(DECL)
132 bool Decl::StatisticsEnabled = false;
133 void Decl::EnableStatistics() {
137 void Decl::PrintStats() {
138 llvm::errs() << "\n*** Decl Stats:\n";
141 #define DECL(DERIVED, BASE) totalDecls += n##DERIVED##s;
142 #define ABSTRACT_DECL(DECL)
147 #define DECL(DERIVED, BASE) \
149 totalBytes += (int)(n##DERIVED##s * sizeof(DERIVED##Decl)); \
151 << sizeof(DERIVED##Decl) << " each (" \
152 << n##DERIVED##s * sizeof(DERIVED##Decl) \
155 #define ABSTRACT_DECL(DECL)
161 void Decl::add(Kind k) {
163 #define DECL(DERIVED, BASE) case DERIVED: ++n##DERIVED##s; break;
164 #define ABSTRACT_DECL(DECL)
169 bool Decl::isTemplateParameterPack() const {
181 bool Decl::isParameterPack() const {
188 FunctionDecl *Decl::getAsFunction() {
196 bool Decl::isTemplateDecl() const {
200 TemplateDecl *Decl::getDescribedTemplate() const {
211 const DeclContext *Decl::getParentFunctionOrMethod() const {
247 // Decl Implementation
250 // Out-of-line virtual method providing a home for Decl.
251 Decl::~Decl() { }
253 void Decl::setDeclContext(DeclContext *DC) {
257 void Decl::setLexicalDeclContext(DeclContext *DC) {
266 Hidden = cast<Decl>(DC)->Hidden;
269 void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC,
274 Decl::MultipleDC *MDC = new (Ctx) Decl::MultipleDC();
281 bool Decl::isLexicallyWithinFunctionOrMethod() const {
293 bool Decl::isInAnonymousNamespace() const {
304 bool Decl::isInStdNamespace() const {
308 TranslationUnitDecl *Decl::getTranslationUnitDecl() {
313 assert(DC && "This decl is not contained in a translation unit!");
317 assert(DC && "This decl is not contained in a translation unit!");
323 ASTContext &Decl::getASTContext() const {
327 ASTMutationListener *Decl::getASTMutationListener() const {
331 unsigned Decl::getMaxAlignment() const {
344 bool Decl::isUsed(bool CheckUsedAttr) const {
345 const Decl *CanonD = getCanonicalDecl();
350 // Ask the most recent decl, since attributes accumulate in the redecl chain.
359 void Decl::markUsed(ASTContext &C) {
369 bool Decl::isReferenced() const {
381 bool Decl::hasDefiningAttr() const {
385 const Attr *Decl::getDefiningAttr() const {
497 AvailabilityResult Decl::getAvailability(std::string *Message) const {
543 bool Decl::canBeWeakImported(bool &IsDefinition) const {
573 bool Decl::isWeakImported() const {
592 unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
704 void Decl::setAttrsImpl(const AttrVec &attrs, ASTContext &Ctx) {
705 assert(!HasAttrs && "Decl already contains attrs.");
714 void Decl::dropAttrs() {
721 const AttrVec &Decl::getAttrs() const {
726 Decl *Decl::castFromDeclContext (const DeclContext *D) {
727 Decl::Kind DK = D->getDeclKind();
729 #define DECL(NAME, BASE)
731 case Decl::NAME: \
732 return static_cast<NAME##Decl*>(const_cast<DeclContext*>(D));
736 #define DECL(NAME, BASE)
739 return static_cast<NAME##Decl*>(const_cast<DeclContext*>(D));
741 llvm_unreachable("a decl that inherits DeclContext isn't handled");
745 DeclContext *Decl::castToDeclContext(const Decl *D) {
746 Decl::Kind DK = D->getKind();
748 #define DECL(NAME, BASE)
750 case Decl::NAME: \
751 return static_cast<NAME##Decl*>(const_cast<Decl*>(D));
755 #define DECL(NAME, BASE)
758 return static_cast<NAME##Decl*>(const_cast<Decl*>(D));
760 llvm_unreachable("a decl that inherits DeclContext isn't handled");
764 SourceLocation Decl::getBodyRBrace() const {
780 bool Decl::AccessDeclContextSanity() const {
805 "Access specifier is AS_none inside a record decl");
810 static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
811 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
813 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
831 /// Starting at a given context (a Decl or DeclContext), look for a
833 template <class T> static Decl *getNonClosureContext(T *D) {
834 if (getKind(D) == Decl::CXXMethod) {
853 Decl *Decl::getNonClosureContext() {
857 Decl *DeclContext::getNonClosureAncestor() {
865 bool DeclContext::classof(const Decl *D) {
867 #define DECL(NAME, BASE)
868 #define DECL_CONTEXT(NAME) case Decl::NAME:
873 #define DECL(NAME, BASE)
875 if (D->getKind() >= Decl::first##NAME && \
876 D->getKind() <= Decl::last##NAME) \
943 if (cast<Decl>(this)->getFriendObjectKind())
955 if (DeclKind == Decl::Enum)
957 else if (DeclKind == Decl::LinkageSpec)
965 while (DC->getDeclKind() != Decl::TranslationUnit) {
966 if (DC->getDeclKind() == Decl::LinkageSpec)
993 case Decl::TranslationUnit:
994 case Decl::ExternCContext:
995 case Decl::LinkageSpec:
996 case Decl::Block:
997 case Decl::Captured:
998 case Decl::OMPDeclareReduction:
1002 case Decl::Namespace:
1006 case Decl::ObjCMethod:
1009 case Decl::ObjCInterface:
1015 case Decl::ObjCProtocol:
1021 case Decl::ObjCCategory:
1024 case Decl::ObjCImplementation:
1025 case Decl::ObjCCategoryImpl:
1029 if (DeclKind >= Decl::firstTag && DeclKind <= Decl::lastTag) {
1049 assert(DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction &&
1059 if (DeclKind != Decl::Namespace) {
1072 std::pair<Decl *, Decl *>
1073 DeclContext::BuildDeclChain(ArrayRef<Decl*> Decls,
1075 // Build up a chain of declarations via the Decl::NextInContextAndBits field.
1076 Decl *FirstNewDecl = nullptr;
1077 Decl *PrevDecl = nullptr;
1082 Decl *D = Decls[I];
1117 SmallVector<Decl*, 64> Decls;
1132 Decl *ExternalFirst, *ExternalLast;
1219 bool DeclContext::containsDecl(Decl *D) const {
1224 void DeclContext::removeDecl(Decl *D) {
1226 "decl being removed from non-lexical context");
1228 "decl is not in decls list");
1230 // Remove D from the decl chain. This is O(n) but hopefully rare.
1237 for (Decl *I = FirstDecl; true; I = I->NextInContextAndBits.getPointer()) {
1238 assert(I && "decl not found in linked list");
1247 // Mark that D is no longer in the decl chain.
1262 assert(Pos != Map->end() && "no lookup entry for decl");
1270 void DeclContext::addHiddenDecl(Decl *D) {
1272 "Decl inserted into wrong lexical context");
1274 "Decl already inserted into a DeclContext");
1296 void DeclContext::addDecl(Decl *D) {
1304 void DeclContext::addDeclInternal(Decl *D) {
1379 for (Decl *D : DCtx->noload_decls()) {
1381 // it's semantically within its decl context. Any other decls which
1408 assert(DeclKind != Decl::LinkageSpec &&
1420 (void)cast<Decl>(this)->getMostRecentDecl();
1470 assert(DeclKind != Decl::LinkageSpec &&
1527 for (Decl *D = FirstDecl; D; D = D->getNextDeclInContext()) {
1582 // If the decl is being added outside of its semantic decl context, we
1604 // up and perform the insertion. If this decl was declared outside its
1615 // the decl which we are adding, so build a full lookup table before adding
1616 // this decl.
1629 Decl *DCAsDecl = cast<Decl>(this);
1630 // Notify that a decl was made visible unless we are a Tag being defined.