//===--- DeclBase.cpp - 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 Decl and DeclContext classes.////===----------------------------------------------------------------------===//#include"clang/AST/DeclBase.h"#include"clang/AST/Decl.h"#include"clang/AST/DeclContextInternals.h"#include"clang/AST/DeclCXX.h"#include"clang/AST/DeclFriend.h"#include"clang/AST/DeclObjC.h"#include"clang/AST/DeclTemplate.h"#include"clang/AST/DependentDiagnostic.h"#include"clang/AST/ExternalASTSource.h"#include"clang/AST/ASTContext.h"#include"clang/AST/Type.h"#include"clang/AST/Stmt.h"#include"clang/AST/StmtCXX.h"#include"clang/AST/ASTMutationListener.h"#include"clang/Basic/TargetInfo.h"#include"llvm/ADT/DenseMap.h"#include"llvm/Support/raw_ostream.h"#include<algorithm>usingnamespaceclang;//===----------------------------------------------------------------------===//// Statistics//===----------------------------------------------------------------------===//#define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;#define ABSTRACT_DECL(DECL)#include"clang/AST/DeclNodes.inc"staticboolStatSwitch=false;constchar*Decl::getDeclKindName()const{switch(DeclKind){default:llvm_unreachable("Declaration not in DeclNodes.inc!");#define DECL(DERIVED, BASE) case DERIVED: return #DERIVED;#define ABSTRACT_DECL(DECL)#include"clang/AST/DeclNodes.inc"}}voidDecl::setInvalidDecl(boolInvalid){InvalidDecl=Invalid;if(Invalid){// Defensive maneuver for ill-formed code: we're likely not to make it to// a point where we set the access specifier, so default it to "public"// to avoid triggering asserts elsewhere in the front end. setAccess(AS_public);}}constchar*DeclContext::getDeclKindName()const{switch(DeclKind){default:llvm_unreachable("Declaration context not in DeclNodes.inc!");#define DECL(DERIVED, BASE) case Decl::DERIVED: return #DERIVED;#define ABSTRACT_DECL(DECL)#include"clang/AST/DeclNodes.inc"}}boolDecl::CollectingStats(boolEnable){if(Enable)StatSwitch=true;returnStatSwitch;}voidDecl::PrintStats(){llvm::errs()<<"\n*** Decl Stats:\n";inttotalDecls=0;#define DECL(DERIVED, BASE) totalDecls += n##DERIVED##s;#define ABSTRACT_DECL(DECL)#include"clang/AST/DeclNodes.inc"llvm::errs()<<" "<<totalDecls<<" decls total.\n";inttotalBytes=0;#define DECL(DERIVED, BASE) \ if (n##DERIVED##s > 0) { \ totalBytes += (int)(n##DERIVED##s * sizeof(DERIVED##Decl)); \ llvm::errs() << " " << n##DERIVED##s << " " #DERIVED " decls