]> granicus.if.org Git - clang/commitdiff
[ptr-traits] Move methods manipulating PointerUnions, DenseMap pointer
authorChandler Carruth <chandlerc@gmail.com>
Wed, 30 Dec 2015 03:24:14 +0000 (03:24 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 30 Dec 2015 03:24:14 +0000 (03:24 +0000)
keys, and PointerIntPairs where the pointee types are incomplete
out-of-line to where we have the complete type.

This is the standard pattern used throughout the AST library to address
the inherently mutually cross referenced nature of the AST.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256612 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
include/clang/AST/Decl.h
include/clang/AST/DeclCXX.h
include/clang/AST/Stmt.h
include/clang/AST/TemplateName.h
lib/AST/ASTContext.cpp
lib/AST/Decl.cpp
lib/AST/DeclCXX.cpp
lib/AST/Stmt.cpp
lib/AST/TemplateName.cpp

index 44b5e3989b2df7009892cf2570963c5ae261bfb0..4a807773f2a46b55459df4bbd92375a363ef03e0 100644 (file)
@@ -2256,9 +2256,7 @@ public:
          const FunctionProtoType *FromFunctionType,
          const FunctionProtoType *ToFunctionType);
 
-  void ResetObjCLayout(const ObjCContainerDecl *CD) {
-    ObjCLayouts[CD] = nullptr;
-  }
+  void ResetObjCLayout(const ObjCContainerDecl *CD);
 
   //===--------------------------------------------------------------------===//
   //                    Integer Predicates
@@ -2309,16 +2307,11 @@ public:
 
   /// \brief Get the duplicate declaration of a ObjCMethod in the same
   /// interface, or null if none exists.
-  const ObjCMethodDecl *getObjCMethodRedeclaration(
-                                               const ObjCMethodDecl *MD) const {
-    return ObjCMethodRedecls.lookup(MD);
-  }
+  const ObjCMethodDecl *
+  getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const;
 
   void setObjCMethodRedeclaration(const ObjCMethodDecl *MD,
-                                  const ObjCMethodDecl *Redecl) {
-    assert(!getObjCMethodRedeclaration(MD) && "MD already has a redeclaration");
-    ObjCMethodRedecls[MD] = Redecl;
-  }
+                                  const ObjCMethodDecl *Redecl);
 
   /// \brief Returns the Objective-C interface that \p ND belongs to if it is
   /// an Objective-C method/property/ivar etc. that is part of an interface,
index da4ceebe9971daee3d2a4e3de034752b0bbb090f..1b4e3731e1586e8f3a5c0529eed475b3d535fccc 100644 (file)
@@ -464,25 +464,15 @@ public:
   }
 
   /// \brief Get the original (first) namespace declaration.
-  NamespaceDecl *getOriginalNamespace() {
-    if (isFirstDecl())
-      return this;
-
-    return AnonOrFirstNamespaceAndInline.getPointer();
-  }
+  NamespaceDecl *getOriginalNamespace();
 
   /// \brief Get the original (first) namespace declaration.
-  const NamespaceDecl *getOriginalNamespace() const {
-    if (isFirstDecl())
-      return this;
-
-    return AnonOrFirstNamespaceAndInline.getPointer();
-  }
+  const NamespaceDecl *getOriginalNamespace() const;
 
   /// \brief Return true if this declaration is an original (first) declaration
   /// of the namespace. This is false for non-original (subsequent) namespace
   /// declarations and anonymous namespaces.
-  bool isOriginalNamespace() const { return isFirstDecl(); }
+  bool isOriginalNamespace() const;
 
   /// \brief Retrieve the anonymous namespace nested inside this namespace,
   /// if any.
@@ -2053,9 +2043,7 @@ public:
   /// \brief If this function is an instantiation of a member function of a
   /// class template specialization, retrieves the member specialization
   /// information.
