summaryrefslogtreecommitdiff
path: root/include/clang/AST/DeclCXX.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/DeclCXX.h')
-rw-r--r--include/clang/AST/DeclCXX.h534
1 files changed, 314 insertions, 220 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 2f735c5506c4..88dc9a655917 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -1,4 +1,4 @@
-//===-- DeclCXX.h - Classes for representing C++ declarations -*- C++ -*-=====//
+//===- DeclCXX.h - Classes for representing C++ declarations --*- C++ -*-=====//
//
// The LLVM Compiler Infrastructure
//
@@ -6,11 +6,11 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief Defines the C++ Decl subclasses, other than those for templates
/// (found in DeclTemplate.h) and friends (in DeclFriend.h).
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_DECLCXX_H
@@ -20,29 +20,56 @@
#include "clang/AST/ASTUnresolvedSet.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
#include "clang/AST/Expr.h"
+#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/LambdaCapture.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/Redeclarable.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Lambda.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/TrailingObjects.h"
+#include <cassert>
+#include <cstddef>
+#include <iterator>
+#include <memory>
+#include <vector>
namespace clang {
class ClassTemplateDecl;
-class ClassTemplateSpecializationDecl;
class ConstructorUsingShadowDecl;
class CXXBasePath;
class CXXBasePaths;
class CXXConstructorDecl;
-class CXXConversionDecl;
class CXXDestructorDecl;
-class CXXMethodDecl;
-class CXXRecordDecl;
-class CXXMemberLookupCriteria;
class CXXFinalOverriderMap;
class CXXIndirectPrimaryBaseSet;
+class CXXMethodDecl;
+class DiagnosticBuilder;
class FriendDecl;
-class LambdaExpr;
+class FunctionTemplateDecl;
+class IdentifierInfo;
+class MemberSpecializationInfo;
+class TemplateDecl;
+class TemplateParameterList;
class UsingDecl;
/// \brief Represents any kind of function declaration, whether it is a
@@ -50,10 +77,10 @@ class UsingDecl;
class AnyFunctionDecl {
NamedDecl *Function;
- AnyFunctionDecl(NamedDecl *ND) : Function(ND) { }
+ AnyFunctionDecl(NamedDecl *ND) : Function(ND) {}
public:
- AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { }
+ AnyFunctionDecl(FunctionDecl *FD) : Function(FD) {}
AnyFunctionDecl(FunctionTemplateDecl *FTD);
/// \brief Implicily converts any function or function template into a
@@ -68,17 +95,18 @@ public:
}
};
-} // end namespace clang
+} // namespace clang
namespace llvm {
+
// Provide PointerLikeTypeTraits for non-cvr pointers.
template<>
- class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
- public:
- static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
+ struct PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
+ static void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
return F.get();
}
- static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
+
+ static ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
return ::clang::AnyFunctionDecl::getFromNamedDecl(
static_cast< ::clang::NamedDecl*>(P));
}
@@ -86,7 +114,7 @@ namespace llvm {
enum { NumLowBitsAvailable = 2 };
};
-} // end namespace llvm
+} // namespace llvm
namespace clang {
@@ -101,7 +129,6 @@ namespace clang {
/// Also note that this class has nothing to do with so-called
/// "access declarations" (C++98 11.3 [class.access.dcl]).
class AccessSpecDecl : public Decl {
- virtual void anchor();
/// \brief The location of the ':'.
SourceLocation ColonLoc;
@@ -110,16 +137,21 @@ class AccessSpecDecl : public Decl {
: Decl(AccessSpec, DC, ASLoc), ColonLoc(ColonLoc) {
setAccess(AS);
}
- AccessSpecDecl(EmptyShell Empty)
- : Decl(AccessSpec, Empty) { }
+
+ AccessSpecDecl(EmptyShell Empty) : Decl(AccessSpec, Empty) {}
+
+ virtual void anchor();
+
public:
/// \brief The location of the access specifier.
SourceLocation getAccessSpecifierLoc() const { return getLocation(); }
+
/// \brief Sets the location of the access specifier.
void setAccessSpecifierLoc(SourceLocation ASLoc) { setLocation(ASLoc); }
/// \brief The location of the colon following the access specifier.
SourceLocation getColonLoc() const { return ColonLoc; }
+
/// \brief Sets the location of the colon.
void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; }
@@ -132,6 +164,7 @@ public:
SourceLocation ColonLoc) {
return new (C, DC) AccessSpecDecl(AS, DC, ASLoc, ColonLoc);
}
+
static AccessSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID);
// Implement isa/cast/dyncast/etc.
@@ -191,12 +224,11 @@ class CXXBaseSpecifier {
TypeSourceInfo *BaseTypeInfo;
public:
- CXXBaseSpecifier() { }
-
+ CXXBaseSpecifier() = default;
CXXBaseSpecifier(SourceRange R, bool V, bool BC, AccessSpecifier A,
TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
: Range(R), EllipsisLoc(EllipsisLoc), Virtual(V), BaseOfClass(BC),
- Access(A), InheritConstructors(false), BaseTypeInfo(TInfo) { }
+ Access(A), InheritConstructors(false), BaseTypeInfo(TInfo) {}
/// \brief Retrieves the source range that contains the entire base specifier.
SourceRange getSourceRange() const LLVM_READONLY { return Range; }
@@ -265,7 +297,16 @@ public:
/// \brief Represents a C++ struct/union/class.
class CXXRecordDecl : public RecordDecl {
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+ friend class ASTNodeImporter;
+ friend class ASTReader;
+ friend class ASTRecordWriter;
+ friend class ASTWriter;
+ friend class DeclContext;
+ friend class LambdaExpr;
+ friend void FunctionDecl::setPure(bool);
friend void TagDecl::startDefinition();
/// Values used in DefinitionData fields to represent special members.
@@ -280,8 +321,6 @@ class CXXRecordDecl : public RecordDecl {
};
struct DefinitionData {
- DefinitionData(CXXRecordDecl *D);
-
/// \brief True if this class has any user-declared constructors.
unsigned UserDeclaredConstructor : 1;
@@ -475,13 +514,13 @@ class CXXRecordDecl : public RecordDecl {
unsigned HasODRHash : 1;
/// \brief A hash of parts of the class to help in ODR checking.
- unsigned ODRHash;
+ unsigned ODRHash = 0;
/// \brief The number of base class specifiers in Bases.
- unsigned NumBases;
+ unsigned NumBases = 0;
/// \brief The number of virtual base class specifiers in VBases.
- unsigned NumVBases;
+ unsigned NumVBases = 0;
/// \brief Base classes of this class.
///
@@ -513,6 +552,8 @@ class CXXRecordDecl : public RecordDecl {
/// This is actually currently stored in reverse order.
LazyDeclPtr FirstFriend;
+ DefinitionData(CXXRecordDecl *D);
+
/// \brief Retrieve the set of direct base classes.
CXXBaseSpecifier *getBases() const {
if (!Bases.isOffset())
@@ -530,6 +571,7 @@ class CXXRecordDecl : public RecordDecl {
ArrayRef<CXXBaseSpecifier> bases() const {
return llvm::makeArrayRef(getBases(), NumBases);
}
+
ArrayRef<CXXBaseSpecifier> vbases() const {
return llvm::makeArrayRef(getVBases(), NumVBases);
}
@@ -543,22 +585,7 @@ class CXXRecordDecl : public RecordDecl {
/// \brief Describes a C++ closure type (generated by a lambda expression).
struct LambdaDefinitionData : public DefinitionData {
- typedef LambdaCapture Capture;
-
- LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info,
- bool Dependent, bool IsGeneric,
- LambdaCaptureDefault CaptureDefault)
- : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric),
- CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0),
- ManglingNumber(0), ContextDecl(nullptr), Captures(nullptr),
- MethodTyInfo(Info) {
- IsLambda = true;
-
- // C++1z [expr.prim.lambda]p4:
- // This class type is not an aggregate type.
- Aggregate = false;
- PlainOldData = false;
- }
+ using Capture = LambdaCapture;
/// \brief Whether this lambda is known to be dependent, even if its
/// context isn't dependent.
@@ -584,7 +611,7 @@ class CXXRecordDecl : public RecordDecl {
/// \brief The number used to indicate this lambda expression for name
/// mangling in the Itanium C++ ABI.
- unsigned ManglingNumber;
+ unsigned ManglingNumber = 0;
/// \brief The declaration that provides context for this lambda, if the
/// actual DeclContext does not suffice. This is used for lambdas that
@@ -594,11 +621,24 @@ class CXXRecordDecl : public RecordDecl {
/// \brief The list of captures, both explicit and implicit, for this
/// lambda.
- Capture *Captures;
+ Capture *Captures = nullptr;
/// \brief The type of the call method.
TypeSourceInfo *MethodTyInfo;
-
+
+ LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info,
+ bool Dependent, bool IsGeneric,
+ LambdaCaptureDefault CaptureDefault)
+ : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric),
+ CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0),
+ MethodTyInfo(Info) {
+ IsLambda = true;
+
+ // C++1z [expr.prim.lambda]p4:
+ // This class type is not an aggregate type.
+ Aggregate = false;
+ PlainOldData = false;
+ }
};
struct DefinitionData *dataPtr() const {
@@ -630,11 +670,8 @@ class CXXRecordDecl : public RecordDecl {
/// classes of class template specializations, this will be the
/// MemberSpecializationInfo referring to the member class that was
/// instantiated or specialized.
- llvm::PointerUnion<ClassTemplateDecl*, MemberSpecializationInfo*>
- TemplateOrInstantiation;
-
- friend class DeclContext;
- friend class LambdaExpr;
+ llvm::PointerUnion<ClassTemplateDecl *, MemberSpecializationInfo *>
+ TemplateOrInstantiation;
/// \brief Called from setBases and addedMember to notify the class that a
/// direct or virtual base class or a member of class type has been added.
@@ -648,9 +685,6 @@ class CXXRecordDecl : public RecordDecl {
void addedMember(Decl *D);
void markedVirtualFunctionPure();
- friend void FunctionDecl::setPure(bool);
-
- friend class ASTNodeImporter;
/// \brief Get the head of our list of friend declarations, possibly
/// deserializing the friends from an external AST source.
@@ -663,14 +697,15 @@ protected:
public:
/// \brief Iterator that traverses the base classes of a class.
- typedef CXXBaseSpecifier* base_class_iterator;
+ using base_class_iterator = CXXBaseSpecifier *;
/// \brief Iterator that traverses the base classes of a class.
- typedef const CXXBaseSpecifier* base_class_const_iterator;
+ using base_class_const_iterator = const CXXBaseSpecifier *;
CXXRecordDecl *getCanonicalDecl() override {
return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
}
+
const CXXRecordDecl *getCanonicalDecl() const {
return const_cast<CXXRecordDecl*>(this)->getCanonicalDecl();
}
@@ -679,6 +714,7 @@ public:
return cast_or_null<CXXRecordDecl>(
static_cast<RecordDecl *>(this)->getPreviousDecl());
}
+
const CXXRecordDecl *getPreviousDecl() const {
return const_cast<CXXRecordDecl*>(this)->getPreviousDecl();
}
@@ -730,9 +766,9 @@ public:
/// \brief Retrieves the number of base classes of this class.
unsigned getNumBases() const { return data().NumBases; }
- typedef llvm::iterator_range<base_class_iterator> base_class_range;
- typedef llvm::iterator_range<base_class_const_iterator>
- base_class_const_range;
+ using base_class_range = llvm::iterator_range<base_class_iterator>;
+ using base_class_const_range =
+ llvm::iterator_range<base_class_const_iterator>;
base_class_range bases() {
return base_class_range(bases_begin(), bases_end());
@@ -772,9 +808,9 @@ public:
/// Iterator access to method members. The method iterator visits
/// all method members of the class, including non-instance methods,
/// special methods, etc.
- typedef specific_decl_iterator<CXXMethodDecl> method_iterator;
- typedef llvm::iterator_range<specific_decl_iterator<CXXMethodDecl>>
- method_range;
+ using method_iterator = specific_decl_iterator<CXXMethodDecl>;
+ using method_range =
+ llvm::iterator_range<specific_decl_iterator<CXXMethodDecl>>;
method_range methods() const {
return method_range(method_begin(), method_end());
@@ -785,21 +821,23 @@ public:
method_iterator method_begin() const {
return method_iterator(decls_begin());
}
+
/// \brief Method past-the-end iterator.
method_iterator method_end() const {
return method_iterator(decls_end());
}
/// Iterator access to constructor members.
- typedef specific_decl_iterator<CXXConstructorDecl> ctor_iterator;
- typedef llvm::iterator_range<specific_decl_iterator<CXXConstructorDecl>>
- ctor_range;
+ using ctor_iterator = specific_decl_iterator<CXXConstructorDecl>;
+ using ctor_range =
+ llvm::iterator_range<specific_decl_iterator<CXXConstructorDecl>>;
ctor_range ctors() const { return ctor_range(ctor_begin(), ctor_end()); }
ctor_iterator ctor_begin() const {
return ctor_iterator(decls_begin());
}
+
ctor_iterator ctor_end() const {
return ctor_iterator(decls_end());
}
@@ -807,7 +845,7 @@ public:
/// An iterator over friend declarations. All of these are defined
/// in DeclFriend.h.
class friend_iterator;
- typedef llvm::iterator_range<friend_iterator> friend_range;
+ using friend_range = llvm::iterator_range<friend_iterator>;
friend_range friends() const;
friend_iterator friend_begin() const;
@@ -839,7 +877,10 @@ public:
/// \brief \c true if a defaulted destructor for this class would be deleted.
bool defaultedDestructorIsDeleted() const {
- return !data().DefaultedDestructorIsDeleted;
+ assert((!needsOverloadResolutionForDestructor() ||
+ (data().DeclaredSpecialMembers & SMF_Destructor)) &&
+ "this property has not yet been computed by Sema");
+ return data().DefaultedDestructorIsDeleted;
}
/// \brief \c true if we know for sure that this class has a single,
@@ -986,6 +1027,15 @@ public:
data().DefaultedMoveConstructorIsDeleted = true;
}
+ /// \brief Set that we attempted to declare an implicit destructor,
+ /// but overload resolution failed so we deleted it.
+ void setImplicitDestructorIsDeleted() {
+ assert((data().DefaultedDestructorIsDeleted ||
+ needsOverloadResolutionForDestructor()) &&
+ "destructor should not be deleted");
+ data().DefaultedDestructorIsDeleted = true;
+ }
+
/// \brief Determine whether this class should get an implicit move
/// constructor or if any existing special member function inhibits this.
bool needsImplicitMoveConstructor() const {
@@ -1144,24 +1194,28 @@ public:
void getCaptureFields(llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
FieldDecl *&ThisCapture) const;
- typedef const LambdaCapture *capture_const_iterator;
- typedef llvm::iterator_range<capture_const_iterator> capture_const_range;
+ using capture_const_iterator = const LambdaCapture *;
+ using capture_const_range = llvm::iterator_range<capture_const_iterator>;
capture_const_range captures() const {
return capture_const_range(captures_begin(), captures_end());
}
+
capture_const_iterator captures_begin() const {
return isLambda() ? getLambdaData().Captures : nullptr;
}
+
capture_const_iterator captures_end() const {
return isLambda() ? captures_begin() + getLambdaData().NumCaptures
: nullptr;
}
- typedef UnresolvedSetIterator conversion_iterator;
+ using conversion_iterator = UnresolvedSetIterator;
+
conversion_iterator conversion_begin() const {
return data().Conversions.get(getASTContext()).begin();
}
+
conversion_iterator conversion_end() const {
return data().Conversions.get(getASTContext()).end();
}
@@ -1433,10 +1487,10 @@ public:
/// We resolve DR1361 by ignoring the second bullet. We resolve DR1452 by
/// treating types with trivial default constructors as literal types.
///
- /// Only in C++1z and beyond, are lambdas literal types.
+ /// Only in C++17 and beyond, are lambdas literal types.
bool isLiteral() const {
return hasTrivialDestructor() &&
- (!isLambda() || getASTContext().getLangOpts().CPlusPlus1z) &&
+ (!isLambda() || getASTContext().getLangOpts().CPlusPlus17) &&
!hasNonLiteralTypeFieldsOrBases() &&
(isAggregate() || isLambda() ||
hasConstexprNonCopyMoveConstructor() ||
@@ -1585,8 +1639,8 @@ public:
/// \param BaseDefinition the definition of the base class
///
/// \returns true if this base matched the search criteria
- typedef llvm::function_ref<bool(const CXXRecordDecl *BaseDefinition)>
- ForallBasesCallback;
+ using ForallBasesCallback =
+ llvm::function_ref<bool(const CXXRecordDecl *BaseDefinition)>;
/// \brief Determines if the given callback holds for all the direct
/// or indirect base classes of this type.
@@ -1614,8 +1668,9 @@ public:
/// base named by the \p Specifier.
///
/// \returns true if this base matched the search criteria, false otherwise.
- typedef llvm::function_ref<bool(const CXXBaseSpecifier *Specifier,
- CXXBasePath &Path)> BaseMatchesCallback;
+ using BaseMatchesCallback =
+ llvm::function_ref<bool(const CXXBaseSpecifier *Specifier,
+ CXXBasePath &Path)>;
/// \brief Look for entities within the base classes of this C++ class,
/// transitively searching all base class subobjects.
@@ -1794,6 +1849,7 @@ public:
/// \brief Returns the inheritance model used for this record.
MSInheritanceAttr::Spelling getMSInheritanceModel() const;
+
/// \brief Calculate what the inheritance model would be for this class.
MSInheritanceAttr::Spelling calculateInheritanceModel() const;
@@ -1832,16 +1888,14 @@ public:
return getLambdaData().MethodTyInfo;
}
+ // \brief Determine whether this type is an Interface Like type for
+ // __interface inheritence purposes.
+ bool isInterfaceLike() const;
+
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) {
return K >= firstCXXRecord && K <= lastCXXRecord;
}
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
- friend class ASTRecordWriter;
- friend class ASTReader;
- friend class ASTWriter;
};
/// \brief Represents a C++ deduction guide declaration.
@@ -1856,6 +1910,7 @@ public:
/// the constructors of \c A.
class CXXDeductionGuideDecl : public FunctionDecl {
void anchor() override;
+
private:
CXXDeductionGuideDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
bool IsExplicit, const DeclarationNameInfo &NameInfo,
@@ -1869,6 +1924,9 @@ private:
}
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+
static CXXDeductionGuideDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation StartLoc, bool IsExplicit,
const DeclarationNameInfo &NameInfo,
@@ -1888,12 +1946,15 @@ public:
return getDeclName().getCXXDeductionGuideTemplate();
}
+ void setIsCopyDeductionCandidate() {
+ IsCopyDeductionCandidate = true;
+ }
+
+ bool isCopyDeductionCandidate() const { return IsCopyDeductionCandidate; }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == CXXDeductionGuide; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// \brief Represents a static or instance method of a struct/union/class.
@@ -1902,6 +1963,7 @@ public:
/// non-static) member functions, whether virtual or not.
class CXXMethodDecl : public FunctionDecl {
void anchor() override;
+
protected:
CXXMethodDecl(Kind DK, ASTContext &C, CXXRecordDecl *RD,
SourceLocation StartLoc, const DeclarationNameInfo &NameInfo,
@@ -1953,7 +2015,7 @@ public:
if (CD->isVirtualAsWritten() || CD->isPure())
return true;
- return (CD->begin_overridden_methods() != CD->end_overridden_methods());
+ return CD->size_overridden_methods() != 0;
}
/// If it's possible to devirtualize a call to this method, return the called
@@ -1999,18 +2061,23 @@ public:
/// True if this method is user-declared and was not
/// deleted or defaulted on its first declaration.
bool isUserProvided() const {
- return !(isDeleted() || getCanonicalDecl()->isDefaulted());
+ auto *DeclAsWritten = this;
+ if (auto *Pattern = getTemplateInstantiationPattern())
+ DeclAsWritten = cast<CXXMethodDecl>(Pattern);
+ return !(DeclAsWritten->isDeleted() ||
+ DeclAsWritten->getCanonicalDecl()->isDefaulted());
}
- ///
void addOverriddenMethod(const CXXMethodDecl *MD);
- typedef const CXXMethodDecl *const* method_iterator;
+ using method_iterator = const CXXMethodDecl *const *;
method_iterator begin_overridden_methods() const;
method_iterator end_overridden_methods() const;
unsigned size_overridden_methods() const;
- typedef ASTContext::overridden_method_range overridden_method_range;
+
+ using overridden_method_range= ASTContext::overridden_method_range;
+
overridden_method_range overridden_methods() const;
/// Returns the parent of this method declaration, which
@@ -2240,6 +2307,7 @@ public:
return Initializee.get<FieldDecl*>();
return nullptr;
}
+
FieldDecl *getAnyMember() const {
if (isMemberInitializer())
return Initializee.get<FieldDecl*>();
@@ -2301,11 +2369,11 @@ public:
/// Description of a constructor that was inherited from a base class.
class InheritedConstructor {
- ConstructorUsingShadowDecl *Shadow;
- CXXConstructorDecl *BaseCtor;
+ ConstructorUsingShadowDecl *Shadow = nullptr;
+ CXXConstructorDecl *BaseCtor = nullptr;
public:
- InheritedConstructor() : Shadow(), BaseCtor() {}
+ InheritedConstructor() = default;
InheritedConstructor(ConstructorUsingShadowDecl *Shadow,
CXXConstructorDecl *BaseCtor)
: Shadow(Shadow), BaseCtor(BaseCtor) {}
@@ -2329,8 +2397,6 @@ public:
class CXXConstructorDecl final
: public CXXMethodDecl,
private llvm::TrailingObjects<CXXConstructorDecl, InheritedConstructor> {
- void anchor() override;
-
/// \name Support for base and member initializers.
/// \{
/// \brief The arguments used to initialize the base or member.
@@ -2350,15 +2416,20 @@ class CXXConstructorDecl final
InheritedConstructor Inherited)
: CXXMethodDecl(CXXConstructor, C, RD, StartLoc, NameInfo, T, TInfo,
SC_None, isInline, isConstexpr, SourceLocation()),
- CtorInitializers(nullptr), NumCtorInitializers(0),
- IsInheritingConstructor((bool)Inherited) {
+ NumCtorInitializers(0), IsInheritingConstructor((bool)Inherited) {
setImplicit(isImplicitlyDeclared);
if (Inherited)
*getTrailingObjects<InheritedConstructor>() = Inherited;
IsExplicitSpecified = isExplicitSpecified;
}
+ void anchor() override;
+
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+ friend TrailingObjects;
+
static CXXConstructorDecl *CreateDeserialized(ASTContext &C, unsigned ID,
bool InheritsConstructor);
static CXXConstructorDecl *
@@ -2369,13 +2440,13 @@ public:
InheritedConstructor Inherited = InheritedConstructor());
/// \brief Iterates through the member/base initializer list.
- typedef CXXCtorInitializer **init_iterator;
+ using init_iterator = CXXCtorInitializer **;
/// \brief Iterates through the member/base initializer list.
- typedef CXXCtorInitializer *const *init_const_iterator;
+ using init_const_iterator = CXXCtorInitializer *const *;
- typedef llvm::iterator_range<init_iterator> init_range;
- typedef llvm::iterator_range<init_const_iterator> init_const_range;
+ using init_range = llvm::iterator_range<init_iterator>;
+ using init_const_range = llvm::iterator_range<init_const_iterator>;
init_range inits() { return init_range(init_begin(), init_end()); }
init_const_range inits() const {
@@ -2387,6 +2458,7 @@ public:
const auto *ConstThis = this;
return const_cast<init_iterator>(ConstThis->init_begin());
}
+
/// \brief Retrieve an iterator to the first initializer.
init_const_iterator init_begin() const;
@@ -2394,14 +2466,15 @@ public:
init_iterator init_end() {
return init_begin() + NumCtorInitializers;
}
+
/// \brief Retrieve an iterator past the last initializer.
init_const_iterator init_end() const {
return init_begin() + NumCtorInitializers;
}
- typedef std::reverse_iterator<init_iterator> init_reverse_iterator;
- typedef std::reverse_iterator<init_const_iterator>
- init_const_reverse_iterator;
+ using init_reverse_iterator = std::reverse_iterator<init_iterator>;
+ using init_const_reverse_iterator =
+ std::reverse_iterator<init_const_iterator>;
init_reverse_iterator init_rbegin() {
return init_reverse_iterator(init_end());
@@ -2532,10 +2605,6 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == CXXConstructor; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
- friend TrailingObjects;
};
/// \brief Represents a C++ destructor within a class.
@@ -2549,20 +2618,26 @@ public:
/// };
/// \endcode
class CXXDestructorDecl : public CXXMethodDecl {
- void anchor() override;
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
- FunctionDecl *OperatorDelete;
+ // FIXME: Don't allocate storage for these except in the first declaration
+ // of a virtual destructor.
+ FunctionDecl *OperatorDelete = nullptr;
+ Expr *OperatorDeleteThisArg = nullptr;
CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
bool isInline, bool isImplicitlyDeclared)
: CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo,
- SC_None, isInline, /*isConstexpr=*/false, SourceLocation()),
- OperatorDelete(nullptr) {
+ SC_None, isInline, /*isConstexpr=*/false, SourceLocation())
+ {
setImplicit(isImplicitlyDeclared);
}
+ void anchor() override;
+
public:
static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation StartLoc,
@@ -2572,11 +2647,16 @@ public:
bool isImplicitlyDeclared);
static CXXDestructorDecl *CreateDeserialized(ASTContext & C, unsigned ID);
- void setOperatorDelete(FunctionDecl *OD);
+ void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
+
const FunctionDecl *getOperatorDelete() const {
return getCanonicalDecl()->OperatorDelete;
}
+ Expr *getOperatorDeleteThisArg() const {
+ return getCanonicalDecl()->OperatorDeleteThisArg;
+ }
+
CXXDestructorDecl *getCanonicalDecl() override {
return cast<CXXDestructorDecl>(FunctionDecl::getCanonicalDecl());
}
@@ -2587,9 +2667,6 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == CXXDestructor; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// \brief Represents a C++ conversion function within a class.
@@ -2603,8 +2680,6 @@ public:
/// };
/// \endcode
class CXXConversionDecl : public CXXMethodDecl {
- void anchor() override;
-
CXXConversionDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, bool isInline,
@@ -2615,7 +2690,12 @@ class CXXConversionDecl : public CXXMethodDecl {
IsExplicitSpecified = isExplicitSpecified;
}
+ void anchor() override;
+
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+
static CXXConversionDecl *Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
@@ -2652,9 +2732,6 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == CXXConversion; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// \brief Represents a linkage specification.
@@ -2665,6 +2742,7 @@ public:
/// \endcode
class LinkageSpecDecl : public Decl, public DeclContext {
virtual void anchor();
+
public:
/// \brief Represents the language in a linkage specification.
///
@@ -2676,25 +2754,29 @@ public:
lang_c = /* DW_LANG_C */ 0x0002,
lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004
};
+
private:
/// \brief The language for this linkage specification.
unsigned Language : 3;
+
/// \brief True if this linkage spec has braces.
///
/// This is needed so that hasBraces() returns the correct result while the
/// linkage spec body is being parsed. Once RBraceLoc has been set this is
/// not used, so it doesn't need to be serialized.
unsigned HasBraces : 1;
+
/// \brief The source location for the extern keyword.
SourceLocation ExternLoc;
+
/// \brief The source location for the right brace (if valid).
SourceLocation RBraceLoc;
LinkageSpecDecl(DeclContext *DC, SourceLocation ExternLoc,
SourceLocation LangLoc, LanguageIDs lang, bool HasBraces)
- : Decl(LinkageSpec, DC, LangLoc), DeclContext(LinkageSpec),
- Language(lang), HasBraces(HasBraces), ExternLoc(ExternLoc),
- RBraceLoc(SourceLocation()) { }
+ : Decl(LinkageSpec, DC, LangLoc), DeclContext(LinkageSpec),
+ Language(lang), HasBraces(HasBraces), ExternLoc(ExternLoc),
+ RBraceLoc(SourceLocation()) {}
public:
static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
@@ -2705,6 +2787,7 @@ public:
/// \brief Return the language specified by this linkage specification.
LanguageIDs getLanguage() const { return LanguageIDs(Language); }
+
/// \brief Set the language specified by this linkage specification.
void setLanguage(LanguageIDs L) { Language = L; }
@@ -2737,9 +2820,11 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == LinkageSpec; }
+
static DeclContext *castToDeclContext(const LinkageSpecDecl *D) {
return static_cast<DeclContext *>(const_cast<LinkageSpecDecl*>(D));
}
+
static LinkageSpecDecl *castFromDeclContext(const DeclContext *DC) {
return static_cast<LinkageSpecDecl *>(const_cast<DeclContext*>(DC));
}
@@ -2756,7 +2841,6 @@ public:
/// artificial names for all using-directives in order to store
/// them in DeclContext effectively.
class UsingDirectiveDecl : public NamedDecl {
- void anchor() override;
/// \brief The location of the \c using keyword.
SourceLocation UsingLoc;
@@ -2773,6 +2857,16 @@ class UsingDirectiveDecl : public NamedDecl {
/// namespace.
DeclContext *CommonAncestor;
+ UsingDirectiveDecl(DeclContext *DC, SourceLocation UsingLoc,
+ SourceLocation NamespcLoc,
+ NestedNameSpecifierLoc QualifierLoc,
+ SourceLocation IdentLoc,
+ NamedDecl *Nominated,
+ DeclContext *CommonAncestor)
+ : NamedDecl(UsingDirective, DC, IdentLoc, getName()), UsingLoc(UsingLoc),
+ NamespaceLoc(NamespcLoc), QualifierLoc(QualifierLoc),
+ NominatedNamespace(Nominated), CommonAncestor(CommonAncestor) {}
+
/// \brief Returns special DeclarationName used by using-directives.
///
/// This is only used by DeclContext for storing UsingDirectiveDecls in
@@ -2781,17 +2875,14 @@ class UsingDirectiveDecl : public NamedDecl {
return DeclarationName::getUsingDirectiveName();
}
- UsingDirectiveDecl(DeclContext *DC, SourceLocation UsingLoc,
- SourceLocation NamespcLoc,
- NestedNameSpecifierLoc QualifierLoc,
- SourceLocation IdentLoc,
- NamedDecl *Nominated,
- DeclContext *CommonAncestor)
- : NamedDecl(UsingDirective, DC, IdentLoc, getName()), UsingLoc(UsingLoc),
- NamespaceLoc(NamespcLoc), QualifierLoc(QualifierLoc),
- NominatedNamespace(Nominated), CommonAncestor(CommonAncestor) { }
+ void anchor() override;
public:
+ friend class ASTDeclReader;
+
+ // Friend for getUsingDirectiveName.
+ friend class DeclContext;
+
/// \brief Retrieve the nested-name-specifier that qualifies the
/// name of the namespace, with source-location information.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
@@ -2844,11 +2935,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == UsingDirective; }
-
- // Friend for getUsingDirectiveName.
- friend class DeclContext;
-
- friend class ASTDeclReader;
};
/// \brief Represents a C++ namespace alias.
@@ -2860,7 +2946,7 @@ public:
/// \endcode
class NamespaceAliasDecl : public NamedDecl,
public Redeclarable<NamespaceAliasDecl> {
- void anchor() override;
+ friend class ASTDeclReader;
/// \brief The location of the \c namespace keyword.
SourceLocation NamespaceLoc;
@@ -2885,13 +2971,14 @@ class NamespaceAliasDecl : public NamedDecl,
NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc),
QualifierLoc(QualifierLoc), Namespace(Namespace) {}
- typedef Redeclarable<NamespaceAliasDecl> redeclarable_base;
+ void anchor() override;
+
+ using redeclarable_base = Redeclarable<NamespaceAliasDecl>;
+
NamespaceAliasDecl *getNextRedeclarationImpl() override;
NamespaceAliasDecl *getPreviousDeclImpl() override;
NamespaceAliasDecl *getMostRecentDeclImpl() override;
- friend class ASTDeclReader;
-
public:
static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation NamespaceLoc,
@@ -2903,8 +2990,9 @@ public:
static NamespaceAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID);
- typedef redeclarable_base::redecl_range redecl_range;
- typedef redeclarable_base::redecl_iterator redecl_iterator;
+ using redecl_range = redeclarable_base::redecl_range;
+ using redecl_iterator = redeclarable_base::redecl_iterator;
+
using redeclarable_base::redecls_begin;
using redeclarable_base::redecls_end;
using redeclarable_base::redecls;
@@ -2976,23 +3064,27 @@ public:
/// }
/// \endcode
class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
- void anchor() override;
+ friend class UsingDecl;
/// The referenced declaration.
- NamedDecl *Underlying;
+ NamedDecl *Underlying = nullptr;
/// \brief The using declaration which introduced this decl or the next using
/// shadow declaration contained in the aforementioned using declaration.
- NamedDecl *UsingOrNextShadow;
- friend class UsingDecl;
+ NamedDecl *UsingOrNextShadow = nullptr;
+
+ void anchor() override;
+
+ using redeclarable_base = Redeclarable<UsingShadowDecl>;
- typedef Redeclarable<UsingShadowDecl> redeclarable_base;
UsingShadowDecl *getNextRedeclarationImpl() override {
return getNextRedeclaration();
}
+
UsingShadowDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
}
+
UsingShadowDecl *getMostRecentDeclImpl() override {
return getMostRecentDecl();
}
@@ -3003,6 +3095,9 @@ protected:
UsingShadowDecl(Kind K, ASTContext &C, EmptyShell);
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+
static UsingShadowDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation Loc, UsingDecl *Using,
NamedDecl *Target) {
@@ -3011,8 +3106,9 @@ public:
static UsingShadowDecl *CreateDeserialized(ASTContext &C, unsigned ID);
- typedef redeclarable_base::redecl_range redecl_range;
- typedef redeclarable_base::redecl_iterator redecl_iterator;
+ using redecl_range = redeclarable_base::redecl_range;
+ using redecl_iterator = redeclarable_base::redecl_iterator;
+
using redeclarable_base::redecls_begin;
using redeclarable_base::redecls_end;
using redeclarable_base::redecls;
@@ -3052,9 +3148,6 @@ public:
static bool classofKind(Kind K) {
return K == Decl::UsingShadow || K == Decl::ConstructorUsingShadow;
}
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// \brief Represents a shadow constructor declaration introduced into a
@@ -3068,18 +3161,16 @@ public:
/// };
/// \endcode
class ConstructorUsingShadowDecl final : public UsingShadowDecl {
- void anchor() override;
-
/// \brief If this constructor using declaration inherted the constructor
/// from an indirect base class, this is the ConstructorUsingShadowDecl
/// in the named direct base class from which the declaration was inherited.
- ConstructorUsingShadowDecl *NominatedBaseClassShadowDecl;
+ ConstructorUsingShadowDecl *NominatedBaseClassShadowDecl = nullptr;
/// \brief If this constructor using declaration inherted the constructor
/// from an indirect base class, this is the ConstructorUsingShadowDecl
/// that will be used to construct the unique direct or virtual base class
/// that receives the constructor arguments.
- ConstructorUsingShadowDecl *ConstructedBaseClassShadowDecl;
+ ConstructorUsingShadowDecl *ConstructedBaseClassShadowDecl = nullptr;
/// \brief \c true if the constructor ultimately named by this using shadow
/// declaration is within a virtual base class subobject of the class that
@@ -3105,12 +3196,16 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl {
IsVirtual = true;
}
}
+
ConstructorUsingShadowDecl(ASTContext &C, EmptyShell Empty)
- : UsingShadowDecl(ConstructorUsingShadow, C, Empty),
- NominatedBaseClassShadowDecl(), ConstructedBaseClassShadowDecl(),
- IsVirtual(false) {}
+ : UsingShadowDecl(ConstructorUsingShadow, C, Empty), IsVirtual(false) {}
+
+ void anchor() override;
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+
static ConstructorUsingShadowDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation Loc,
UsingDecl *Using, NamedDecl *Target,
@@ -3169,9 +3264,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == ConstructorUsingShadow; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// \brief Represents a C++ using-declaration.
@@ -3181,8 +3273,6 @@ public:
/// using someNameSpace::someIdentifier;
/// \endcode
class UsingDecl : public NamedDecl, public Mergeable<UsingDecl> {
- void anchor() override;
-
/// \brief The source location of the 'using' keyword itself.
SourceLocation UsingLocation;
@@ -3208,7 +3298,12 @@ class UsingDecl : public NamedDecl, public Mergeable<UsingDecl> {
DNLoc(NameInfo.getInfo()), FirstUsingShadow(nullptr, HasTypenameKeyword) {
}
+ void anchor() override;
+
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+
/// \brief Return the source location of the 'using' keyword.
SourceLocation getUsingLoc() const { return UsingLocation; }
@@ -3241,17 +3336,17 @@ public:
/// this using declaration.
class shadow_iterator {
/// \brief The current using shadow declaration.
- UsingShadowDecl *Current;
+ UsingShadowDecl *Current = nullptr;
public:
- typedef UsingShadowDecl* value_type;
- typedef UsingShadowDecl* reference;
- typedef UsingShadowDecl* pointer;
- typedef std::forward_iterator_tag iterator_category;
- typedef std::ptrdiff_t difference_type;
+ using value_type = UsingShadowDecl *;
+ using reference = UsingShadowDecl *;
+ using pointer = UsingShadowDecl *;
+ using iterator_category = std::forward_iterator_tag;
+ using difference_type = std::ptrdiff_t;
- shadow_iterator() : Current(nullptr) { }
- explicit shadow_iterator(UsingShadowDecl *C) : Current(C) { }
+ shadow_iterator() = default;
+ explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {}
reference operator*() const { return Current; }
pointer operator->() const { return Current; }
@@ -3275,14 +3370,16 @@ public:
}
};
- typedef llvm::iterator_range<shadow_iterator> shadow_range;
+ using shadow_range = llvm::iterator_range<shadow_iterator>;
shadow_range shadows() const {
return shadow_range(shadow_begin(), shadow_end());
}
+
shadow_iterator shadow_begin() const {
return shadow_iterator(FirstUsingShadow.getPointer());
}
+
shadow_iterator shadow_end() const { return shadow_iterator(); }
/// \brief Return the number of shadowed declarations associated with this
@@ -3310,9 +3407,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Using; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// Represents a pack of using declarations that a single
@@ -3331,8 +3425,6 @@ public:
class UsingPackDecl final
: public NamedDecl, public Mergeable<UsingPackDecl>,
private llvm::TrailingObjects<UsingPackDecl, NamedDecl *> {
- void anchor() override;
-
/// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from
/// which this waas instantiated.
NamedDecl *InstantiatedFrom;
@@ -3352,7 +3444,13 @@ class UsingPackDecl final
getTrailingObjects<NamedDecl *>());
}
+ void anchor() override;
+
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+ friend TrailingObjects;
+
/// Get the using declaration from which this was instantiated. This will
/// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl
/// that is a pack expansion.
@@ -3380,10 +3478,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == UsingPack; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
- friend TrailingObjects;
};
/// \brief Represents a dependent using declaration which was not marked with
@@ -3399,8 +3493,6 @@ public:
/// \endcode
class UnresolvedUsingValueDecl : public ValueDecl,
public Mergeable<UnresolvedUsingValueDecl> {
- void anchor() override;
-
/// \brief The source location of the 'using' keyword
SourceLocation UsingLocation;
@@ -3419,13 +3511,17 @@ class UnresolvedUsingValueDecl : public ValueDecl,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
SourceLocation EllipsisLoc)
- : ValueDecl(UnresolvedUsingValue, DC,
- NameInfo.getLoc(), NameInfo.getName(), Ty),
- UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc),
- QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo())
- { }
+ : ValueDecl(UnresolvedUsingValue, DC,
+ NameInfo.getLoc(), NameInfo.getName(), Ty),
+ UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc),
+ QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo()) {}
+
+ void anchor() override;
public:
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
+
/// \brief Returns the source location of the 'using' keyword.
SourceLocation getUsingLoc() const { return UsingLocation; }
@@ -3478,9 +3574,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == UnresolvedUsingValue; }
-
- friend class ASTDeclReader;
- friend class ASTDeclWriter;
};
/// \brief Represents a dependent using declaration which was marked with
@@ -3497,7 +3590,7 @@ public:
class UnresolvedUsingTypenameDecl
: public TypeDecl,
public Mergeable<UnresolvedUsingTypenameDecl> {
- void anchor() override;
+ friend class ASTDeclReader;
/// \brief The source location of the 'typename' keyword
SourceLocation TypenameLocation;
@@ -3517,9 +3610,9 @@ class UnresolvedUsingTypenameDecl
: TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName,
UsingLoc),
TypenameLocation(TypenameLoc), EllipsisLoc(EllipsisLoc),
- QualifierLoc(QualifierLoc) { }
+ QualifierLoc(QualifierLoc) {}
- friend class ASTDeclReader;
+ void anchor() override;
public:
/// \brief Returns the source location of the 'using' keyword.
@@ -3574,7 +3667,6 @@ public:
/// \brief Represents a C++11 static_assert declaration.
class StaticAssertDecl : public Decl {
- virtual void anchor();
llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed;
StringLiteral *Message;
SourceLocation RParenLoc;
@@ -3582,11 +3674,15 @@ class StaticAssertDecl : public Decl {
StaticAssertDecl(DeclContext *DC, SourceLocation StaticAssertLoc,
Expr *AssertExpr, StringLiteral *Message,
SourceLocation RParenLoc, bool Failed)
- : Decl(StaticAssert, DC, StaticAssertLoc),
- AssertExprAndFailed(AssertExpr, Failed), Message(Message),
- RParenLoc(RParenLoc) { }
+ : Decl(StaticAssert, DC, StaticAssertLoc),
+ AssertExprAndFailed(AssertExpr, Failed), Message(Message),
+ RParenLoc(RParenLoc) {}
+
+ virtual void anchor();
public:
+ friend class ASTDeclReader;
+
static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation StaticAssertLoc,
Expr *AssertExpr, StringLiteral *Message,
@@ -3609,8 +3705,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == StaticAssert; }
-
- friend class ASTDeclReader;
};
/// A binding in a decomposition declaration. For instance, given:
@@ -3622,18 +3716,20 @@ public:
/// x[0], x[1], and x[2] respectively, where x is the implicit
/// DecompositionDecl of type 'int (&)[3]'.
class BindingDecl : public ValueDecl {
- void anchor() override;
-
/// The binding represented by this declaration. References to this
/// declaration are effectively equivalent to this expression (except
/// that it is only evaluated once at the point of declaration of the
/// binding).
- Expr *Binding;
+ Expr *Binding = nullptr;
BindingDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
- : ValueDecl(Decl::Binding, DC, IdLoc, Id, QualType()), Binding(nullptr) {}
+ : ValueDecl(Decl::Binding, DC, IdLoc, Id, QualType()) {}
+
+ void anchor() override;
public:
+ friend class ASTDeclReader;
+
static BindingDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation IdLoc, IdentifierInfo *Id);
static BindingDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -3657,8 +3753,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Decl::Binding; }
-
- friend class ASTDeclReader;
};
/// A decomposition declaration. For instance, given:
@@ -3672,8 +3766,6 @@ public:
class DecompositionDecl final
: public VarDecl,
private llvm::TrailingObjects<DecompositionDecl, BindingDecl *> {
- void anchor() override;
-
/// The number of BindingDecl*s following this object.
unsigned NumBindings;
@@ -3688,7 +3780,12 @@ class DecompositionDecl final
getTrailingObjects<BindingDecl *>());
}
+ void anchor() override;
+
public:
+ friend class ASTDeclReader;
+ friend TrailingObjects;
+
static DecompositionDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation StartLoc,
SourceLocation LSquareLoc,
@@ -3706,9 +3803,6 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Decomposition; }
-
- friend TrailingObjects;
- friend class ASTDeclReader;
};
/// An instance of this class represents the declaration of a property
@@ -3748,6 +3842,8 @@ class MSPropertyDecl : public DeclaratorDecl {
GetterId(Getter), SetterId(Setter) {}
public:
+ friend class ASTDeclReader;
+
static MSPropertyDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, DeclarationName N, QualType T,
TypeSourceInfo *TInfo, SourceLocation StartL,
@@ -3760,8 +3856,6 @@ public:
IdentifierInfo* getGetterId() const { return GetterId; }
bool hasSetter() const { return SetterId != nullptr; }
IdentifierInfo* getSetterId() const { return SetterId; }
-
- friend class ASTDeclReader;
};
/// Insertion operator for diagnostics. This allows sending an AccessSpecifier
@@ -3772,6 +3866,6 @@ const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const PartialDiagnostic &operator<<(const PartialDiagnostic &DB,
AccessSpecifier AS);
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_AST_DECLCXX_H