15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ASTContext.h - Context to hold long-lived AST nodes ----*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
9ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett///
10ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett/// \file
11ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett/// \brief Defines the clang::ASTContext interface.
12ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett///
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_ASTCONTEXT_H
175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
18ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek#include "clang/AST/ASTTypeTraits.h"
1930a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/CanonicalType.h"
2030a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/CommentCommandTraits.h"
21ad75653f81dece1c806e9c28dd7e7582c9929a27Ted Kremenek#include "clang/AST/Decl.h"
226bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines#include "clang/AST/ExternalASTSource.h"
23ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor#include "clang/AST/NestedNameSpecifier.h"
24d249e1d1f1498b81314459ceda19d6ff25c278adDouglas Gregor#include "clang/AST/PrettyPrinter.h"
2530a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/RawCommentList.h"
267532dc66648cfe7432c9fe66dec5225f0ab301c6Douglas Gregor#include "clang/AST/TemplateName.h"
27464175bba1318bef7905122e9fda20cff926df78Chris Lattner#include "clang/AST/Type.h"
2830a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/AddressSpaces.h"
2930a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/IdentifierTable.h"
3030a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/LangOptions.h"
3130a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/OperatorKinds.h"
3230a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/PartialDiagnostic.h"
3330a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/VersionTuple.h"
34464175bba1318bef7905122e9fda20cff926df78Chris Lattner#include "llvm/ADT/DenseMap.h"
3568d331a78e655d97294e94fcfa63f92cc1f40578Steve Naroff#include "llvm/ADT/FoldingSet.h"
364f32786ac45210143654390177105eb749b614e9Ted Kremenek#include "llvm/ADT/IntrusiveRefCntPtr.h"
37432a8893f7e30d141d7f279bd00b741a3cdac81fFariborz Jahanian#include "llvm/ADT/SmallPtrSet.h"
38c1b0f7fa9b755ab59129ae85187d0d4f91379995Argyrios Kyrtzidis#include "llvm/ADT/TinyPtrVector.h"
396c2b6eb8d836da19007f7540709e16d5e39a1cbaChris Lattner#include "llvm/Support/Allocator.h"
40651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines#include <memory>
415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector>
425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
43b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattnernamespace llvm {
44b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  struct fltSemantics;
45b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner}
46b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner
475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
48a9376d470ccb0eac74fe09a6b2a18a890f1d17c4Chris Lattner  class FileManager;
496b96742ceedebb5eb8f1299ab67cb3ecd6d92aafReid Kleckner  class AtomicExpr;
50e91593ef084479340582b2ba177b44be50a717b7Daniel Dunbar  class ASTRecordLayout;
515e530af5d51572a0ed5dbe50da54bd333840c63dDavid Chisnall  class BlockExpr;
52bdc601b196c48d4cd56a5ceb45d41ae4e87371abKen Dyck  class CharUnits;
53d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  class DiagnosticsEngine;
54e91593ef084479340582b2ba177b44be50a717b7Daniel Dunbar  class Expr;
557b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis  class ASTMutationListener;
56c7229c338c21ef26b01ef3ecf9eec4fd373fa9ecChris Lattner  class IdentifierTable;
57211c8ddb5b500ed84833751363d0cfe1115f4dd3Richard Smith  class MaterializeTemporaryExpr;
58e91593ef084479340582b2ba177b44be50a717b7Daniel Dunbar  class SelectorTable;
59d934112e6170b0fd940d8e40db6936cea2cdcf62Douglas Gregor  class TargetInfo;
60071cc7deffad608165b1ddd5263e8bf181861520Charles Davis  class CXXABI;
61942f9fe11d3a9583eef6bc4ca2549b1f0d1694daReid Kleckner  class MangleNumberingContext;
62e91593ef084479340582b2ba177b44be50a717b7Daniel Dunbar  // Decls
6314110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  class MangleContext;
640d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  class ObjCIvarDecl;
65c56f34a1c1779de15330bdb3eec39b3418802d47Daniel Dunbar  class ObjCPropertyDecl;
660076ea62c2da91121bca6d402da67f0b611fc8bbDmitri Gribenko  class UnresolvedSetIterator;
670d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  class UsingDecl;
68ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  class UsingShadowDecl;
69651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  class VTableContextBase;
701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
711b63e4f732dbc73d90abf886b4d21f8e3a165f6dChris Lattner  namespace Builtin { class Context; }
721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
731abee64ad71519ea9d91f1fe76441b9cdb75b6c0Dmitri Gribenko  namespace comments {
741abee64ad71519ea9d91f1fe76441b9cdb75b6c0Dmitri Gribenko    class FullComment;
751abee64ad71519ea9d91f1fe76441b9cdb75b6c0Dmitri Gribenko  }
761abee64ad71519ea9d91f1fe76441b9cdb75b6c0Dmitri Gribenko
77ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett/// \brief Holds long-lived AST nodes (such as types and decls) that can be
78ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett/// referred to throughout the semantic analysis of a file.
79c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmithclass ASTContext : public RefCountedBase<ASTContext> {
80ef99001908e799c388f1363b1e607dad5f5b57d3John McCall  ASTContext &this_() { return *this; }
81ef99001908e799c388f1363b1e607dad5f5b57d3John McCall
82f512acee01617c9da8079ed88ded3bb9f2418349Benjamin Kramer  mutable SmallVector<Type *, 0> Types;
834ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
844ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ComplexType> ComplexTypes;
854ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<PointerType> PointerTypes;
86651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
874ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
884ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
894ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
904ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
914ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes;
924ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
934ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable std::vector<VariableArrayType*> VariableArrayTypes;
944ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes;
954ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<DependentSizedExtVectorType>
964ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad    DependentSizedExtVectorTypes;
974ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<VectorType> VectorTypes;
984ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
998026f6d82f7fa544bc0453714fe94bca62a1196eSebastian Redl  mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
1008026f6d82f7fa544bc0453714fe94bca62a1196eSebastian Redl    FunctionProtoTypes;
1014ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes;
1024ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes;
1034ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
1044ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<SubstTemplateTypeParmType>
1054ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad    SubstTemplateTypeParmTypes;
106c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor  mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
107c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor    SubstTemplateTypeParmPackTypes;
1084ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
109ef99001908e799c388f1363b1e607dad5f5b57d3John McCall    TemplateSpecializationTypes;
1104ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ParenType> ParenTypes;
1114ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
1124ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
1134ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType,
1144ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad                                     ASTContext&>
11533500955d731c73717af52088b7fc0e7a85681e7John McCall    DependentTemplateSpecializationTypes;
1167536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
1174ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
1184ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
119483b9f3bc05c5409e2c6643f1c9d91e21c8ff9d2Richard Smith  mutable llvm::FoldingSet<AutoType> AutoTypes;
120b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  mutable llvm::FoldingSet<AtomicType> AtomicTypes;
1219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  llvm::FoldingSet<AttributedType> AttributedTypes;
1221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1234ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
1244ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
125146060435c3efce95c95a092c7a1eb651cfb9ae0John McCall  mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
126146060435c3efce95c95a092c7a1eb651cfb9ae0John McCall    SubstTemplateTemplateParms;
127146060435c3efce95c95a092c7a1eb651cfb9ae0John McCall  mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
128146060435c3efce95c95a092c7a1eb651cfb9ae0John McCall                                     ASTContext&>
1291aee05d08b2184acadeb36de300e216390780d6cDouglas Gregor    SubstTemplateTemplateParmPacks;
1301aee05d08b2184acadeb36de300e216390780d6cDouglas Gregor
131ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The set of nested name specifiers.
132ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  ///
133ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// This set is managed by the NestedNameSpecifier class.
1344ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers;
1354ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable NestedNameSpecifier *GlobalNestedNameSpecifier;
136ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  friend class NestedNameSpecifier;
137ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor
138ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief A cache mapping from RecordDecls to ASTRecordLayouts.
139ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  ///
140ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// This is lazily created.  This is intentionally not serialized.
1414ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
1424ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad    ASTRecordLayouts;
1434ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*>
1444ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad    ObjCLayouts;
145f98aba35e6c3da5aae61843fc01334939e4e12ecEli Friedman
146ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief A cache from types to size and alignment information.
147bc5419a2edc4030d1a623576fe339fbd3eed17a6Daniel Dunbar  typedef llvm::DenseMap<const Type*,
148bc5419a2edc4030d1a623576fe339fbd3eed17a6Daniel Dunbar                         std::pair<uint64_t, unsigned> > TypeInfoMap;
149bc5419a2edc4030d1a623576fe339fbd3eed17a6Daniel Dunbar  mutable TypeInfoMap MemoizedTypeInfo;
150bc5419a2edc4030d1a623576fe339fbd3eed17a6Daniel Dunbar
151ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief A cache mapping from CXXRecordDecls to key functions.
152cd03f862d82cac28c9517e2036716f8d49112c8bRichard Smith  llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions;
153f53df2398e07d13be9962b95aebc19b31706fa33Anders Carlsson
1548a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  /// \brief Mapping from ObjCContainers to their ObjCImplementations.
1558a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis  llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
156b40034c2e580ab3b08de9dfb738d8e5d8ef79136Argyrios Kyrtzidis
157b40034c2e580ab3b08de9dfb738d8e5d8ef79136Argyrios Kyrtzidis  /// \brief Mapping from ObjCMethod to its duplicate declaration in the same
158b40034c2e580ab3b08de9dfb738d8e5d8ef79136Argyrios Kyrtzidis  /// interface.
159b40034c2e580ab3b08de9dfb738d8e5d8ef79136Argyrios Kyrtzidis  llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls;
1608a1d722f13df383600f36d77f842957c8adb5f1bArgyrios Kyrtzidis
1611ceee5c42d5c410217f67d384eecc6ea4a2bba9bFariborz Jahanian  /// \brief Mapping from __block VarDecls to their copy initialization expr.
162830937bc1100fba7682f7c32c40512085870f50cFariborz Jahanian  llvm::DenseMap<const VarDecl*, Expr*> BlockVarCopyInits;
1631ceee5c42d5c410217f67d384eecc6ea4a2bba9bFariborz Jahanian
164af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet  /// \brief Mapping from class scope functions specialization to their
165ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// template patterns.
166af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet  llvm::DenseMap<const FunctionDecl*, FunctionDecl*>
1670d95f0d7b81110f77e99e833f766d19be7b7e072Francois Pichet    ClassScopeSpecializationPattern;
168af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet
169211c8ddb5b500ed84833751363d0cfe1115f4dd3Richard Smith  /// \brief Mapping from materialized temporaries with static storage duration
170211c8ddb5b500ed84833751363d0cfe1115f4dd3Richard Smith  /// that appear in constant initializers to their evaluated values.
171211c8ddb5b500ed84833751363d0cfe1115f4dd3Richard Smith  llvm::DenseMap<const MaterializeTemporaryExpr*, APValue>
172211c8ddb5b500ed84833751363d0cfe1115f4dd3Richard Smith    MaterializedTemporaryValues;
173211c8ddb5b500ed84833751363d0cfe1115f4dd3Richard Smith
1743e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor  /// \brief Representation of a "canonical" template template parameter that
1753e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor  /// is used in canonical template names.
1763e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor  class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
1773e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor    TemplateTemplateParmDecl *Parm;
1783e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor
1793e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor  public:
1803e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor    CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
1813e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor      : Parm(Parm) { }
1823e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor
1833e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor    TemplateTemplateParmDecl *getParam() const { return Parm; }
1843e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor
1853e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor    void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Parm); }
1863e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor
1873e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor    static void Profile(llvm::FoldingSetNodeID &ID,
1883e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor                        TemplateTemplateParmDecl *Parm);
1893e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor  };
1904ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::FoldingSet<CanonicalTemplateTemplateParm>
1914ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad    CanonTemplateTemplateParms;
1923e1274f2b99cb99c03cc8e2c6517c37d330b597aDouglas Gregor
1934ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  TemplateTemplateParmDecl *
1944ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad    getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
195006113841bdae1edb77aef75ba1ffdf2e55a3094Argyrios Kyrtzidis
196772eeaefef2c883aabe35caf4543e7e32d290183Douglas Gregor  /// \brief The typedef for the __int128_t type.
197772eeaefef2c883aabe35caf4543e7e32d290183Douglas Gregor  mutable TypedefDecl *Int128Decl;
198006113841bdae1edb77aef75ba1ffdf2e55a3094Argyrios Kyrtzidis
199772eeaefef2c883aabe35caf4543e7e32d290183Douglas Gregor  /// \brief The typedef for the __uint128_t type.
200772eeaefef2c883aabe35caf4543e7e32d290183Douglas Gregor  mutable TypedefDecl *UInt128Decl;
201cac18add73d095eaab600aefe27ea7174aec4922Nico Weber
202cac18add73d095eaab600aefe27ea7174aec4922Nico Weber  /// \brief The typedef for the __float128 stub type.
203cac18add73d095eaab600aefe27ea7174aec4922Nico Weber  mutable TypeDecl *Float128StubDecl;
204772eeaefef2c883aabe35caf4543e7e32d290183Douglas Gregor
205c5613b26a24a33d7450e3d0bf315c6ccc920ce7bMeador Inge  /// \brief The typedef for the target specific predefined
206c5613b26a24a33d7450e3d0bf315c6ccc920ce7bMeador Inge  /// __builtin_va_list type.
207c5613b26a24a33d7450e3d0bf315c6ccc920ce7bMeador Inge  mutable TypedefDecl *BuiltinVaListDecl;
208d1b3c2dd5bc1f3103bee6137957aa7c5f8f2f0bcSteve Naroff
209ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief The typedef for the predefined \c id type.
2104dfd02a17c6d604c72e6936527c5e1c56d3ecb7aDouglas Gregor  mutable TypedefDecl *ObjCIdDecl;
2114dfd02a17c6d604c72e6936527c5e1c56d3ecb7aDouglas Gregor
212ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief The typedef for the predefined \c SEL type.
2137a27ea52b7bd635c89bec5a9c521a3bf7d204238Douglas Gregor  mutable TypedefDecl *ObjCSelDecl;
2141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
215ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief The typedef for the predefined \c Class type.
21679d6726921897811232554ed94c5d77b5b7b3fc0Douglas Gregor  mutable TypedefDecl *ObjCClassDecl;
217a6ea10e22b600d92e084f6b11b9b9a92d0eb2412Douglas Gregor
218ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief The typedef for the predefined \c Protocol class in Objective-C.
219a6ea10e22b600d92e084f6b11b9b9a92d0eb2412Douglas Gregor  mutable ObjCInterfaceDecl *ObjCProtocolClassDecl;
220961713055e636170da59d7006a878cb4ba518a5dFariborz Jahanian
221961713055e636170da59d7006a878cb4ba518a5dFariborz Jahanian  /// \brief The typedef for the predefined 'BOOL' type.
222961713055e636170da59d7006a878cb4ba518a5dFariborz Jahanian  mutable TypedefDecl *BOOLDecl;
223a6ea10e22b600d92e084f6b11b9b9a92d0eb2412Douglas Gregor
22401a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  // Typedefs which may be provided defining the structure of Objective-C
22501a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  // pseudo-builtins
22601a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  QualType ObjCIdRedefinitionType;
22701a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  QualType ObjCClassRedefinitionType;
22801a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  QualType ObjCSelRedefinitionType;
22901a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor
230a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  QualType ObjCConstantStringType;
2314ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable RecordDecl *CFConstantStringTypeDecl;
232f64bc202a2bcdf7b10f418ad52aaa7366c8ffef9Fariborz Jahanian
233f7992132207d7ddc8810a135cec97ebe5805e500Fariborz Jahanian  mutable QualType ObjCSuperType;
234f7992132207d7ddc8810a135cec97ebe5805e500Fariborz Jahanian
235f64bc202a2bcdf7b10f418ad52aaa7366c8ffef9Fariborz Jahanian  QualType ObjCNSStringType;
2367a9d49fd2bfac00e905b361ba76d26ab5b6c3b09Ted Kremenek
237e97179c675b341927807c718be215c8d1aab8acbDouglas Gregor  /// \brief The typedef declaration for the Objective-C "instancetype" type.
238e97179c675b341927807c718be215c8d1aab8acbDouglas Gregor  TypedefDecl *ObjCInstanceTypeDecl;
239e97179c675b341927807c718be215c8d1aab8acbDouglas Gregor
240c29f77b769bcc5b6dc85e72c8e3cc2e348e5cf25Douglas Gregor  /// \brief The type for the C FILE type.
241c29f77b769bcc5b6dc85e72c8e3cc2e348e5cf25Douglas Gregor  TypeDecl *FILEDecl;
2421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2438fad9941a635a42ee644e7396ca84cbaaa5c1b6eMike Stump  /// \brief The type for the C jmp_buf type.
244782fa308a765aeac2acb39c4e697c937ec21185bMike Stump  TypeDecl *jmp_bufDecl;
2451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2468fad9941a635a42ee644e7396ca84cbaaa5c1b6eMike Stump  /// \brief The type for the C sigjmp_buf type.
247782fa308a765aeac2acb39c4e697c937ec21185bMike Stump  TypeDecl *sigjmp_bufDecl;
2481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
249e2d4f4ed44a32f179c6d48cd1dba8346ab2129d9Rafael Espindola  /// \brief The type for the C ucontext_t type.
250e2d4f4ed44a32f179c6d48cd1dba8346ab2129d9Rafael Espindola  TypeDecl *ucontext_tDecl;
251e2d4f4ed44a32f179c6d48cd1dba8346ab2129d9Rafael Espindola
252adaaad3715c9c26cdcfdfe3401a13d7b4423ddcfMike Stump  /// \brief Type for the Block descriptor for Blocks CodeGen.
2535c0d3d66bf06213009802876a14e6298efc1e0b0Douglas Gregor  ///
2545c0d3d66bf06213009802876a14e6298efc1e0b0Douglas Gregor  /// Since this is only used for generation of debug info, it is not
2555c0d3d66bf06213009802876a14e6298efc1e0b0Douglas Gregor  /// serialized.
2564ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable RecordDecl *BlockDescriptorType;
257adaaad3715c9c26cdcfdfe3401a13d7b4423ddcfMike Stump
258083c25eea14bb4cc4ecc3ec763c60e2e609e22bdMike Stump  /// \brief Type for the Block descriptor for Blocks CodeGen.
2595c0d3d66bf06213009802876a14e6298efc1e0b0Douglas Gregor  ///
2605c0d3d66bf06213009802876a14e6298efc1e0b0Douglas Gregor  /// Since this is only used for generation of debug info, it is not
2615c0d3d66bf06213009802876a14e6298efc1e0b0Douglas Gregor  /// serialized.
2624ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable RecordDecl *BlockDescriptorExtendedType;
263083c25eea14bb4cc4ecc3ec763c60e2e609e22bdMike Stump
26414b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne  /// \brief Declaration for the CUDA cudaConfigureCall function.
26514b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne  FunctionDecl *cudaConfigureCallDecl;
26614b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne
267bf1a028246d884a540aeafa38e89be59a269b072John McCall  TypeSourceInfo NullTypeSourceInfo;
268bf1a028246d884a540aeafa38e89be59a269b072John McCall
2691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Keeps track of all declaration attributes.
27068584ed35ad819a1668e3f527ba7f5dd4ae6a333Douglas Gregor  ///
27168584ed35ad819a1668e3f527ba7f5dd4ae6a333Douglas Gregor  /// Since so few decls have attrs, we keep them in a hash map instead of
27268584ed35ad819a1668e3f527ba7f5dd4ae6a333Douglas Gregor  /// wasting space in the Decl class.
2736320064d0c60fa8683f5623881c9394fd4aa7689Douglas Gregor  llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
2742455636163fdd18581d7fdae816433f886d88213Mike Stump
2754ed0122c1b795379cc4e11dfd62312358dcbf506Richard Smith  /// \brief A mapping from non-redeclarable declarations in modules that were
2764ed0122c1b795379cc4e11dfd62312358dcbf506Richard Smith  /// merged with other declarations to the canonical declaration that they were
2774ed0122c1b795379cc4e11dfd62312358dcbf506Richard Smith  /// merged into.
2784ed0122c1b795379cc4e11dfd62312358dcbf506Richard Smith  llvm::DenseMap<Decl*, Decl*> MergedDecls;
2794ed0122c1b795379cc4e11dfd62312358dcbf506Richard Smith
280ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufopublic:
281ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// \brief A type synonym for the TemplateOrInstantiation mapping.
282ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  typedef llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>
283ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  TemplateOrSpecializationInfo;
284ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
285ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufoprivate:
286ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
287ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// \brief A mapping to contain the template or declaration that
288ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// a variable declaration describes or was instantiated from,
289ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// respectively.
2907caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///
291ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// For non-templates, this value will be NULL. For variable
292ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// declarations that describe a variable template, this will be a
293ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// pointer to a VarTemplateDecl. For static data members
294ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// of class template specializations, this will be the
295ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// MemberSpecializationInfo referring to the member variable that was
296ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// instantiated or specialized. Thus, the mapping will keep track of
297ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// the static data member templates from which static data members of
298ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  /// class template specializations were instantiated.
2997caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///
3007caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// Given the following example:
3017caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///
3027caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// \code
3037caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// template<typename T>
3047caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// struct X {
3057caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///   static T value;
3067caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// };
3077caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///
3087caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// template<typename T>
3097caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///   T X<T>::value = T(17);
3107caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///
3117caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// int *x = &X<int>::value;
3127caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// \endcode
3137caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  ///
3141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// This mapping will contain an entry that maps from the VarDecl for
3157caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
316251b4ff2578e26959a4c036140ccd61c5e9292f2Douglas Gregor  /// class template X) and will be marked TSK_ImplicitInstantiation.
317ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>
318ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  TemplateOrInstantiation;
3191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
320ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  /// \brief Keeps track of the declaration from which a UsingDecl was
321ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// created during instantiation.
322ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  ///
323ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// The source declaration is always a UsingDecl, an UnresolvedUsingValueDecl,
324ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// or an UnresolvedUsingTypenameDecl.
3250d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  ///
3260d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// For example:
3270d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// \code
3280d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// template<typename T>
3290d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// struct A {
3300d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  ///   void f();
3310d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// };
3320d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  ///
3330d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// template<typename T>
3340d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// struct B : A<T> {
3350d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  ///   using A<T>::f;
3360d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// };
3370d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  ///
3380d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// template struct B<int>;
3390d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// \endcode
3400d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  ///
3410d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// This mapping will contain an entry that maps from the UsingDecl in
3420d8df780aef1acda5962347a32591efc629b6748Anders Carlsson  /// B<int> to the UnresolvedUsingDecl in B<T>.
343ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  llvm::DenseMap<UsingDecl *, NamedDecl *> InstantiatedFromUsingDecl;
344ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
345ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
346ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    InstantiatedFromUsingShadowDecl;
3471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
348d8b285fee4471f393da8ee30f552ceacdc362afaAnders Carlsson  llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
3491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3507d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  /// \brief Mapping that stores the methods overridden by a given C++
3517d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  /// member function.
3527d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  ///
3537d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  /// Since most C++ member functions aren't virtual and therefore
3547d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  /// don't override anything, we store the overridden functions in
3557d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  /// this map on the side rather than within the CXXMethodDecl structure.
356c1b0f7fa9b755ab59129ae85187d0d4f91379995Argyrios Kyrtzidis  typedef llvm::TinyPtrVector<const CXXMethodDecl*> CXXMethodVector;
3577d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor  llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
3587d10b7eb670b821741b4c96f6cf7afbc3bb39abeDouglas Gregor
35907369dde9d72213bf8a48288cd8b29999af9a40cEli Friedman  /// \brief Mapping from each declaration context to its corresponding
36007369dde9d72213bf8a48288cd8b29999af9a40cEli Friedman  /// mangling numbering context (used for constructs like lambdas which
36107369dde9d72213bf8a48288cd8b29999af9a40cEli Friedman  /// need to be consistently numbered for the mangler).
362942f9fe11d3a9583eef6bc4ca2549b1f0d1694daReid Kleckner  llvm::DenseMap<const DeclContext *, MangleNumberingContext *>
36307369dde9d72213bf8a48288cd8b29999af9a40cEli Friedman      MangleNumberingContexts;
36466cff7257698d5528632917d38f9a3037bb1506dDavid Blaikie
3655e867c8a07d82da0d3b0a43402ee4f1c6ba416e9Eli Friedman  /// \brief Side-table of mangling numbers for declarations which rarely
3665e867c8a07d82da0d3b0a43402ee4f1c6ba416e9Eli Friedman  /// need them (like static local vars).
3675e867c8a07d82da0d3b0a43402ee4f1c6ba416e9Eli Friedman  llvm::DenseMap<const NamedDecl *, unsigned> MangleNumbers;
368651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  llvm::DenseMap<const VarDecl *, unsigned> StaticLocalNumbers;
36966cff7257698d5528632917d38f9a3037bb1506dDavid Blaikie
370ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief Mapping that stores parameterIndex values for ParmVarDecls when
371ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
372d211cb709510fbe7e75167b9feee0050851d001aTed Kremenek  typedef llvm::DenseMap<const VarDecl *, unsigned> ParameterIndexTable;
373d211cb709510fbe7e75167b9feee0050851d001aTed Kremenek  ParameterIndexTable ParamIndices;
374d211cb709510fbe7e75167b9feee0050851d001aTed Kremenek
375e664977aca2a05a77abab5a06dc0fb69e870cfb9Douglas Gregor  ImportDecl *FirstLocalImport;
376e664977aca2a05a77abab5a06dc0fb69e870cfb9Douglas Gregor  ImportDecl *LastLocalImport;
377e664977aca2a05a77abab5a06dc0fb69e870cfb9Douglas Gregor
378ef177820100ab583b08fd3056e2a5a52ee4b1629Argyrios Kyrtzidis  TranslationUnitDecl *TUDecl;
379ef177820100ab583b08fd3056e2a5a52ee4b1629Argyrios Kyrtzidis
380ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief The associated SourceManager object.a
381b800dc2d5e27ec60f567567b623cdc61152b8fb8Chris Lattner  SourceManager &SourceMgr;
3821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
383ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief The language options used to create the AST associated with
384e7d07d113677a39026ff5119b8b67f6fe8ca9793Ted Kremenek  ///  this ASTContext object.
3853e3cd93b2fd9644e970c389e715c13883faf68b6Douglas Gregor  LangOptions &LangOpts;
386e7d07d113677a39026ff5119b8b67f6fe8ca9793Ted Kremenek
38763fe86bee66fc145942c56b2cc564ea0b9b9ea12Douglas Gregor  /// \brief The allocator used to create AST objects.
38863fe86bee66fc145942c56b2cc564ea0b9b9ea12Douglas Gregor  ///
38963fe86bee66fc145942c56b2cc564ea0b9b9ea12Douglas Gregor  /// AST objects are never destructed; rather, all memory associated with the
39063fe86bee66fc145942c56b2cc564ea0b9b9ea12Douglas Gregor  /// AST objects will be released when the ASTContext itself is destroyed.
3914ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable llvm::BumpPtrAllocator BumpAlloc;
3921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
393fe6b2d481d91140923f4541f273b253291884214Douglas Gregor  /// \brief Allocator for partial diagnostics.
394d7a3e2c5f61cd4893f95b69a424fe4def3aa0f69Benjamin Kramer  PartialDiagnostic::StorageAllocator DiagAllocator;
395071cc7deffad608165b1ddd5263e8bf181861520Charles Davis
396071cc7deffad608165b1ddd5263e8bf181861520Charles Davis  /// \brief The current C++ ABI.
397651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  std::unique_ptr<CXXABI> ABI;
398071cc7deffad608165b1ddd5263e8bf181861520Charles Davis  CXXABI *createCXXABI(const TargetInfo &T);
39936d2fd44bfeec417bbd7465218353abb8bf7e95dArgyrios Kyrtzidis
400207f4d8543529221932af82836016a2ef066c917Peter Collingbourne  /// \brief The logical -> physical address space map.
401bcfd1f55bfbb3e5944cd5e03d07b343e280838c4Douglas Gregor  const LangAS::Map *AddrSpaceMap;
402207f4d8543529221932af82836016a2ef066c917Peter Collingbourne
4031eef85246b411b55c493098266746d0d83c241eaDavid Tweed  /// \brief Address space map mangling must be used with language specific
4041eef85246b411b55c493098266746d0d83c241eaDavid Tweed  /// address spaces (e.g. OpenCL/CUDA)
4051eef85246b411b55c493098266746d0d83c241eaDavid Tweed  bool AddrSpaceMapMangling;
4061eef85246b411b55c493098266746d0d83c241eaDavid Tweed
40736d2fd44bfeec417bbd7465218353abb8bf7e95dArgyrios Kyrtzidis  friend class ASTDeclReader;
40801a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  friend class ASTReader;
40901a4cf11777bb34c35f5d251a9e95eb736d0842bDouglas Gregor  friend class ASTWriter;
4104d8d22bfaed6e5d7da6b5556415b18c43b44e36cDouglas Gregor  friend class CXXRecordDecl;
4114d8d22bfaed6e5d7da6b5556415b18c43b44e36cDouglas Gregor
412bcfd1f55bfbb3e5944cd5e03d07b343e280838c4Douglas Gregor  const TargetInfo *Target;
4138987b2385d9ba63ada66e1344ace79b04d5cb5c3Douglas Gregor  clang::PrintingPolicy PrintingPolicy;
41430c42404202d2e2512e51efc6066bd614cfdb5a4Douglas Gregor
4151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic:
41671993dd85eed9cc42c6b2fa61ee5c53026b74817Anders Carlsson  IdentifierTable &Idents;
41729238a0bf7cbf5b396efb451a0adb5fe4aa037caSteve Naroff  SelectorTable &Selectors;
4181b63e4f732dbc73d90abf886b4d21f8e3a165f6dChris Lattner  Builtin::Context &BuiltinInfo;
4194ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  mutable DeclarationNameTable DeclarationNames;
420651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  IntrusiveRefCntPtr<ExternalASTSource> ExternalSource;
4217b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis  ASTMutationListener *Listener;
4222e1cd4264d363ca869bf37ef160902f211d21b8cDouglas Gregor
423ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// \brief Contains parents of a node.
4246bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  typedef llvm::SmallVector<ast_type_traits::DynTypedNode, 2> ParentVector;
425ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek
426ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// \brief Maps from a node to its parents.
4276bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  typedef llvm::DenseMap<const void *,
4286bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines                         llvm::PointerUnion<ast_type_traits::DynTypedNode *,
4296bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines                                            ParentVector *>> ParentMap;
430ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek
431ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// \brief Returns the parents of the given node.
432ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  ///
433ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// Note that this will lazily compute the parents of all nodes
434ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// and store them for later retrieval. Thus, the first call is O(n)
435ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// in the number of AST nodes.
436ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  ///
437ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// Caveats and FIXMEs:
438ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// Calculating the parent map over all AST nodes will need to load the
439ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// full AST. This can be undesirable in the case where the full AST is
440ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// expensive to create (for example, when using precompiled header
441ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// preambles). Thus, there are good opportunities for optimization here.
442ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// One idea is to walk the given node downwards, looking for references
443ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// to declaration contexts - once a declaration context is found, compute
444ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// the parent map for the declaration context; if that can satisfy the
445ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// request, loading the whole AST can be avoided. Note that this is made
446ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// more complex by statements in templates having multiple parents - those
447ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// problems can be solved by building closure over the templated parts of
448ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// the AST, which also avoids touching large parts of the AST.
449ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// Additionally, we will want to add an interface to already give a hint
450ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// where to search for the parents, for example when looking at a statement
451ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// inside a certain function.
452ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  ///
453ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// 'NodeT' can be one of Decl, Stmt, Type, TypeLoc,
454ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  /// NestedNameSpecifier or NestedNameSpecifierLoc.
455ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  template <typename NodeT>
456ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  ParentVector getParents(const NodeT &Node) {
457ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek    return getParents(ast_type_traits::DynTypedNode::create(Node));
458ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek  }
459ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek
460cff15128c6c089bd6fae841b80680e6f5afbf0bfReid Kleckner  ParentVector getParents(const ast_type_traits::DynTypedNode &Node);
461ff9a01000ff74a994aa3da26ea2ec732c97291b7Manuel Klimek
462023bd7d6ff3bf9ad6c9fa2e404924195e4f31584Benjamin Kramer  const clang::PrintingPolicy &getPrintingPolicy() const {
463023bd7d6ff3bf9ad6c9fa2e404924195e4f31584Benjamin Kramer    return PrintingPolicy;
464023bd7d6ff3bf9ad6c9fa2e404924195e4f31584Benjamin Kramer  }
4658987b2385d9ba63ada66e1344ace79b04d5cb5c3Douglas Gregor
466023bd7d6ff3bf9ad6c9fa2e404924195e4f31584Benjamin Kramer  void setPrintingPolicy(const clang::PrintingPolicy &Policy) {
4678987b2385d9ba63ada66e1344ace79b04d5cb5c3Douglas Gregor    PrintingPolicy = Policy;
4688987b2385d9ba63ada66e1344ace79b04d5cb5c3Douglas Gregor  }
46930c42404202d2e2512e51efc6066bd614cfdb5a4Douglas Gregor
4707a9d49fd2bfac00e905b361ba76d26ab5b6c3b09Ted Kremenek  SourceManager& getSourceManager() { return SourceMgr; }
471a9376d470ccb0eac74fe09a6b2a18a890f1d17c4Chris Lattner  const SourceManager& getSourceManager() const { return SourceMgr; }
472a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko
473a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko  llvm::BumpPtrAllocator &getAllocator() const {
474a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko    return BumpAlloc;
475a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko  }
476a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko
477605c59a1d1a11112c643031770c616e2e441c349Eli Friedman  void *Allocate(size_t Size, unsigned Align = 8) const {
47863fe86bee66fc145942c56b2cc564ea0b9b9ea12Douglas Gregor    return BumpAlloc.Allocate(Size, Align);
479c0ac4923f08b25ae973a8ee7942cf3eb89da57b7Steve Naroff  }
4804ba2a17694148e16eaa8d3917f657ffcd3667be4Jay Foad  void Deallocate(void *Ptr) const { }
481fe6b2d481d91140923f4541f273b253291884214Douglas Gregor
48261e0b94838127601718c64b80940868d4b995e1fTed Kremenek  /// Return the total amount of physical memory allocated for representing
48361e0b94838127601718c64b80940868d4b995e1fTed Kremenek  /// AST nodes and type information.
484ba29bd25515fbd99e98ba0fedb9d93617b27609eTed Kremenek  size_t getASTAllocatedMemory() const {
48561e0b94838127601718c64b80940868d4b995e1fTed Kremenek    return BumpAlloc.getTotalMemory();
48661e0b94838127601718c64b80940868d4b995e1fTed Kremenek  }
487ba29bd25515fbd99e98ba0fedb9d93617b27609eTed Kremenek  /// Return the total memory used for various side tables.
488ba29bd25515fbd99e98ba0fedb9d93617b27609eTed Kremenek  size_t getSideTableAllocatedMemory() const;
48961e0b94838127601718c64b80940868d4b995e1fTed Kremenek
490d7a3e2c5f61cd4893f95b69a424fe4def3aa0f69Benjamin Kramer  PartialDiagnostic::StorageAllocator &getDiagAllocator() {
491d7a3e2c5f61cd4893f95b69a424fe4def3aa0f69Benjamin Kramer    return DiagAllocator;
492fe6b2d481d91140923f4541f273b253291884214Douglas Gregor  }
493fe6b2d481d91140923f4541f273b253291884214Douglas Gregor
494bcfd1f55bfbb3e5944cd5e03d07b343e280838c4Douglas Gregor  const TargetInfo &getTargetInfo() const { return *Target; }
495bcfd1f55bfbb3e5944cd5e03d07b343e280838c4Douglas Gregor
4967b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// getIntTypeForBitwidth -
4977b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// sets integer QualTy according to specified details:
4987b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// bitwidth, signed/unsigned.
4997b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// Returns empty type if there is no appropriate target types.
5007b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  QualType getIntTypeForBitwidth(unsigned DestWidth,
5017b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy                                 unsigned Signed) const;
5027b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// getRealTypeForBitwidth -
5037b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// sets floating point QualTy according to specified bitwidth.
5047b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  /// Returns empty type if there is no appropriate target types.
5057b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy  QualType getRealTypeForBitwidth(unsigned DestWidth) const;
5067b7bef1ec355fb46643349d77c266b913f36b656Stepan Dyatkovskiy
507538bbe597b935a74d95c668ad209536753f13481Fariborz Jahanian  bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
508538bbe597b935a74d95c668ad209536753f13481Fariborz Jahanian
5094e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie  const LangOptions& getLangOpts() const { return LangOpts; }
5101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
511d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  DiagnosticsEngine &getDiagnostics() const;
51278a916ec5ff5b66adec3c499e1b9af7b87668309Argyrios Kyrtzidis
5131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  FullSourceLoc getFullLoc(SourceLocation Loc) const {
5149c728dc4d8da89c73fcae74c9e72d7a83ffd7b6dTed Kremenek    return FullSourceLoc(Loc,SourceMgr);
5159c728dc4d8da89c73fcae74c9e72d7a83ffd7b6dTed Kremenek  }
516ef177820100ab583b08fd3056e2a5a52ee4b1629Argyrios Kyrtzidis
517aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  /// \brief All comments in this translation unit.
518aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  RawCommentList Comments;
519aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko
520aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  /// \brief True if comments are already loaded from ExternalASTSource.
521aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  mutable bool CommentsLoaded;
522aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko
523f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  class RawCommentAndCacheFlags {
524f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  public:
525f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    enum Kind {
526f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// We searched for a comment attached to the particular declaration, but
527f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// didn't find any.
528f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      ///
529f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// getRaw() == 0.
530f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      NoCommentInDecl = 0,
531f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
532f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// We have found a comment attached to this particular declaration.
533f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      ///
534f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// getRaw() != 0.
535f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      FromDecl,
536f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
537f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// This declaration does not have an attached comment, and we have
538f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// searched the redeclaration chain.
539f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      ///
540f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// If getRaw() == 0, the whole redeclaration chain does not have any
541f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// comments.
542f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      ///
543f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// If getRaw() != 0, it is a comment propagated from other
544f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      /// redeclaration.
545f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      FromRedecl
546f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    };
547f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
548f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    Kind getKind() const LLVM_READONLY {
549f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      return Data.getInt();
550f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    }
551f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
552f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    void setKind(Kind K) {
553f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      Data.setInt(K);
554f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    }
555f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
556f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    const RawComment *getRaw() const LLVM_READONLY {
557f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      return Data.getPointer();
558f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    }
559f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
560f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    void setRaw(const RawComment *RC) {
561f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko      Data.setPointer(RC);
562f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    }
563f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko
5641599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko    const Decl *getOriginalDecl() const LLVM_READONLY {
5651599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko      return OriginalDecl;
5661599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko    }
5671599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko
5681599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko    void setOriginalDecl(const Decl *Orig) {
5691599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko      OriginalDecl = Orig;
5701599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko    }
5711599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko
572f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  private:
573f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko    llvm::PointerIntPair<const RawComment *, 2, Kind> Data;
5741599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko    const Decl *OriginalDecl;
575f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  };
5768d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko
577f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  /// \brief Mapping from declarations to comments attached to any
578f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  /// redeclaration.
5798d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko  ///
5808d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko  /// Raw comments are owned by Comments list.  This mapping is populated
5818d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko  /// lazily.
582f50555eedef33fd5a67d369aa0ae8a6f1d201543Dmitri Gribenko  mutable llvm::DenseMap<const Decl *, RawCommentAndCacheFlags> RedeclComments;
583aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko
584c41ace950dcf2254c9aa48e73647b89c35109f80Dmitri Gribenko  /// \brief Mapping from declarations to parsed comments attached to any
585c41ace950dcf2254c9aa48e73647b89c35109f80Dmitri Gribenko  /// redeclaration.
586c41ace950dcf2254c9aa48e73647b89c35109f80Dmitri Gribenko  mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
587c41ace950dcf2254c9aa48e73647b89c35109f80Dmitri Gribenko
5887e0f1ee35fe98d6751b9e736410f8254795b5f68Dmitri Gribenko  /// \brief Return the documentation comment attached to a given declaration,
589aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  /// without looking into cache.
590a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko  RawComment *getRawCommentForDeclNoCache(const Decl *D) const;
591aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko
592aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenkopublic:
593a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko  RawCommentList &getRawCommentList() {
594a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko    return Comments;
595a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko  }
596a5ef44ff5d93a3be6ca67782828157a71894cf0cDmitri Gribenko
597aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  void addComment(const RawComment &RC) {
598127ff2ea6440c3da4b47f9c8b3b190254a97e7b5Ted Kremenek    assert(LangOpts.RetainCommentsFromSystemHeaders ||
599127ff2ea6440c3da4b47f9c8b3b190254a97e7b5Ted Kremenek           !SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
600811c820257746b1799b790b6adc7804f44154011Dmitri Gribenko    Comments.addComment(RC, BumpAlloc);
601aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  }
602aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko
6037e0f1ee35fe98d6751b9e736410f8254795b5f68Dmitri Gribenko  /// \brief Return the documentation comment attached to a given declaration.
604aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko  /// Returns NULL if no comment is attached.
6051599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko  ///
6061599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko  /// \param OriginalDecl if not NULL, is set to declaration AST node that had
6071599eac40a3b28de0824013dc2fb90551dfa01b0Dmitri Gribenko  /// the comment, if the comment we found comes from a redeclaration.
6086bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  const RawComment *
6096bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  getRawCommentForAnyRedecl(const Decl *D,
6106bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines                            const Decl **OriginalDecl = nullptr) const;
6118d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko
6128d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko  /// Return parsed documentation comment attached to a given declaration.
6138d3ba23f2d9e6c87794d059412a0808c9cbacb25Dmitri Gribenko  /// Returns NULL if no comment is attached.
6141952354bd376062c3ab3d328c0fc6c36530c9309Dmitri Gribenko  ///
6151952354bd376062c3ab3d328c0fc6c36530c9309Dmitri Gribenko  /// \param PP the Preprocessor used with this TU.  Could be NULL if
6161952354bd376062c3ab3d328c0fc6c36530c9309Dmitri Gribenko  /// preprocessor is not available.
6171952354bd376062c3ab3d328c0fc6c36530c9309Dmitri Gribenko  comments::FullComment *getCommentForDecl(const Decl *D,
6181952354bd376062c3ab3d328c0fc6c36530c9309Dmitri Gribenko                                           const Preprocessor *PP) const;
6190a74a4ccc4ecfe1a2792ab72c83815323d8fc914Richard Smith
6200a74a4ccc4ecfe1a2792ab72c83815323d8fc914Richard Smith  /// Return parsed documentation comment attached to a given declaration.
6210a74a4ccc4ecfe1a2792ab72c83815323d8fc914Richard Smith  /// Returns NULL if no comment is attached. Does not look at any
6220a74a4ccc4ecfe1a2792ab72c83815323d8fc914Richard Smith  /// redeclarations of the declaration.
6230a74a4ccc4ecfe1a2792ab72c83815323d8fc914Richard Smith  comments::FullComment *getLocalCommentForDeclUncached(const Decl *D) const;
6240a74a4ccc4ecfe1a2792ab72c83815323d8fc914Richard Smith
625749ace614b6ea1ae11d194a60b18e1e43e1db243Fariborz Jahanian  comments::FullComment *cloneFullComment(comments::FullComment *FC,
626749ace614b6ea1ae11d194a60b18e1e43e1db243Fariborz Jahanian                                         const Decl *D) const;
627aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko
628e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenkoprivate:
629e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenko  mutable comments::CommandTraits CommentCommandTraits;
630e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenko
631651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  /// \brief Iterator that visits import declarations.
632651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  class import_iterator {
633651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    ImportDecl *Import;
634651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
635651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  public:
636651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    typedef ImportDecl               *value_type;
637651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    typedef ImportDecl               *reference;
638651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    typedef ImportDecl               *pointer;
639651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    typedef int                       difference_type;
640651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    typedef std::forward_iterator_tag iterator_category;
641651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
642651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    import_iterator() : Import() {}
643651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    explicit import_iterator(ImportDecl *Import) : Import(Import) {}
644651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
645651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    reference operator*() const { return Import; }
646651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    pointer operator->() const { return Import; }
647651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
648651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    import_iterator &operator++() {
649651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      Import = ASTContext::getNextLocalImport(Import);
650651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      return *this;
651651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    }
652651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
653651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    import_iterator operator++(int) {
654651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      import_iterator Other(*this);
655651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      ++(*this);
656651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      return Other;
657651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    }
658651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
659651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    friend bool operator==(import_iterator X, import_iterator Y) {
660651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      return X.Import == Y.Import;
661651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    }
662651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
663651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    friend bool operator!=(import_iterator X, import_iterator Y) {
664651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines      return X.Import != Y.Import;
665651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines    }
666651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  };
667651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
668e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenkopublic:
669e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenko  comments::CommandTraits &getCommentCommandTraits() const {
670e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenko    return CommentCommandTraits;
671e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenko  }
672e4330a302ac20b41b9800267ebd4b5b01f8553f8Dmitri Gribenko
67368584ed35ad819a1668e3f527ba7f5dd4ae6a333Douglas Gregor  /// \brief Retrieve the attributes for the given declaration.
6746320064d0c60fa8683f5623881c9394fd4aa7689Douglas Gregor  AttrVec& getDeclAttrs(const Decl *D);
6751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
67668584ed35ad819a1668e3f527ba7f5dd4ae6a333Douglas Gregor  /// \brief Erase the attributes corresponding to the given declaration.
6776320064d0c60fa8683f5623881c9394fd4aa7689Douglas Gregor  void eraseDeclAttrs(const Decl *D);
6782455636163fdd18581d7fdae816433f886d88213Mike Stump
6797caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// \brief If this variable is an instantiated static data member of a
6801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// class template specialization, returns the templated static data member
6817caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// from which it was instantiated.
682ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  // FIXME: Remove ?
683663b5a0be7261c29bc4c526a71cffcfa02d4153eDouglas Gregor  MemberSpecializationInfo *getInstantiatedFromStaticDataMember(
684663b5a0be7261c29bc4c526a71cffcfa02d4153eDouglas Gregor                                                           const VarDecl *Var);
6851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
686ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  TemplateOrSpecializationInfo
687ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  getTemplateOrSpecializationInfo(const VarDecl *Var);
688ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
689af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet  FunctionDecl *getClassScopeSpecializationPattern(const FunctionDecl *FD);
690af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet
691af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet  void setClassScopeSpecializationPattern(FunctionDecl *FD,
692af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet                                          FunctionDecl *Pattern);
693af0f4d0b2e38c810effc8b024ad2fb6604eec5d3Francois Pichet
6947caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// \brief Note that the static data member \p Inst is an instantiation of
6957caa6825f42a0f7e97d6fc06233133c42b218e46Douglas Gregor  /// the static data member template \p Tmpl of a class template.
696251b4ff2578e26959a4c036140ccd61c5e9292f2Douglas Gregor  void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl,
6979421adc43891e272156fab640e5d5ee5054b779cArgyrios Kyrtzidis                                           TemplateSpecializationKind TSK,
6989421adc43891e272156fab640e5d5ee5054b779cArgyrios Kyrtzidis                        SourceLocation PointOfInstantiation = SourceLocation());
6991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
700ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  void setTemplateOrSpecializationInfo(VarDecl *Inst,
701ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo                                       TemplateOrSpecializationInfo TSI);
702ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
703ca0d10edcf1192ab8546a75e8be5bab7ef32e488James Dennett  /// \brief If the given using decl \p Inst is an instantiation of a
704ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  /// (possibly unresolved) using decl from a template instantiation,
705d8b285fee4471f393da8ee30f552ceacdc362afaAnders Carlsson  /// return it.
706ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  NamedDecl *getInstantiatedFromUsingDecl(UsingDecl *