-  MemberSpecializationInfo *getMemberSpecializationInfo() const {
-    return TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>();
-  }
+  MemberSpecializationInfo *getMemberSpecializationInfo() const;
 
   /// \brief Specify that this record is an instantiation of the
   /// member function FD.
@@ -2076,13 +2064,9 @@ public:
   /// FunctionDecl that describes the function template,
   /// getDescribedFunctionTemplate() retrieves the
   /// FunctionTemplateDecl from a FunctionDecl.
-  FunctionTemplateDecl *getDescribedFunctionTemplate() const {
-    return TemplateOrSpecialization.dyn_cast<FunctionTemplateDecl*>();
-  }
+  FunctionTemplateDecl *getDescribedFunctionTemplate() const;
 
-  void setDescribedFunctionTemplate(FunctionTemplateDecl *Template) {
-    TemplateOrSpecialization = Template;
-  }
+  void setDescribedFunctionTemplate(FunctionTemplateDecl *Template);
 
   /// \brief Determine whether this function is a function template
   /// specialization.
@@ -2097,10 +2081,7 @@ public:
   /// \brief If this function is actually a function template specialization,
   /// retrieve information about this function template specialization.
   /// Otherwise, returns NULL.
-  FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const {
-    return TemplateOrSpecialization.
-             dyn_cast<FunctionTemplateSpecializationInfo*>();
-  }
+  FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const;
 
   /// \brief Determines whether this function is a function template
   /// specialization or a member of a class template specialization that can
@@ -2177,10 +2158,7 @@ public:
                       const TemplateArgumentListInfo &TemplateArgs);
 
   DependentFunctionTemplateSpecializationInfo *
-  getDependentSpecializationInfo() const {
-    return TemplateOrSpecialization.
-             dyn_cast<DependentFunctionTemplateSpecializationInfo*>();
-  }
+  getDependentSpecializationInfo() const;
 
   /// \brief Determine what kind of template instantiation this function
   /// represents.
@@ -3597,9 +3575,7 @@ private:
   /// \brief The body of the outlined function.
   llvm::PointerIntPair<Stmt *, 1, bool> BodyAndNothrow;
 
-  explicit CapturedDecl(DeclContext *DC, unsigned NumParams)
-    : Decl(Captured, DC, SourceLocation()), DeclContext(Captured),
-      NumParams(NumParams), ContextParam(0), BodyAndNothrow(nullptr, false) { }
+  explicit CapturedDecl(DeclContext *DC, unsigned NumParams);
 
   ImplicitParamDecl *const *getParams() const {
     return getTrailingObjects<ImplicitParamDecl *>();
@@ -3615,11 +3591,11 @@ public:
   static CapturedDecl *CreateDeserialized(ASTContext &C, unsigned ID,
                                           unsigned NumParams);
 
-  Stmt *getBody() const override { return BodyAndNothrow.getPointer(); }
-  void setBody(Stmt *B) { BodyAndNothrow.setPointer(B); }
+  Stmt *getBody() const override;
+  void setBody(Stmt *B);
 
-  bool isNothrow() const { return BodyAndNothrow.getInt(); }
-  void setNothrow(bool Nothrow = true) { BodyAndNothrow.setInt(Nothrow); }
+  bool isNothrow() const;
+  void setNothrow(bool Nothrow = true);
 
   unsigned getNumParams() const { return NumParams; }
 
index c24823f7f17d8c6ee0dc2da739cfd06c9c34618e..7c54901be3ea573e2a24d15eda4fc07983273882 100644 (file)
@@ -1344,9 +1344,7 @@ public:
   /// \brief If this class is an instantiation of a member class of a
   /// class template specialization, retrieves the member specialization
   /// information.
-  MemberSpecializationInfo *getMemberSpecializationInfo() const {
-    return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>();
-  }
+  MemberSpecializationInfo *getMemberSpecializationInfo() const;
 
   /// \brief Specify that this record is an instantiation of the
   /// member class \p RD.
@@ -1364,13 +1362,9 @@ public:
   /// CXXRecordDecl that from a ClassTemplateDecl, while
   /// getDescribedClassTemplate() retrieves the ClassTemplateDecl from
   /// a CXXRecordDecl.
-  ClassTemplateDecl *getDescribedClassTemplate() const {
-    return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl*>();
-  }
+  ClassTemplateDecl *getDescribedClassTemplate() const;
 
-  void setDescribedClassTemplate(ClassTemplateDecl *Template) {
-    TemplateOrInstantiation = Template;
-  }
+  void setDescribedClassTemplate(ClassTemplateDecl *Template);
 
   /// \brief Determine whether this particular class is a specialization or
   /// instantiation of a class template or member class of a class template,
index 1d1a99ed69079b48b2c70b11bf8fbbb6714da4b0..e48b7dcc28f5645f94778f5d366b970500fed8e5 100644 (file)
@@ -2011,7 +2011,7 @@ public:
             VarDecl *Var = nullptr);
 
     /// \brief Determine the kind of capture.
-    VariableCaptureKind getCaptureKind() const { return VarAndKind.getInt(); }
+    VariableCaptureKind getCaptureKind() const;
 
     /// \brief Retrieve the source location at which the variable or 'this' was
     /// first used.
@@ -2037,11 +2037,8 @@ public:
     /// \brief Retrieve the declaration of the variable being captured.
     ///
     /// This operation is only valid if this capture captures a variable.
-    VarDecl *getCapturedVar() const {
-      assert((capturesVariable() || capturesVariableByCopy()) &&
-             "No variable available for 'this' or VAT capture");
-      return VarAndKind.getPointer();
-    }
+    VarDecl *getCapturedVar() const;
+
     friend class ASTStmtReader;
   };
 
@@ -2088,26 +2085,17 @@ public:
   const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; }
 
   /// \brief Retrieve the outlined function declaration.
-  CapturedDecl *getCapturedDecl() { return CapDeclAndKind.getPointer(); }
-  const CapturedDecl *getCapturedDecl() const {
-    return CapDeclAndKind.getPointer();
-  }
+  CapturedDecl *getCapturedDecl();
+  const CapturedDecl *getCapturedDecl() const;
 
   /// \brief Set the outlined function declaration.
-  void setCapturedDecl(CapturedDecl *D) {
-    assert(D && "null CapturedDecl");
-    CapDeclAndKind.setPointer(D);
-  }
+  void setCapturedDecl(CapturedDecl *D);
 
   /// \brief Retrieve the captured region kind.
-  CapturedRegionKind getCapturedRegionKind() const {
-    return CapDeclAndKind.getInt();
-  }
+  CapturedRegionKind getCapturedRegionKind() const;
 
   /// \brief Set the captured region kind.
-  void setCapturedRegionKind(CapturedRegionKind Kind) {
-    CapDeclAndKind.setInt(Kind);
-  }
+  void setCapturedRegionKind(CapturedRegionKind Kind);
 
   /// \brief Retrieve the record declaration for captured variables.
   const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; }
index f3d23b9260aed26f1369f776bd1acceee492c5ad..85304e9f953dad484204599c9ed2d4d5c12d4e46 100644 (file)
@@ -207,17 +207,15 @@ public:
   };
 
   TemplateName() : Storage() { }
-  explicit TemplateName(TemplateDecl *Template) : Storage(Template) { }
-  explicit TemplateName(OverloadedTemplateStorage *Storage)
-    : Storage(Storage) { }
+  explicit TemplateName(TemplateDecl *Template);
+  explicit TemplateName(OverloadedTemplateStorage *Storage);
   explicit TemplateName(SubstTemplateTemplateParmStorage *Storage);
-  explicit TemplateName(SubstTemplateTemplateParmPackStorage *Storage)
-    : Storage(Storage) { }
-  explicit TemplateName(QualifiedTemplateName *Qual) : Storage(Qual) { }
-  explicit TemplateName(DependentTemplateName *Dep) : Storage(Dep) { }
+  explicit TemplateName(SubstTemplateTemplateParmPackStorage *Storage);
+  explicit TemplateName(QualifiedTemplateName *Qual);
+  explicit TemplateName(DependentTemplateName *Dep);
 
   /// \brief Determine whether this template name is NULL.
-  bool isNull() const { return Storage.isNull(); }
+  bool isNull() const;
   
   // \brief Get the kind of name that is actually stored.
   NameKind getKind() const;
@@ -238,26 +236,14 @@ public:
   /// name refers to, if known. If the template name does not refer to a
   /// specific set of function templates because it is a dependent name or
   /// refers to a single template, returns NULL.
-  OverloadedTemplateStorage *getAsOverloadedTemplate() const {
-    if (UncommonTemplateNameStorage *Uncommon = 
-                              Storage.dyn_cast<UncommonTemplateNameStorage *>())
-      return Uncommon->getAsOverloadedStorage();
-    
-    return nullptr;
-  }
+  OverloadedTemplateStorage *getAsOverloadedTemplate() const;
 
   /// \brief Retrieve the substituted template template parameter, if 
   /// known.
   ///
   /// \returns The storage for the substituted template template parameter,
   /// if known. Otherwise, returns NULL.
-  SubstTemplateTemplateParmStorage *getAsSubstTemplateTemplateParm() const {
-    if (UncommonTemplateNameStorage *uncommon = 
-          Storage.dyn_cast<UncommonTemplateNameStorage *>())
-      return uncommon->getAsSubstTemplateTemplateParm();
-    
-    return nullptr;
-  }
+  SubstTemplateTemplateParmStorage *getAsSubstTemplateTemplateParm() const;
 
   /// \brief Retrieve the substituted template template parameter pack, if 
   /// known.
@@ -265,25 +251,15 @@ public:
   /// \returns The storage for the substituted template template parameter pack,
   /// if known. Otherwise, returns NULL.
   SubstTemplateTemplateParmPackStorage *
-  getAsSubstTemplateTemplateParmPack() const {
-    if (UncommonTemplateNameStorage *Uncommon = 
-        Storage.dyn_cast<UncommonTemplateNameStorage *>())
-      return Uncommon->getAsSubstTemplateTemplateParmPack();
-    
-    return nullptr;
-  }
+  getAsSubstTemplateTemplateParmPack() const;
 
   /// \brief Retrieve the underlying qualified template name
   /// structure, if any.
-  QualifiedTemplateName *getAsQualifiedTemplateName() const {
-    return Storage.dyn_cast<QualifiedTemplateName *>();
-  }
+  QualifiedTemplateName *getAsQualifiedTemplateName() const;
 
   /// \brief Retrieve the underlying dependent template name
   /// structure, if any.
-  DependentTemplateName *getAsDependentTemplateName() const {
-    return Storage.dyn_cast<DependentTemplateName *>();
-  }
+  DependentTemplateName *getAsDependentTemplateName() const;
 
   TemplateName getUnderlying() const;
 
@@ -359,9 +335,6 @@ public:
                       TemplateName replacement);
 };
 
-inline TemplateName::TemplateName(SubstTemplateTemplateParmStorage *Storage)
-  : Storage(Storage) { }
-
 inline TemplateName TemplateName::getUnderlying() const {
   if (SubstTemplateTemplateParmStorage *subst
         = getAsSubstTemplateTemplateParm())
index 508124a2a6eb45756d067230ca44308af8393bbc..973445ca2a71b3b58bbdfca4d43530b31cb03dbf 100644 (file)
@@ -2062,6 +2062,17 @@ void ASTContext::setObjCImplementation(ObjCCategoryDecl *CatD,
   ObjCImpls[CatD] = ImplD;
 }
 
+const ObjCMethodDecl *
+ASTContext::getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const {
+  return ObjCMethodRedecls.lookup(MD);
+}
+
+void ASTContext::setObjCMethodRedeclaration(const ObjCMethodDecl *MD,
+                                            const ObjCMethodDecl *Redecl) {
+  assert(!getObjCMethodRedeclaration(MD) && "MD already has a redeclaration");
+  ObjCMethodRedecls[MD] = Redecl;
+}
+
 const ObjCInterfaceDecl *ASTContext::getObjContainingInterface(
                                               const NamedDecl *ND) const {
   if (const ObjCInterfaceDecl *ID =
@@ -7805,6 +7816,10 @@ bool ASTContext::FunctionTypesMatchOnNSConsumedAttrs(
   return true;
 }
 
+void ASTContext::ResetObjCLayout(const ObjCContainerDecl *CD) {
+  ObjCLayouts[CD] = nullptr;
+}
+
 /// mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and
 /// 'RHS' attributes and returns the merged version; including for function
 /// return types.
index ff0b91001ccde2debcbe6d5928daf5ed6aacce24..42bebc543e3e5399a73c7b08bf67380cdc14ecdf 100644 (file)
@@ -3045,6 +3045,10 @@ FunctionDecl *FunctionDecl::getInstantiatedFromMemberFunction() const {
   return nullptr;
 }
 
+MemberSpecializationInfo *FunctionDecl::getMemberSpecializationInfo() const {
+  return TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo *>();
+}
+
 void 
 FunctionDecl::setInstantiationOfMemberFunction(ASTContext &C,
                                                FunctionDecl *FD,
@@ -3056,6 +3060,14 @@ FunctionDecl::setInstantiationOfMemberFunction(ASTContext &C,
   TemplateOrSpecialization = Info;
 }
 
+FunctionTemplateDecl *FunctionDecl::getDescribedFunctionTemplate() const {
+  return TemplateOrSpecialization.dyn_cast<FunctionTemplateDecl *>();
+}
+
+void FunctionDecl::setDescribedFunctionTemplate(FunctionTemplateDecl *Template) {
+  TemplateOrSpecialization = Template;
+}
+
 bool FunctionDecl::isImplicitlyInstantiable() const {
   // If the function is invalid, it can't be implicitly instantiated.
   if (isInvalidDecl())
@@ -3162,6 +3174,12 @@ FunctionDecl *FunctionDecl::getClassScopeSpecializationPattern() const {
     return getASTContext().getClassScopeSpecializationPattern(this);
 }
 
+FunctionTemplateSpecializationInfo *
+FunctionDecl::getTemplateSpecializationInfo() const {
+  return TemplateOrSpecialization
+      .dyn_cast<FunctionTemplateSpecializationInfo *>();
+}
+
 const TemplateArgumentList *
 FunctionDecl::getTemplateSpecializationArgs() const {
   if (FunctionTemplateSpecializationInfo *Info
@@ -3214,6 +3232,12 @@ FunctionDecl::setDependentTemplateSpecialization(ASTContext &Context,
   TemplateOrSpecialization = Info;
 }
 
+DependentFunctionTemplateSpecializationInfo *
+FunctionDecl::getDependentSpecializationInfo() const {
+  return TemplateOrSpecialization
+      .dyn_cast<DependentFunctionTemplateSpecializationInfo *>();
+}
+
 DependentFunctionTemplateSpecializationInfo *
 DependentFunctionTemplateSpecializationInfo::Create(
     ASTContext &Context, const UnresolvedSetImpl &Ts,
@@ -3963,6 +3987,10 @@ BlockDecl *BlockDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
   return new (C, ID) BlockDecl(nullptr, SourceLocation());
 }
 
+CapturedDecl::CapturedDecl(DeclContext *DC, unsigned NumParams)
+    : Decl(Captured, DC, SourceLocation()), DeclContext(Captured),
+      NumParams(NumParams), ContextParam(0), BodyAndNothrow(nullptr, false) {}
+
 CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC,
                                    unsigned NumParams) {
   return new (C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
@@ -3975,6 +4003,12 @@ CapturedDecl *CapturedDecl::CreateDeserialized(ASTContext &C, unsigned ID,
       CapturedDecl(nullptr, NumParams);
 }
 
+Stmt *CapturedDecl::getBody() const { return BodyAndNothrow.getPointer(); }
+void CapturedDecl::setBody(Stmt *B) { BodyAndNothrow.setPointer(B); }
+
+bool CapturedDecl::isNothrow() const { return BodyAndNothrow.getInt(); }
+void CapturedDecl::setNothrow(bool Nothrow) { BodyAndNothrow.setInt(Nothrow); }
+
 EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD,
                                            SourceLocation L,
                                            IdentifierInfo *Id, QualType T,
index 71bc247a007f95084b0cc3a798d3fe2a0dc6992f..4f24fdc28f7171b55c4146439c1454e0d78c9346 100644 (file)
@@ -1218,6 +1218,10 @@ CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() const {
   return nullptr;
 }
 
+MemberSpecializationInfo *CXXRecordDecl::getMemberSpecializationInfo() const {
+  return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>();
+}
+
 void 
 CXXRecordDecl::setInstantiationOfMemberClass(CXXRecordDecl *RD,
                                              TemplateSpecializationKind TSK) {
@@ -1228,6 +1232,14 @@ CXXRecordDecl::setInstantiationOfMemberClass(CXXRecordDecl *RD,
     = new (getASTContext()) MemberSpecializationInfo(RD, TSK);
 }
 
+ClassTemplateDecl *CXXRecordDecl::getDescribedClassTemplate() const {
+  return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl *>();
+}
+
+void CXXRecordDecl::setDescribedClassTemplate(ClassTemplateDecl *Template) {
+  TemplateOrInstantiation = Template;
+}
+
 TemplateSpecializationKind CXXRecordDecl::getTemplateSpecializationKind() const{
   if (const ClassTemplateSpecializationDecl *Spec
         = dyn_cast<ClassTemplateSpecializationDecl>(this))
@@ -2016,6 +2028,22 @@ NamespaceDecl *NamespaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
                                    SourceLocation(), nullptr, nullptr);
 }
 
+NamespaceDecl *NamespaceDecl::getOriginalNamespace() {
+  if (isFirstDecl())
+    return this;
+
+  return AnonOrFirstNamespaceAndInline.getPointer();
+}
+
+const NamespaceDecl *NamespaceDecl::getOriginalNamespace() const {
+  if (isFirstDecl())
+    return this;
+
+  return AnonOrFirstNamespaceAndInline.getPointer();
+}
+
+bool NamespaceDecl::isOriginalNamespace() const { return isFirstDecl(); }
+
 NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() {
   return getNextRedeclaration();
 }
index 10434463b882edef53c243cff6da2eff7ce05608..ca63d8486d8235a7a8a2795ad6041a27a6a6d3af 100644 (file)
@@ -972,6 +972,17 @@ CapturedStmt::Capture::Capture(SourceLocation Loc, VariableCaptureKind Kind,
   }
 }
 
+CapturedStmt::VariableCaptureKind
+CapturedStmt::Capture::getCaptureKind() const {
+  return VarAndKind.getInt();
+}
+
+VarDecl *CapturedStmt::Capture::getCapturedVar() const {
+  assert((capturesVariable() || capturesVariableByCopy()) &&
+         "No variable available for 'this' or VAT capture");
+  return VarAndKind.getPointer();
+}
+
 CapturedStmt::Capture *CapturedStmt::getStoredCaptures() const {
   unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1);
 
@@ -1060,6 +1071,29 @@ Stmt::child_range CapturedStmt::children() {
   return child_range(getStoredStmts(), getStoredStmts() + NumCaptures);
 }
 
+CapturedDecl *CapturedStmt::getCapturedDecl() {
+  return CapDeclAndKind.getPointer();
+}
+const CapturedDecl *CapturedStmt::getCapturedDecl() const {
+  return CapDeclAndKind.getPointer();
+}
+
+/// \brief Set the outlined function declaration.
+void CapturedStmt::setCapturedDecl(CapturedDecl *D) {
+  assert(D && "null CapturedDecl");
+  CapDeclAndKind.setPointer(D);
+}
+
+/// \brief Retrieve the captured region kind.
+CapturedRegionKind CapturedStmt::getCapturedRegionKind() const {
+  return CapDeclAndKind.getInt();
+}
+
+/// \brief Set the captured region kind.
+void CapturedStmt::setCapturedRegionKind(CapturedRegionKind Kind) {
+  CapDeclAndKind.setInt(Kind);
+}
+
 bool CapturedStmt::capturesVariable(const VarDecl *Var) const {
   for (const auto &I : captures()) {
     if (!I.capturesVariable())
index e612f10eef04e42f595209ecbd1b7f83c42a31a9..f46f3cffde49e10a396a85f2d33283b4180763f2 100644 (file)
@@ -51,6 +51,18 @@ void SubstTemplateTemplateParmPackStorage::Profile(llvm::FoldingSetNodeID &ID,
   ArgPack.Profile(ID, Context);
 }
 
+TemplateName::TemplateName(TemplateDecl *Template) : Storage(Template) {}
+TemplateName::TemplateName(OverloadedTemplateStorage *Storage)
+    : Storage(Storage) {}
+TemplateName::TemplateName(SubstTemplateTemplateParmStorage *Storage)
+    : Storage(Storage) {}
+TemplateName::TemplateName(SubstTemplateTemplateParmPackStorage *Storage)
+    : Storage(Storage) {}
+TemplateName::TemplateName(QualifiedTemplateName *Qual) : Storage(Qual) {}
+TemplateName::TemplateName(DependentTemplateName *Dep) : Storage(Dep) {}
+
+bool TemplateName::isNull() const { return Storage.isNull(); }
+
 TemplateName::NameKind TemplateName::getKind() const {
   if (Storage.is<TemplateDecl *>())
     return Template;
@@ -81,6 +93,40 @@ TemplateDecl *TemplateName::getAsTemplateDecl() const {
   return nullptr;
 }
 
+OverloadedTemplateStorage *TemplateName::getAsOverloadedTemplate() const {
+  if (UncommonTemplateNameStorage *Uncommon =
+          Storage.dyn_cast<UncommonTemplateNameStorage *>())
+    return Uncommon->getAsOverloadedStorage();
+
+  return nullptr;
+}
+
+SubstTemplateTemplateParmStorage *
+TemplateName::getAsSubstTemplateTemplateParm() const {
+  if (UncommonTemplateNameStorage *uncommon =
+          Storage.dyn_cast<UncommonTemplateNameStorage *>())
+    return uncommon->getAsSubstTemplateTemplateParm();
+
+  return nullptr;
+}
+
+SubstTemplateTemplateParmPackStorage *
+TemplateName::getAsSubstTemplateTemplateParmPack() const {
+  if (UncommonTemplateNameStorage *Uncommon =
+          Storage.dyn_cast<UncommonTemplateNameStorage *>())
+    return Uncommon->getAsSubstTemplateTemplateParmPack();
+
+  return nullptr;
+}
+
+QualifiedTemplateName *TemplateName::getAsQualifiedTemplateName() const {
+  return Storage.dyn_cast<QualifiedTemplateName *>();
+}
+
+DependentTemplateName *TemplateName::getAsDependentTemplateName() const {
+  return Storage.dyn_cast<DependentTemplateName *>();
+}
+
 bool TemplateName::isDependent() const {
   if (TemplateDecl *Template = getAsTemplateDecl()) {
     if (isa<TemplateTemplateParmDecl>(Template))