diff options
Diffstat (limited to 'include/clang/AST')
51 files changed, 661 insertions, 563 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index c6f8e2973e8e7..a9ab687a8de9e 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -226,6 +226,12 @@ class ASTContext : public RefCountedBase<ASTContext> { using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>; mutable TypeInfoMap MemoizedTypeInfo; + /// A cache from types to unadjusted alignment information. Only ARM and + /// AArch64 targets need this information, keeping it separate prevents + /// imposing overhead on TypeInfo size. + using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>; + mutable UnadjustedAlignMap MemoizedUnadjustedAlign; + /// A cache mapping from CXXRecordDecls to key functions. llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions; @@ -1522,7 +1528,7 @@ public: /// The sizeof operator requires this (C99 6.5.3.4p4). CanQualType getSizeType() const; - /// Return the unique signed counterpart of + /// Return the unique signed counterpart of /// the integer type corresponding to size_t. CanQualType getSignedSizeType() const; @@ -2067,6 +2073,16 @@ public: unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; } unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; } + /// Return the ABI-specified natural alignment of a (complete) type \p T, + /// before alignment adjustments, in bits. + /// + /// This alignment is curently used only by ARM and AArch64 when passing + /// arguments of a composite type. + unsigned getTypeUnadjustedAlign(QualType T) const { + return getTypeUnadjustedAlign(T.getTypePtr()); + } + unsigned getTypeUnadjustedAlign(const Type *T) const; + /// Return the ABI-specified alignment of a type, in bits, or 0 if /// the type is incomplete and we cannot determine the alignment (for /// example, from alignment attributes). @@ -2077,6 +2093,12 @@ public: CharUnits getTypeAlignInChars(QualType T) const; CharUnits getTypeAlignInChars(const Type *T) const; + /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, + /// in characters, before alignment adjustments. This method does not work on + /// incomplete types. + CharUnits getTypeUnadjustedAlignInChars(QualType T) const; + CharUnits getTypeUnadjustedAlignInChars(const Type *T) const; + // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the // type is a record, its data size is returned. std::pair<CharUnits, CharUnits> getTypeInfoDataSizeInChars(QualType T) const; diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h index b08865dde3c10..2534272da3a30 100644 --- a/include/clang/AST/ASTDiagnostic.h +++ b/include/clang/AST/ASTDiagnostic.h @@ -23,11 +23,11 @@ namespace clang { NUM_BUILTIN_AST_DIAGNOSTICS }; } // end namespace diag - + /// DiagnosticsEngine argument formatting function for diagnostics that /// involve AST nodes. /// - /// This function formats diagnostic arguments for various AST nodes, + /// This function formats diagnostic arguments for various AST nodes, /// including types, declaration names, nested name specifiers, and /// declaration contexts, into strings that can be printed as part of /// diagnostics. It is meant to be used as the argument to diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index 6e6a1926254bc..2e9a8775a8a23 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -63,7 +63,7 @@ class Attr; private: /// The contexts we're importing to and from. ASTContext &ToContext, &FromContext; - + /// The file managers we're importing to and from. FileManager &ToFileManager, &FromFileManager; @@ -72,11 +72,11 @@ class Attr; /// Whether the last diagnostic came from the "from" context. bool LastDiagFromFrom = false; - + /// Mapping from the already-imported types in the "from" context /// to the corresponding types in the "to" context. llvm::DenseMap<const Type *, const Type *> ImportedTypes; - + /// Mapping from the already-imported declarations in the "from" /// context to the corresponding declarations in the "to" context. llvm::DenseMap<Decl *, Decl *> ImportedDecls; @@ -93,11 +93,11 @@ class Attr; /// the "from" source manager to the corresponding CXXBasesSpecifier /// in the "to" source manager. ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers; - + /// Declaration (from, to) pairs that are known not to be equivalent /// (which we have already complained about). NonEquivalentDeclSet NonEquivalentDecls; - + public: /// Create a new AST importer. /// @@ -115,13 +115,13 @@ class Attr; ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport); - + virtual ~ASTImporter(); - + /// Whether the importer will perform a minimal import, creating /// to-be-completed forward declarations when possible. bool isMinimalImport() const { return Minimal; } - + /// Import the given type from the "from" context into the "to" /// context. /// @@ -142,10 +142,10 @@ class Attr; /// \returns the equivalent attribute in the "to" context. Attr *Import(const Attr *FromAttr); - /// Import the given declaration from the "from" context into the + /// Import the given declaration from the "from" context into the /// "to" context. /// - /// \returns the equivalent declaration in the "to" context, or a NULL type + /// \returns the equivalent declaration in the "to" context, or a NULL type /// if an error occurred. Decl *Import(Decl *FromD); Decl *Import(const Decl *FromD) { @@ -163,7 +163,7 @@ class Attr; /// \returns the equivalent declaration context in the "to" /// context, or a NULL type if an error occurred. DeclContext *ImportContext(DeclContext *FromDC); - + /// Import the given expression from the "from" context into the /// "to" context. /// @@ -195,7 +195,7 @@ class Attr; /// Import the goven template name from the "from" context into the /// "to" context. TemplateName Import(TemplateName From); - + /// Import the given source location from the "from" context into /// the "to" context. /// @@ -229,7 +229,7 @@ class Attr; /// \returns the equivalent selector in the "to" context. Selector Import(Selector FromSel); - /// Import the given file ID from the "from" context into the + /// Import the given file ID from the "from" context into the /// "to" context. /// /// \returns the equivalent file ID in the source manager of the "to" @@ -252,13 +252,13 @@ class Attr; /// Import the definition of the given declaration, including all of /// the declarations it contains. /// - /// This routine is intended to be used + /// This routine is intended to be used void ImportDefinition(Decl *From); /// Cope with a name conflict when importing a declaration into the /// given context. /// - /// This routine is invoked whenever there is a name conflict while + /// This routine is invoked whenever there is a name conflict while /// importing a declaration. The returned name will become the name of the /// imported declaration. By default, the returned name is the same as the /// original name, leaving the conflict unresolve such that name lookup @@ -270,7 +270,7 @@ class Attr; /// \param Name the name of the declaration being imported, which conflicts /// with other declarations. /// - /// \param DC the declaration context (in the "to" AST context) in which + /// \param DC the declaration context (in the "to" AST context) in which /// the name is being imported. /// /// \param IDNS the identifier namespace in which the name will be found. @@ -286,25 +286,25 @@ class Attr; unsigned IDNS, NamedDecl **Decls, unsigned NumDecls); - + /// Retrieve the context that AST nodes are being imported into. ASTContext &getToContext() const { return ToContext; } - + /// Retrieve the context that AST nodes are being imported from. ASTContext &getFromContext() const { return FromContext; } - + /// Retrieve the file manager that AST nodes are being imported into. FileManager &getToFileManager() const { return ToFileManager; } /// Retrieve the file manager that AST nodes are being imported from. FileManager &getFromFileManager() const { return FromFileManager; } - + /// Report a diagnostic in the "to" context. DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID); - + /// Report a diagnostic in the "from" context. DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID); - + /// Return the set of declarations that we know are not equivalent. NonEquivalentDeclSet &getNonEquivalentDecls() { return NonEquivalentDecls; } @@ -313,7 +313,7 @@ class Attr; /// /// \param D A declaration in the "to" context. virtual void CompleteDecl(Decl* D); - + /// Subclasses can override this function to observe all of the \c From -> /// \c To declaration mappings as they are imported. virtual Decl *Imported(Decl *From, Decl *To) { return To; } @@ -328,7 +328,7 @@ class Attr; /// RecordDecl can be found, we can complete it without the need for /// importation, eliminating this loop. virtual Decl *GetOriginalDecl(Decl *To) { return nullptr; } - + /// Determine whether the given types are structurally /// equivalent. bool IsStructurallyEquivalent(QualType From, QualType To, diff --git a/include/clang/AST/ASTLambda.h b/include/clang/AST/ASTLambda.h index 2fe4e2563b36f..6fedcb8d38011 100644 --- a/include/clang/AST/ASTLambda.h +++ b/include/clang/AST/ASTLambda.h @@ -40,7 +40,7 @@ inline bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD) { if (!MD) return false; const CXXRecordDecl *LambdaClass = MD->getParent(); if (LambdaClass && LambdaClass->isGenericLambda()) - return isLambdaCallOperator(MD) && + return isLambdaCallOperator(MD) && MD->isFunctionTemplateSpecialization(); return false; } @@ -51,11 +51,11 @@ inline bool isLambdaConversionOperator(CXXConversionDecl *C) { inline bool isLambdaConversionOperator(Decl *D) { if (!D) return false; - if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) - return isLambdaConversionOperator(Conv); - if (FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(D)) - if (CXXConversionDecl *Conv = - dyn_cast_or_null<CXXConversionDecl>(F->getTemplatedDecl())) + if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) + return isLambdaConversionOperator(Conv); + if (FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(D)) + if (CXXConversionDecl *Conv = + dyn_cast_or_null<CXXConversionDecl>(F->getTemplatedDecl())) return isLambdaConversionOperator(Conv); return false; } @@ -71,7 +71,7 @@ inline bool isGenericLambdaCallOperatorSpecialization(DeclContext *DC) { inline DeclContext *getLambdaAwareParentOfDeclContext(DeclContext *DC) { if (isLambdaCallOperator(DC)) return DC->getParent()->getParent(); - else + else return DC->getParent(); } diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h index 31ae2b111e013..80184e1cc7402 100644 --- a/include/clang/AST/ASTMutationListener.h +++ b/include/clang/AST/ASTMutationListener.h @@ -134,13 +134,13 @@ public: /// \param M The containing module in which the definition was made visible, /// if any. virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {} - + /// An attribute was added to a RecordDecl /// /// \param Attr The attribute that was added to the Record /// /// \param Record The RecordDecl that got a new attribute - virtual void AddedAttributeToRecord(const Attr *Attr, + virtual void AddedAttributeToRecord(const Attr *Attr, const RecordDecl *Record) {} // NOTE: If new methods are added they should also be added to diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 32a61c59d2368..20922742f687b 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -86,7 +86,7 @@ public: attr::Kind getKind() const { return static_cast<attr::Kind>(AttrKind); } - + unsigned getSpellingListIndex() const { return SpellingListIndex; } const char *getSpelling() const; diff --git a/include/clang/AST/AttrIterator.h b/include/clang/AST/AttrIterator.h index 56807b4590d37..2087ecc0e70c7 100644 --- a/include/clang/AST/AttrIterator.h +++ b/include/clang/AST/AttrIterator.h @@ -106,7 +106,7 @@ public: specific_attr_iterator Right) { assert((Left.Current == nullptr) == (Right.Current == nullptr)); if (Left.Current < Right.Current) - Left.AdvanceToNext(Right.Current); + Left.AdvanceToNext(Right.Current); else Right.AdvanceToNext(Left.Current); return Left.Current == Right.Current; diff --git a/include/clang/AST/BaseSubobject.h b/include/clang/AST/BaseSubobject.h index fdb7e718fe9e4..2b702c76b2fab 100644 --- a/include/clang/AST/BaseSubobject.h +++ b/include/clang/AST/BaseSubobject.h @@ -24,21 +24,21 @@ namespace clang { class CXXRecordDecl; -// BaseSubobject - Uniquely identifies a direct or indirect base class. +// BaseSubobject - Uniquely identifies a direct or indirect base class. // Stores both the base class decl and the offset from the most derived class to // the base class. Used for vtable and VTT generation. class BaseSubobject { /// Base - The base class declaration. const CXXRecordDecl *Base; - + /// BaseOffset - The offset from the most derived class to the base class. CharUnits BaseOffset; - + public: BaseSubobject() = default; BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset) : Base(Base), BaseOffset(BaseOffset) {} - + /// getBase - Returns the base class declaration. const CXXRecordDecl *getBase() const { return Base; } @@ -74,7 +74,7 @@ template<> struct DenseMapInfo<clang::BaseSubobject> { Base.getBaseOffset())); } - static bool isEqual(const clang::BaseSubobject &LHS, + static bool isEqual(const clang::BaseSubobject &LHS, const clang::BaseSubobject &RHS) { return LHS == RHS; } diff --git a/include/clang/AST/CXXInheritance.h b/include/clang/AST/CXXInheritance.h index 2ae1d8b25823b..f5e23f8e8505d 100644 --- a/include/clang/AST/CXXInheritance.h +++ b/include/clang/AST/CXXInheritance.h @@ -34,10 +34,10 @@ namespace clang { class ASTContext; class NamedDecl; - + /// Represents an element in a path from a derived class to a -/// base class. -/// +/// base class. +/// /// Each step in the path references the link from a /// derived class to one of its direct base classes, along with a /// base "number" that identifies which base subobject of the @@ -47,12 +47,12 @@ struct CXXBasePathElement { /// class to a base class, which will be followed by this base /// path element. const CXXBaseSpecifier *Base; - + /// The record decl of the class that the base is a base of. const CXXRecordDecl *Class; - + /// Identifies which base class subobject (of type - /// \c Base->getType()) this base path element refers to. + /// \c Base->getType()) this base path element refers to. /// /// This value is only valid if \c !Base->isVirtual(), because there /// is no base numbering for the zero or one virtual bases of a @@ -64,7 +64,7 @@ struct CXXBasePathElement { /// (which is not represented as part of the path) to a particular /// (direct or indirect) base class subobject. /// -/// Individual elements in the path are described by the \c CXXBasePathElement +/// Individual elements in the path are described by the \c CXXBasePathElement /// structure, which captures both the link from a derived class to one of its /// direct bases and identification describing which base class /// subobject is being used. @@ -121,7 +121,7 @@ class CXXBasePaths { /// The type from which this search originated. CXXRecordDecl *Origin = nullptr; - + /// Paths - The actual set of paths that can be taken from the /// derived class to the same base class. std::list<CXXBasePath> Paths; @@ -160,12 +160,12 @@ class CXXBasePaths { /// ambiguous paths while it is looking for a path from a derived /// type to a base type. bool FindAmbiguities; - + /// RecordPaths - Whether Sema::IsDerivedFrom should record paths /// while it is determining whether there are paths from a derived /// type to a base type. bool RecordPaths; - + /// DetectVirtual - Whether Sema::IsDerivedFrom should abort the search /// if it finds a path that goes across a virtual base. The virtual class /// is also recorded. @@ -181,7 +181,7 @@ public: using paths_iterator = std::list<CXXBasePath>::iterator; using const_paths_iterator = std::list<CXXBasePath>::const_iterator; using decl_iterator = NamedDecl **; - + /// BasePaths - Construct a new BasePaths structure to record the /// paths for a derived-to-base search. explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true, @@ -193,31 +193,31 @@ public: paths_iterator end() { return Paths.end(); } const_paths_iterator begin() const { return Paths.begin(); } const_paths_iterator end() const { return Paths.end(); } - + CXXBasePath& front() { return Paths.front(); } const CXXBasePath& front() const { return Paths.front(); } - + using decl_range = llvm::iterator_range<decl_iterator>; decl_range found_decls(); - + /// Determine whether the path from the most-derived type to the /// given base type is ambiguous (i.e., it refers to multiple subobjects of /// the same base type). bool isAmbiguous(CanQualType BaseType); - + /// Whether we are finding multiple paths to detect ambiguities. bool isFindingAmbiguities() const { return FindAmbiguities; } - + /// Whether we are recording paths. bool isRecordingPaths() const { return RecordPaths; } - + /// Specify whether we should be recording paths or not. void setRecordingPaths(bool RP) { RecordPaths = RP; } - + /// Whether we are detecting virtual bases. bool isDetectingVirtual() const { return DetectVirtual; } - + /// The virtual base discovered on the path (if we are merely /// detecting virtuals). const RecordType* getDetectedVirtual() const { @@ -228,11 +228,11 @@ public: /// began CXXRecordDecl *getOrigin() const { return Origin; } void setOrigin(CXXRecordDecl *Rec) { Origin = Rec; } - + /// Clear the base-paths results. void clear(); - - /// Swap this data structure's contents with another CXXBasePaths + + /// Swap this data structure's contents with another CXXBasePaths /// object. void swap(CXXBasePaths &Other); }; diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h index 63a0af66eec37..0e738da43ad41 100644 --- a/include/clang/AST/CanonicalType.h +++ b/include/clang/AST/CanonicalType.h @@ -85,8 +85,8 @@ public: /// Retrieve the underlying type pointer, which refers to a /// canonical type, or nullptr. - const T *getTypePtrOrNull() const { - return cast_or_null<T>(Stored.getTypePtrOrNull()); + const T *getTypePtrOrNull() const { + return cast_or_null<T>(Stored.getTypePtrOrNull()); } /// Implicit conversion to a qualified type. @@ -94,7 +94,7 @@ public: /// Implicit conversion to bool. explicit operator bool() const { return !isNull(); } - + bool isNull() const { return Stored.isNull(); } diff --git a/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h index ddead6046a147..0aadf06fffc98 100644 --- a/include/clang/AST/CharUnits.h +++ b/include/clang/AST/CharUnits.h @@ -61,7 +61,7 @@ namespace clang { /// fromQuantity - Construct a CharUnits quantity from a raw integer type. static CharUnits fromQuantity(QuantityType Quantity) { - return CharUnits(Quantity); + return CharUnits(Quantity); } // Compound assignment. @@ -87,7 +87,7 @@ namespace clang { CharUnits operator-- (int) { return CharUnits(Quantity--); } - + // Comparison operators. bool operator== (const CharUnits &Other) const { return Quantity == Other.Quantity; @@ -97,21 +97,21 @@ namespace clang { } // Relational operators. - bool operator< (const CharUnits &Other) const { - return Quantity < Other.Quantity; + bool operator< (const CharUnits &Other) const { + return Quantity < Other.Quantity; } - bool operator<= (const CharUnits &Other) const { + bool operator<= (const CharUnits &Other) const { return Quantity <= Other.Quantity; } - bool operator> (const CharUnits &Other) const { - return Quantity > Other.Quantity; + bool operator> (const CharUnits &Other) const { + return Quantity > Other.Quantity; } - bool operator>= (const CharUnits &Other) const { - return Quantity >= Other.Quantity; + bool operator>= (const CharUnits &Other) const { + return Quantity >= Other.Quantity; } // Other predicates. - + /// isZero - Test whether the quantity equals zero. bool isZero() const { return Quantity == 0; } @@ -172,7 +172,7 @@ namespace clang { return CharUnits(-Quantity); } - + // Conversions. /// getQuantity - Get the raw integer representation of this quantity. @@ -205,7 +205,7 @@ namespace clang { }; // class CharUnit } // namespace clang -inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale, +inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU) { return CU * Scale; } @@ -223,8 +223,8 @@ template<> struct DenseMapInfo<clang::CharUnits> { static clang::CharUnits getTombstoneKey() { clang::CharUnits::QuantityType Quantity = DenseMapInfo<clang::CharUnits::QuantityType>::getTombstoneKey(); - - return clang::CharUnits::fromQuantity(Quantity); + + return clang::CharUnits::fromQuantity(Quantity); } static unsigned getHashValue(const clang::CharUnits &CU) { @@ -232,7 +232,7 @@ template<> struct DenseMapInfo<clang::CharUnits> { return DenseMapInfo<clang::CharUnits::QuantityType>::getHashValue(Quantity); } - static bool isEqual(const clang::CharUnits &LHS, + static bool isEqual(const clang::CharUnits &LHS, const clang::CharUnits &RHS) { return LHS == RHS; } @@ -241,7 +241,7 @@ template<> struct DenseMapInfo<clang::CharUnits> { template <> struct isPodLike<clang::CharUnits> { static const bool value = true; }; - + } // end namespace llvm #endif // LLVM_CLANG_AST_CHARUNITS_H diff --git a/include/clang/AST/Comment.h b/include/clang/AST/Comment.h index e3a427d8aa0d8..f5538dec2a142 100644 --- a/include/clang/AST/Comment.h +++ b/include/clang/AST/Comment.h @@ -98,7 +98,7 @@ protected: unsigned RenderKind : 2; unsigned CommandID : CommandInfo::NumCommandIDBits; }; - enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 + + enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 + CommandInfo::NumCommandIDBits }; class HTMLTagCommentBitfields { @@ -146,7 +146,7 @@ protected: /// Contains values from CommandMarkerKind enum. unsigned CommandMarker : 1; }; - enum { NumBlockCommandCommentBits = NumCommentBits + + enum { NumBlockCommandCommentBits = NumCommentBits + CommandInfo::NumCommandIDBits + 1 }; class ParamCommandCommentBitfields { @@ -987,7 +987,7 @@ struct DeclInfo { /// Declaration the comment is actually attached to (in the source). /// Should not be NULL. const Decl *CommentDecl; - + /// CurrentDecl is the declaration with which the FullComment is associated. /// /// It can be different from \c CommentDecl. It happens when we decide @@ -997,7 +997,7 @@ struct DeclInfo { /// /// The information in the DeclInfo corresponds to CurrentDecl. const Decl *CurrentDecl; - + /// Parameters that can be referenced by \\param if \c CommentDecl is something /// that we consider a "function". ArrayRef<const ParmVarDecl *> ParamVars; @@ -1119,21 +1119,21 @@ public: } child_iterator child_end() const { - return reinterpret_cast<child_iterator>(Blocks.end()); + return reinterpret_cast<child_iterator>(Blocks.end()); } const Decl *getDecl() const LLVM_READONLY { return ThisDeclInfo->CommentDecl; } - + const DeclInfo *getDeclInfo() const LLVM_READONLY { if (!ThisDeclInfo->IsFilled) ThisDeclInfo->fill(); return ThisDeclInfo; } - + ArrayRef<BlockContentComment *> getBlocks() const { return Blocks; } - + }; } // end namespace comments } // end namespace clang diff --git a/include/clang/AST/CommentCommandTraits.h b/include/clang/AST/CommentCommandTraits.h index bac4e99dc7a4c..4fd007872c013 100644 --- a/include/clang/AST/CommentCommandTraits.h +++ b/include/clang/AST/CommentCommandTraits.h @@ -107,17 +107,17 @@ struct CommandInfo { /// \fn void f(int a); /// \endcode unsigned IsDeclarationCommand : 1; - + /// True if verbatim-like line command is a function declaration. unsigned IsFunctionDeclarationCommand : 1; /// True if block command is further describing a container API; such /// as \@coclass, \@classdesign, etc. unsigned IsRecordLikeDetailCommand : 1; - + /// True if block command is a container API; such as \@interface. unsigned IsRecordLikeDeclarationCommand : 1; - + /// True if this command is unknown. This \c CommandInfo object was /// created during parsing. unsigned IsUnknownCommand : 1; @@ -150,7 +150,7 @@ public: } const CommandInfo *getTypoCorrectCommandInfo(StringRef Typo) const; - + const CommandInfo *getCommandInfo(unsigned CommandID) const; const CommandInfo *registerUnknownCommand(StringRef CommandName); diff --git a/include/clang/AST/CommentLexer.h b/include/clang/AST/CommentLexer.h index 52c4eb9e309a1..3ef5b7c8c998c 100644 --- a/include/clang/AST/CommentLexer.h +++ b/include/clang/AST/CommentLexer.h @@ -76,7 +76,7 @@ class Token { /// unused (command spelling can be found with CommandTraits). Otherwise, /// contains the length of the string that starts at TextPtr. unsigned IntVal; - + public: SourceLocation getLocation() const LLVM_READONLY { return Loc; } void setLocation(SourceLocation SL) { Loc = SL; } @@ -228,7 +228,7 @@ private: llvm::BumpPtrAllocator &Allocator; DiagnosticsEngine &Diags; - + const CommandTraits &Traits; const char *const BufferStart; diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h index 0e94c33970caf..632eba782b924 100644 --- a/include/clang/AST/CommentSema.h +++ b/include/clang/AST/CommentSema.h @@ -191,11 +191,11 @@ public: void checkBlockCommandDuplicate(const BlockCommandComment *Command); void checkDeprecatedCommand(const BlockCommandComment *Comment); - + void checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment); - + void checkContainerDeclVerbatimLine(const BlockCommandComment *Comment); - + void checkContainerDecl(const BlockCommandComment *Comment); /// Resolve parameter names to parameter indexes in function declaration. diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index dde94599636f0..ebdb2890daf5d 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -98,7 +98,7 @@ public: /// Return the TypeLoc wrapper for the type source info. TypeLoc getTypeLoc() const; // implemented in TypeLoc.h - + /// Override the type stored in this TypeSourceInfo. Use with caution! void overrideType(QualType T) { Ty = T; } }; @@ -488,7 +488,7 @@ public: SourceLocation IdentL, IdentifierInfo *II, SourceLocation GnuLabelL); static LabelDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + LabelStmt *getStmt() const { return TheStmt; } void setStmt(LabelStmt *T) { TheStmt = T; } @@ -511,8 +511,8 @@ public: }; /// Represent a C++ namespace. -class NamespaceDecl : public NamedDecl, public DeclContext, - public Redeclarable<NamespaceDecl> +class NamespaceDecl : public NamedDecl, public DeclContext, + public Redeclarable<NamespaceDecl> { /// The starting location of the source range, pointing /// to either the namespace or the inline keyword. @@ -523,7 +523,7 @@ class NamespaceDecl : public NamedDecl, public DeclContext, /// A pointer to either the anonymous namespace that lives just inside /// this namespace or to the first namespace in the chain (the latter case - /// only when this is not the first in the chain), along with a + /// only when this is not the first in the chain), along with a /// boolean value indicating whether this is an inline namespace. llvm::PointerIntPair<NamespaceDecl *, 1, bool> AnonOrFirstNamespaceAndInline; @@ -1931,7 +1931,7 @@ public: bool isConstexprSpecified = false); static FunctionDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + DeclarationNameInfo getNameInfo() const { return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } @@ -2598,7 +2598,7 @@ public: InClassInitStyle InitStyle); static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// Returns the index of this field within its record, /// as appropriate for passing to ASTRecordLayout::getFieldOffset. unsigned getFieldIndex() const; @@ -2754,7 +2754,7 @@ public: QualType T, Expr *E, const llvm::APSInt &V); static EnumConstantDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + const Expr *getInitExpr() const { return (const Expr*) Init; } Expr *getInitExpr() { return (Expr*) Init; } const llvm::APSInt &getInitVal() const { return Val; } @@ -3812,7 +3812,7 @@ public: /// Finds the first data member which has a name. /// nullptr is returned if no named data member exists. - const FieldDecl *findFirstNamedDataMember() const; + const FieldDecl *findFirstNamedDataMember() const; private: /// Deserialize just the fields. @@ -3835,7 +3835,7 @@ public: SourceLocation RParenLoc); static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + SourceLocation getAsmLoc() const { return getLocation(); } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } @@ -3927,9 +3927,9 @@ protected: IsConversionFromLambda(false), DoesNotEscape(false) {} public: - static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); + static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); static BlockDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + SourceLocation getCaretLocation() const { return getLocation(); } bool isVariadic() const { return IsVariadic; } @@ -4009,7 +4009,7 @@ public: } Decl *getBlockManglingContextDecl() const { - return ManglingContextDecl; + return ManglingContextDecl; } void setBlockMangling(unsigned Number, Decl *Ctx) { @@ -4145,16 +4145,16 @@ class ImportDecl final : public Decl, /// The imported module, along with a bit that indicates whether /// we have source-location information for each identifier in the module - /// name. + /// name. /// /// When the bit is false, we only have a single source location for the /// end of the import declaration. llvm::PointerIntPair<Module *, 1, bool> ImportedAndComplete; - + /// The next import in the list of imports local to the translation /// unit being parsed (not loaded from an AST file). ImportDecl *NextLocalImport = nullptr; - + ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef<SourceLocation> IdentifierLocs); @@ -4162,26 +4162,26 @@ class ImportDecl final : public Decl, SourceLocation EndLoc); ImportDecl(EmptyShell Empty) : Decl(Import, Empty) {} - + public: /// Create a new module import declaration. - static ImportDecl *Create(ASTContext &C, DeclContext *DC, + static ImportDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef<SourceLocation> IdentifierLocs); - + /// Create a new module import declaration for an implicitly-generated /// import. - static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC, - SourceLocation StartLoc, Module *Imported, + static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC, + SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc); - + /// Create a new, deserialized module import declaration. - static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, + static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations); - + /// Retrieve the module that was imported by the import declaration. Module *getImportedModule() const { return ImportedAndComplete.getPointer(); } - + /// Retrieves the locations of each of the identifiers that make up /// the complete module name in the import declaration. /// @@ -4218,7 +4218,7 @@ public: static ExportDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc); static ExportDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + SourceLocation getExportLoc() const { return getLocation(); } SourceLocation getRBraceLoc() const { return RBraceLoc; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index f99bd627877c5..d6b89d971d940 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -302,7 +302,7 @@ private: /// global variable, etc.) that is lexically inside an objc container /// definition. unsigned TopLevelDeclInObjCContainer : 1; - + /// Whether statistic collection is enabled. static bool StatisticsEnabled; @@ -629,7 +629,7 @@ protected: assert(isFromASTFile() && "Only works on a deserialized declaration"); *((unsigned*)this - 2) = ID; } - + public: /// Determine the availability of the given declaration. /// @@ -879,7 +879,7 @@ public: /// Whether this particular Decl is a canonical one. bool isCanonicalDecl() const { return getCanonicalDecl() == this; } - + protected: /// Returns the next redeclaration or itself if this is the only decl. /// @@ -956,10 +956,10 @@ public: /// Retrieve the previous declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. Decl *getPreviousDecl() { return getPreviousDeclImpl(); } - + /// Retrieve the most recent declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. - const Decl *getPreviousDecl() const { + const Decl *getPreviousDecl() const { return const_cast<Decl *>(this)->getPreviousDeclImpl(); } @@ -974,7 +974,7 @@ public: /// Retrieve the most recent declaration that declares the same entity /// as this declaration (which may be this declaration). - const Decl *getMostRecentDecl() const { + const Decl *getMostRecentDecl() const { return const_cast<Decl *>(this)->getMostRecentDeclImpl(); } @@ -1159,13 +1159,13 @@ protected: inline bool declaresSameEntity(const Decl *D1, const Decl *D2) { if (!D1 || !D2) return false; - + if (D1 == D2) return true; - + return D1->getCanonicalDecl() == D2->getCanonicalDecl(); } - + /// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when /// doing something to a specific decl. class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry { @@ -1517,7 +1517,7 @@ public: /// connected to this declaration context. /// /// For declaration contexts that have multiple semantically connected but - /// syntactically distinct contexts, such as C++ namespaces, this routine + /// syntactically distinct contexts, such as C++ namespaces, this routine /// retrieves the complete set of such declaration contexts in source order. /// For example, given: /// @@ -1921,7 +1921,7 @@ public: /// Determine whether the given declaration is stored in the list of /// declarations lexically within this context. bool isDeclInLexicalTraversal(const Decl *D) const { - return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl || + return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl || D == LastDecl); } diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 1d0489912c6bd..4353f66a34e43 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -264,7 +264,7 @@ public: return EllipsisLoc; } - /// Returns the access specifier for this base specifier. + /// Returns the access specifier for this base specifier. /// /// This is the actual base specifier as used for semantic analysis, so /// the result can never be AS_none. To retrieve the access specifier as @@ -564,7 +564,7 @@ class CXXRecordDecl : public RecordDecl { CXXRecordDecl *Definition; /// The first friend declaration in this class, or null if there - /// aren't any. + /// aren't any. /// /// This is actually currently stored in reverse order. LazyDeclPtr FirstFriend; @@ -606,14 +606,14 @@ class CXXRecordDecl : public RecordDecl { /// Whether this lambda is known to be dependent, even if its /// context isn't dependent. - /// + /// /// A lambda with a non-dependent context can be dependent if it occurs /// within the default argument of a function template, because the /// lambda will have been created with the enclosing context as its /// declaration context, rather than function. This is an unfortunate - /// artifact of having to parse the default arguments before. + /// artifact of having to parse the default arguments before. unsigned Dependent : 1; - + /// Whether this lambda is a generic lambda. unsigned IsGenericLambda : 1; @@ -626,28 +626,28 @@ class CXXRecordDecl : public RecordDecl { /// The number of explicit captures in this lambda. unsigned NumExplicitCaptures : 13; - /// The number used to indicate this lambda expression for name + /// The number used to indicate this lambda expression for name /// mangling in the Itanium C++ ABI. unsigned ManglingNumber = 0; - + /// The declaration that provides context for this lambda, if the /// actual DeclContext does not suffice. This is used for lambdas that /// occur within default arguments of function parameters within the class /// or within a data member initializer. LazyDeclPtr ContextDecl; - - /// The list of captures, both explicit and implicit, for this + + /// The list of captures, both explicit and implicit, for this /// lambda. Capture *Captures = nullptr; /// 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), + 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; @@ -1205,22 +1205,22 @@ public: return DD && DD->IsLambda; } - /// Determine whether this class describes a generic + /// Determine whether this class describes a generic /// lambda function object (i.e. function call operator is - /// a template). - bool isGenericLambda() const; + /// a template). + bool isGenericLambda() const; /// Retrieve the lambda call operator of the closure type /// if this is a closure type. - CXXMethodDecl *getLambdaCallOperator() const; + CXXMethodDecl *getLambdaCallOperator() const; /// Retrieve the lambda static invoker, the address of which /// is returned by the conversion operator, and the body of which - /// is forwarded to the lambda call operator. - CXXMethodDecl *getLambdaStaticInvoker() const; + /// is forwarded to the lambda call operator. + CXXMethodDecl *getLambdaStaticInvoker() const; /// Retrieve the generic lambda's template parameter list. - /// Returns null if the class does not represent a lambda or a generic + /// Returns null if the class does not represent a lambda or a generic /// lambda. TemplateParameterList *getGenericLambdaTemplateParameterList() const; @@ -1345,11 +1345,11 @@ public: /// not overridden. bool isAbstract() const { return data().Abstract; } - /// Determine whether this class is standard-layout per + /// Determine whether this class is standard-layout per /// C++ [class]p7. bool isStandardLayout() const { return data().IsStandardLayout; } - /// Determine whether this class was standard-layout per + /// Determine whether this class was standard-layout per /// C++11 [class]p7, specifically using the C++11 rules without any DRs. bool isCXX11StandardLayout() const { return data().IsCXX11StandardLayout; } @@ -1900,25 +1900,25 @@ public: /// If this is the closure type of a lambda expression, retrieve the /// number to be used for name mangling in the Itanium C++ ABI. /// - /// Zero indicates that this closure type has internal linkage, so the + /// Zero indicates that this closure type has internal linkage, so the /// mangling number does not matter, while a non-zero value indicates which /// lambda expression this is in this particular context. unsigned getLambdaManglingNumber() const { assert(isLambda() && "Not a lambda closure type!"); return getLambdaData().ManglingNumber; } - - /// Retrieve the declaration that provides additional context for a + + /// Retrieve the declaration that provides additional context for a /// lambda, when the normal declaration context is not specific enough. /// - /// Certain contexts (default arguments of in-class function parameters and + /// Certain contexts (default arguments of in-class function parameters and /// the initializers of data members) have separate name mangling rules for /// lambdas within the Itanium C++ ABI. For these cases, this routine provides - /// the declaration in which the lambda occurs, e.g., the function parameter + /// the declaration in which the lambda occurs, e.g., the function parameter /// or the non-static data member. Otherwise, it returns NULL to imply that /// the declaration context suffices. Decl *getLambdaContextDecl() const; - + /// Set the mangling number and context declaration for a lambda /// class. void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl) { @@ -2799,7 +2799,7 @@ public: /// Determine whether this conversion function is a conversion from /// a lambda closure type to a block pointer. bool isLambdaToBlockPointerConversion() const; - + CXXConversionDecl *getCanonicalDecl() override { return cast<CXXConversionDecl>(FunctionDecl::getCanonicalDecl()); } @@ -2812,7 +2812,7 @@ public: static bool classofKind(Kind K) { return K == CXXConversion; } }; -/// Represents a linkage specification. +/// Represents a linkage specification. /// /// For example: /// \code @@ -2862,7 +2862,7 @@ public: SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces); static LinkageSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// Return the language specified by this linkage specification. LanguageIDs getLanguage() const { return LanguageIDs(Language); } @@ -3770,7 +3770,7 @@ public: Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed); static StaticAssertDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + Expr *getAssertExpr() { return AssertExprAndFailed.getPointer(); } const Expr *getAssertExpr() const { return AssertExprAndFailed.getPointer(); } diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index 47fb68bf42d3e..a8de8ed168403 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -254,7 +254,7 @@ inline void CXXRecordDecl::pushFriendDecl(FriendDecl *FD) { FD->NextFriend = data().FirstFriend; data().FirstFriend = FD; } - + } // namespace clang #endif // LLVM_CLANG_AST_DECLFRIEND_H diff --git a/include/clang/AST/DeclLookups.h b/include/clang/AST/DeclLookups.h index 64eb3f24b3701..9627f440d406c 100644 --- a/include/clang/AST/DeclLookups.h +++ b/include/clang/AST/DeclLookups.h @@ -54,7 +54,7 @@ public: ++It; } while (It != End && It->first == DeclarationName::getUsingDirectiveName()); - + return *this; } diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index c81a5f805fc03..c1cc726e31521 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -587,7 +587,7 @@ class ObjCTypeParamDecl : public TypedefNameDecl { /// explicitly specified. SourceLocation ColonLoc; - ObjCTypeParamDecl(ASTContext &ctx, DeclContext *dc, + ObjCTypeParamDecl(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, @@ -659,7 +659,7 @@ class ObjCTypeParamList final unsigned End; }; - union { + union { /// Location of the left and right angle brackets. PODSourceRange Brackets; @@ -1123,7 +1123,7 @@ public: ObjCPropertyDecl *>; using ProtocolPropertySet = llvm::SmallDenseSet<const ObjCProtocolDecl *, 8>; using PropertyDeclOrder = llvm::SmallVector<ObjCPropertyDecl *, 8>; - + /// This routine collects list of properties to be implemented in the class. /// This includes, class's and its conforming protocols' properties. /// Note, the superclass's properties are not included in the list. @@ -1195,15 +1195,15 @@ class ObjCInterfaceDecl : public ObjCContainerDecl /// TypeForDecl - This indicates the Type object that represents this /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType mutable const Type *TypeForDecl = nullptr; - + struct DefinitionData { - /// The definition of this class, for quick access from any + /// The definition of this class, for quick access from any /// declaration. ObjCInterfaceDecl *Definition = nullptr; - + /// When non-null, this is always an ObjCObjectType. TypeSourceInfo *SuperClassTInfo = nullptr; - + /// Protocols referenced in the \@interface declaration ObjCProtocolList ReferencedProtocols; @@ -1247,11 +1247,11 @@ class ObjCInterfaceDecl : public ObjCContainerDecl /// One of the \c InheritedDesignatedInitializersState enumeratos. mutable unsigned InheritedDesignatedInitializers : 2; - + /// The location of the last location in this declaration, before - /// the properties/methods. For example, this will be the '>', '}', or - /// identifier, - SourceLocation EndLoc; + /// the properties/methods. For example, this will be the '>', '}', or + /// identifier, + SourceLocation EndLoc; DefinitionData() : ExternallyCompleted(false), IvarListMissingImplementation(true), @@ -1285,7 +1285,7 @@ class ObjCInterfaceDecl : public ObjCContainerDecl /// Allocate the definition data for this class. void allocateDefinitionData(); - + using redeclarable_base = Redeclarable<ObjCInterfaceDecl>; ObjCInterfaceDecl *getNextRedeclarationImpl() override { @@ -1334,7 +1334,7 @@ public: SourceRange getSourceRange() const override LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); - + return SourceRange(getAtStartLoc(), getLocation()); } @@ -1390,7 +1390,7 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return protocol_iterator(); - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1453,7 +1453,7 @@ public: if (data().ExternallyCompleted) LoadExternalDefinition(); - return data().AllReferencedProtocols.empty() + return data().AllReferencedProtocols.empty() ? protocol_begin() : data().AllReferencedProtocols.begin(); } @@ -1462,11 +1462,11 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return all_protocol_iterator(); - + if (data().ExternallyCompleted) LoadExternalDefinition(); - return data().AllReferencedProtocols.empty() + return data().AllReferencedProtocols.empty() ? protocol_end() : data().AllReferencedProtocols.end(); } @@ -1476,17 +1476,17 @@ public: ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); } - ivar_iterator ivar_begin() const { + ivar_iterator ivar_begin() const { if (const ObjCInterfaceDecl *Def = getDefinition()) - return ivar_iterator(Def->decls_begin()); - + return ivar_iterator(Def->decls_begin()); + // FIXME: Should make sure no callers ever do this. return ivar_iterator(); } - ivar_iterator ivar_end() const { + ivar_iterator ivar_end() const { if (const ObjCInterfaceDecl *Def = getDefinition()) - return ivar_iterator(Def->decls_end()); + return ivar_iterator(Def->decls_end()); // FIXME: Should make sure no callers ever do this. return ivar_iterator(); @@ -1546,10 +1546,10 @@ public: /// Determine whether this particular declaration of this class is /// actually also a definition. - bool isThisDeclarationADefinition() const { + bool isThisDeclarationADefinition() const { return getDefinition() == this; } - + /// Determine whether this class has been defined. bool hasDefinition() const { // If the name of this class is out-of-date, bring it up-to-date, which @@ -1561,16 +1561,16 @@ public: return Data.getPointer(); } - - /// Retrieve the definition of this class, or NULL if this class - /// has been forward-declared (with \@class) but not yet defined (with + + /// Retrieve the definition of this class, or NULL if this class + /// has been forward-declared (with \@class) but not yet defined (with /// \@interface). ObjCInterfaceDecl *getDefinition() { return hasDefinition()? Data.getPointer()->Definition : nullptr; } - /// Retrieve the definition of this class, or NULL if this class - /// has been forward-declared (with \@class) but not yet defined (with + /// Retrieve the definition of this class, or NULL if this class + /// has been forward-declared (with \@class) but not yet defined (with /// \@interface). const ObjCInterfaceDecl *getDefinition() const { return hasDefinition()? Data.getPointer()->Definition : nullptr; @@ -1579,7 +1579,7 @@ public: /// Starts the definition of this Objective-C class, taking it from /// a forward declaration (\@class) to a definition (\@interface). void startDefinition(); - + /// Retrieve the superclass type. const ObjCObjectType *getSuperClassType() const { if (TypeSourceInfo *TInfo = getSuperClassTInfo()) @@ -1593,7 +1593,7 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return nullptr; - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1604,7 +1604,7 @@ public: // does not include any type arguments that apply to the superclass. ObjCInterfaceDecl *getSuperClass() const; - void setSuperClass(TypeSourceInfo *superClass) { + void setSuperClass(TypeSourceInfo *superClass) { data().SuperClassTInfo = superClass; } @@ -1618,7 +1618,7 @@ public: ObjCCategoryDecl *Current = nullptr; void findAcceptableCategory(); - + public: using value_type = ObjCCategoryDecl *; using reference = value_type; @@ -1659,7 +1659,7 @@ private: /// /// Used in the \c visible_categories_iterator. static bool isVisibleCategory(ObjCCategoryDecl *Cat); - + public: /// Iterator that walks over the list of categories and extensions /// that are visible, i.e., not hidden in a non-imported submodule. @@ -1765,7 +1765,7 @@ private: /// /// Used in the \c known_extensions_iterator. static bool isKnownExtension(ObjCCategoryDecl *Cat); - + public: friend class ASTDeclReader; friend class ASTDeclWriter; @@ -1787,7 +1787,7 @@ public: known_extensions_iterator known_extensions_begin() const { return known_extensions_iterator(getCategoryListRaw()); } - + /// Retrieve an iterator to the end of the known-extensions list. known_extensions_iterator known_extensions_end() const { return known_extensions_iterator(); @@ -1804,7 +1804,7 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return nullptr; - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1831,7 +1831,7 @@ public: while (I != nullptr) { if (declaresSameEntity(this, I)) return true; - + I = I->getSuperClass(); } return false; @@ -1841,7 +1841,7 @@ public: /// to be incompatible with __weak references. Returns true if it is. bool isArcWeakrefUnavailable() const; - /// isObjCRequiresPropertyDefs - Checks that a class or one of its super + /// isObjCRequiresPropertyDefs - Checks that a class or one of its super /// classes must not be auto-synthesized. Returns class decl. if it must not /// be; 0, otherwise. const ObjCInterfaceDecl *isObjCRequiresPropertyDefs() const; @@ -1854,7 +1854,7 @@ public: } ObjCProtocolDecl *lookupNestedProtocol(IdentifierInfo *Name); - + // Lookup a method. First, we search locally. If a method isn't // found, we search referenced protocols and class categories. ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance, @@ -1893,14 +1893,14 @@ public: true /* followsSuper */, Cat); } - - SourceLocation getEndOfDefinitionLoc() const { + + SourceLocation getEndOfDefinitionLoc() const { if (!hasDefinition()) return getLocation(); - - return data().EndLoc; + + return data().EndLoc; } - + void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; } /// Retrieve the starting location of the superclass. @@ -1909,7 +1909,7 @@ public: /// isImplicitInterfaceDecl - check that this is an implicitly declared /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation /// declaration without an \@interface declaration. - bool isImplicitInterfaceDecl() const { + bool isImplicitInterfaceDecl() const { return hasDefinition() ? data().Definition->isImplicit() : isImplicit(); } @@ -1987,7 +1987,7 @@ public: bool synthesized=false); static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// Return the class interface that this ivar is logically contained /// in; this is either the interface where the ivar was declared, or the /// interface the ivar is conceptually a part of in the case of synthesized @@ -2045,7 +2045,7 @@ public: QualType T, Expr *BW); static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ObjCAtDefsField; } @@ -2087,7 +2087,7 @@ class ObjCProtocolDecl : public ObjCContainerDecl, ObjCProtocolDecl *Definition; /// Referenced protocols - ObjCProtocolList ReferencedProtocols; + ObjCProtocolList ReferencedProtocols; }; /// Contains a pointer to the data associated with this class, @@ -2107,7 +2107,7 @@ class ObjCProtocolDecl : public ObjCContainerDecl, assert(Data.getPointer() && "Objective-C protocol has no definition!"); return *Data.getPointer(); } - + void allocateDefinitionData(); using redeclarable_base = Redeclarable<ObjCProtocolDecl>; @@ -2152,15 +2152,15 @@ public: protocol_iterator protocol_begin() const { if (!hasDefinition()) return protocol_iterator(); - + return data().ReferencedProtocols.begin(); } - protocol_iterator protocol_end() const { + protocol_iterator protocol_end() const { if (!hasDefinition()) return protocol_iterator(); - - return data().ReferencedProtocols.end(); + + return data().ReferencedProtocols.end(); } using protocol_loc_iterator = ObjCProtocolList::loc_iterator; @@ -2173,22 +2173,22 @@ public: protocol_loc_iterator protocol_loc_begin() const { if (!hasDefinition()) return protocol_loc_iterator(); - + return data().ReferencedProtocols.loc_begin(); } protocol_loc_iterator protocol_loc_end() const { if (!hasDefinition()) return protocol_loc_iterator(); - + return data().ReferencedProtocols.loc_end(); } - unsigned protocol_size() const { + unsigned protocol_size() const { if (!hasDefinition()) return 0; - - return data().ReferencedProtocols.size(); + + return data().ReferencedProtocols.size(); } /// setProtocolList - Set the list of protocols that this interface @@ -2235,12 +2235,12 @@ public: return hasDefinition()? Data.getPointer()->Definition : nullptr; } - /// Determine whether this particular declaration is also the + /// Determine whether this particular declaration is also the /// definition. bool isThisDeclarationADefinition() const { return getDefinition() == this; } - + /// Starts the definition of this Objective-C protocol. void startDefinition(); @@ -2251,10 +2251,10 @@ public: SourceRange getSourceRange() const override LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); - + return SourceRange(getAtStartLoc(), getLocation()); } - + using redecl_range = redeclarable_base::redecl_range; using redecl_iterator = redeclarable_base::redecl_iterator; @@ -2316,7 +2316,7 @@ class ObjCCategoryDecl : public ObjCContainerDecl { /// class extension may have private ivars. SourceLocation IvarLBraceLoc; SourceLocation IvarRBraceLoc; - + ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, @@ -2431,7 +2431,7 @@ public: SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; } - + void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; } SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } @@ -2576,7 +2576,7 @@ class ObjCImplementationDecl : public ObjCImplDecl { /// \@implementation may have private ivars. SourceLocation IvarLBraceLoc; SourceLocation IvarRBraceLoc; - + /// Support for ivar initialization. /// The arguments used to initialize the ivars LazyCXXCtorInitializersPtr IvarInitializers; @@ -2594,7 +2594,7 @@ class ObjCImplementationDecl : public ObjCImplDecl { ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc = SourceLocation(), - SourceLocation IvarLBraceLoc=SourceLocation(), + SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation()) : ObjCImplDecl(ObjCImplementation, DC, classInterface, classInterface ? classInterface->getIdentifier() @@ -2616,7 +2616,7 @@ public: SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc = SourceLocation(), - SourceLocation IvarLBraceLoc=SourceLocation(), + SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation()); static ObjCImplementationDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -2700,7 +2700,7 @@ public: std::string getNameAsString() const { return getName(); } - + /// Produce a name to be used for class's metadata. It comes either via /// class's objc_runtime_name attribute or class name. StringRef getObjCRuntimeNameAsString() const; @@ -2715,7 +2715,7 @@ public: SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; } - + using ivar_iterator = specific_decl_iterator<ObjCIvarDecl>; using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>; @@ -2760,9 +2760,9 @@ public: SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl* aliasedClass); - static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, + static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index a2f00ec9ffa22..e0ea7cb8b1b83 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -734,8 +734,8 @@ public: }; /// Declaration of a redeclarable template. -class RedeclarableTemplateDecl : public TemplateDecl, - public Redeclarable<RedeclarableTemplateDecl> +class RedeclarableTemplateDecl : public TemplateDecl, + public Redeclarable<RedeclarableTemplateDecl> { using redeclarable_base = Redeclarable<RedeclarableTemplateDecl>; @@ -823,7 +823,7 @@ protected: /// Pointer to the common data shared by all declarations of this /// template. mutable CommonBase *Common = nullptr; - + /// Retrieves the "common" pointer shared by all (re-)declarations of /// the same template. Calling this routine may implicitly allocate memory /// for the common pointer. @@ -888,10 +888,10 @@ public: } /// Retrieve the member template from which this template was - /// instantiated, or nullptr if this template was not instantiated from a + /// instantiated, or nullptr if this template was not instantiated from a /// member template. /// - /// A template is instantiated from a member template when the member + /// A template is instantiated from a member template when the member /// template itself is part of a class template (or member thereof). For /// example, given /// @@ -1178,7 +1178,7 @@ public: unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack); - static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C, + static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C, unsigned ID); /// Whether this template type parameter was declared with @@ -1312,12 +1312,12 @@ public: QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos); - static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, + static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, unsigned ID); - static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, + static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpandedTypes); - + using TemplateParmPosition::getDepth; using TemplateParmPosition::setDepth; using TemplateParmPosition::getPosition; @@ -1495,7 +1495,7 @@ public: static TemplateTemplateParmDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions); - + using TemplateParmPosition::getDepth; using TemplateParmPosition::setDepth; using TemplateParmPosition::getPosition; @@ -2442,7 +2442,7 @@ public: static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID); - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index 9d3dad6bbd9d2..856f3ab5720e3 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -211,14 +211,14 @@ public: /// getNameKind - Determine what kind of name this is. NameKind getNameKind() const; - /// Determines whether the name itself is dependent, e.g., because it + /// Determines whether the name itself is dependent, e.g., because it /// involves a C++ type that is itself dependent. /// /// Note that this does not capture all of the notions of "dependent name", - /// because an identifier can be a dependent name if it is used as the + /// because an identifier can be a dependent name if it is used as the /// callee in a call expression with dependent arguments. bool isDependentName() const; - + /// getNameAsString - Retrieve the human-readable string for this name. std::string getAsString() const; @@ -543,7 +543,7 @@ public: /// Determine whether this name involves a template parameter. bool isInstantiationDependent() const; - + /// Determine whether this name contains an unexpanded /// parameter pack. bool containsUnexpandedParameterPack() const; @@ -558,7 +558,7 @@ public: SourceLocation getBeginLoc() const { return NameLoc; } /// getEndLoc - Retrieve the location of the last token. - SourceLocation getEndLoc() const; + SourceLocation getEndLoc() const { return getLocEnd(); } /// getSourceRange - The range of the declaration name. SourceRange getSourceRange() const LLVM_READONLY { @@ -570,9 +570,11 @@ public: } SourceLocation getLocEnd() const LLVM_READONLY { - SourceLocation EndLoc = getEndLoc(); + SourceLocation EndLoc = getEndLocPrivate(); return EndLoc.isValid() ? EndLoc : getLocStart(); } +private: + SourceLocation getEndLocPrivate() const; }; /// Insertion operator for diagnostics. This allows sending DeclarationName's diff --git a/include/clang/AST/DependentDiagnostic.h b/include/clang/AST/DependentDiagnostic.h index a514326c6cb10..c21ef7907b8ae 100644 --- a/include/clang/AST/DependentDiagnostic.h +++ b/include/clang/AST/DependentDiagnostic.h @@ -101,9 +101,9 @@ private: friend class DependentStoredDeclsMap; DependentDiagnostic(const PartialDiagnostic &PDiag, - PartialDiagnostic::Storage *Storage) + PartialDiagnostic::Storage *Storage) : Diag(PDiag, Storage) {} - + static DependentDiagnostic *Create(ASTContext &Context, DeclContext *Parent, const PartialDiagnostic &PDiag); diff --git a/include/clang/AST/EvaluatedExprVisitor.h b/include/clang/AST/EvaluatedExprVisitor.h index e00986dbe9c86..1aec5ae842d48 100644 --- a/include/clang/AST/EvaluatedExprVisitor.h +++ b/include/clang/AST/EvaluatedExprVisitor.h @@ -21,9 +21,9 @@ #include "clang/AST/StmtVisitor.h" namespace clang { - + class ASTContext; - + /// Given a potentially-evaluated expression, this visitor visits all /// of its potentially-evaluated subexpressions, recursively. template<template <typename> class Ptr, typename ImplClass> diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 7585231e62e5c..c18fbf05df683 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -884,7 +884,7 @@ public: : Expr(OpaqueValueExprClass, T, VK, OK, T->isDependentType() || (SourceExpr && SourceExpr->isTypeDependent()), - T->isDependentType() || + T->isDependentType() || (SourceExpr && SourceExpr->isValueDependent()), T->isInstantiationDependentType() || (SourceExpr && SourceExpr->isInstantiationDependent()), @@ -2787,20 +2787,26 @@ public: /// representation in the source code (ExplicitCastExpr's derived /// classes). class CastExpr : public Expr { +public: + using BasePathSizeTy = unsigned int; + static_assert(std::numeric_limits<BasePathSizeTy>::max() >= 16384, + "[implimits] Direct and indirect base classes [16384]."); + private: Stmt *Op; bool CastConsistency() const; + BasePathSizeTy *BasePathSize(); + const CXXBaseSpecifier * const *path_buffer() const { return const_cast<CastExpr*>(this)->path_buffer(); } CXXBaseSpecifier **path_buffer(); - void setBasePathSize(unsigned basePathSize) { - CastExprBits.BasePathSize = basePathSize; - assert(CastExprBits.BasePathSize == basePathSize && - "basePathSize doesn't fit in bits of CastExprBits.BasePathSize!"); + void setBasePathSize(BasePathSizeTy basePathSize) { + assert(!path_empty() && basePathSize != 0); + *(BasePathSize()) = basePathSize; } protected: @@ -2823,7 +2829,9 @@ protected: Op(op) { CastExprBits.Kind = kind; CastExprBits.PartOfExplicitCast = false; - setBasePathSize(BasePathSize); + CastExprBits.BasePathIsEmpty = BasePathSize == 0; + if (!path_empty()) + setBasePathSize(BasePathSize); assert(CastConsistency()); } @@ -2831,7 +2839,9 @@ protected: CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize) : Expr(SC, Empty) { CastExprBits.PartOfExplicitCast = false; - setBasePathSize(BasePathSize); + CastExprBits.BasePathIsEmpty = BasePathSize == 0; + if (!path_empty()) + setBasePathSize(BasePathSize); } public: @@ -2859,8 +2869,12 @@ public: typedef CXXBaseSpecifier **path_iterator; typedef const CXXBaseSpecifier * const *path_const_iterator; - bool path_empty() const { return CastExprBits.BasePathSize == 0; } - unsigned path_size() const { return CastExprBits.BasePathSize; } + bool path_empty() const { return CastExprBits.BasePathIsEmpty; } + unsigned path_size() const { + if (path_empty()) + return 0U; + return *(const_cast<CastExpr *>(this)->BasePathSize()); + } path_iterator path_begin() { return path_buffer(); } path_iterator path_end() { return path_buffer() + path_size(); } path_const_iterator path_begin() const { return path_buffer(); } @@ -2908,7 +2922,12 @@ public: /// @endcode class ImplicitCastExpr final : public CastExpr, - private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<ImplicitCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + private: ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, unsigned BasePathLength, ExprValueKind VK) @@ -3013,7 +3032,8 @@ public: /// (Type)expr. For example: @c (int)f. class CStyleCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<CStyleCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { SourceLocation LPLoc; // the location of the left paren SourceLocation RPLoc; // the location of the right paren @@ -3027,6 +3047,10 @@ class CStyleCastExpr final explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize) : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { } + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: static CStyleCastExpr *Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, @@ -5341,7 +5365,7 @@ public: SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); } SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == TypoExprClass; } diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 8206a26b2c4b5..7ab8020dec649 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -301,7 +301,8 @@ public: /// \c static_cast<int>(1.0). class CXXStaticCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects<CXXStaticCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<CXXStaticCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, @@ -312,6 +313,10 @@ class CXXStaticCastExpr final explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -337,7 +342,8 @@ public: /// check to determine how to perform the type conversion. class CXXDynamicCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects<CXXDynamicCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects< + CXXDynamicCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, @@ -348,6 +354,10 @@ class CXXDynamicCastExpr final explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -380,6 +390,7 @@ public: class CXXReinterpretCastExpr final : public CXXNamedCastExpr, private llvm::TrailingObjects<CXXReinterpretCastExpr, + CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, unsigned pathSize, @@ -392,6 +403,10 @@ class CXXReinterpretCastExpr final CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -419,7 +434,8 @@ public: /// value. class CXXConstCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects<CXXConstCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<CXXConstCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) @@ -429,6 +445,10 @@ class CXXConstCastExpr final explicit CXXConstCastExpr(EmptyShell Empty) : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -721,7 +741,7 @@ public: } }; -/// A member reference to an MSPropertyDecl. +/// A member reference to an MSPropertyDecl. /// /// This expression always has pseudo-object type, and therefore it is /// typically not encountered in a fully-typechecked expression except @@ -1471,7 +1491,8 @@ public: /// \endcode class CXXFunctionalCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects< + CXXFunctionalCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { SourceLocation LParenLoc; SourceLocation RParenLoc; @@ -1486,6 +1507,10 @@ class CXXFunctionalCastExpr final explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -1591,7 +1616,7 @@ class LambdaExpr final : public Expr, /// The number of captures. unsigned NumCaptures : 16; - + /// The default capture kind, which is a value of type /// LambdaCaptureDefault. unsigned CaptureDefault : 2; @@ -1602,10 +1627,10 @@ class LambdaExpr final : public Expr, /// Whether this lambda had the result type explicitly specified. unsigned ExplicitResultType : 1; - + /// The location of the closing brace ('}') that completes /// the lambda. - /// + /// /// The location of the brace is also available by looking up the /// function call operator in the lambda class. However, it is /// stored here to improve the performance of getSourceRange(), and @@ -1673,7 +1698,7 @@ public: /// Retrieve this lambda's captures. capture_range captures() const; - + /// Retrieve an iterator pointing to the first lambda capture. capture_iterator capture_begin() const; @@ -1686,7 +1711,7 @@ public: /// Retrieve this lambda's explicit captures. capture_range explicit_captures() const; - + /// Retrieve an iterator pointing to the first explicit /// lambda capture. capture_iterator explicit_capture_begin() const; @@ -1754,18 +1779,18 @@ public: SourceRange getIntroducerRange() const { return IntroducerRange; } /// Retrieve the class that corresponds to the lambda. - /// + /// /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the /// captures in its fields and provides the various operations permitted /// on a lambda (copying, calling). CXXRecordDecl *getLambdaClass() const; /// Retrieve the function call operator associated with this - /// lambda expression. + /// lambda expression. CXXMethodDecl *getCallOperator() const; - /// If this is a generic lambda expression, retrieve the template - /// parameter list associated with it, or else return null. + /// If this is a generic lambda expression, retrieve the template + /// parameter list associated with it, or else return null. TemplateParameterList *getTemplateParameterList() const; /// Whether this is a generic lambda. @@ -1784,7 +1809,7 @@ public: /// Whether this lambda had its result type explicitly specified. bool hasExplicitResultType() const { return ExplicitResultType; } - + static bool classof(const Stmt *T) { return T->getStmtClass() == LambdaExprClass; } @@ -2129,7 +2154,7 @@ public: Expr *getArgument() { return cast<Expr>(Argument); } const Expr *getArgument() const { return cast<Expr>(Argument); } - /// Retrieve the type being destroyed. + /// Retrieve the type being destroyed. /// /// If the type being destroyed is a dependent type which may or may not /// be a pointer, return an invalid type. @@ -2345,13 +2370,13 @@ class TypeTraitExpr final private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> { /// The location of the type trait keyword. SourceLocation Loc; - + /// The location of the closing parenthesis. SourceLocation RParenLoc; - + // Note: The TypeSourceInfos for the arguments are allocated after the // TypeTraitExpr. - + TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef<TypeSourceInfo *> Args, SourceLocation RParenLoc, @@ -2377,26 +2402,26 @@ public: static TypeTraitExpr *CreateDeserialized(const ASTContext &C, unsigned NumArgs); - + /// Determine which type trait this expression uses. TypeTrait getTrait() const { return static_cast<TypeTrait>(TypeTraitExprBits.Kind); } - bool getValue() const { - assert(!isValueDependent()); - return TypeTraitExprBits.Value; + bool getValue() const { + assert(!isValueDependent()); + return TypeTraitExprBits.Value; } - + /// Determine the number of arguments to this type trait. unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; } - + /// Retrieve the Ith argument. TypeSourceInfo *getArg(unsigned I) const { assert(I < getNumArgs() && "Argument out-of-range"); return getArgs()[I]; } - + /// Retrieve the argument types. ArrayRef<TypeSourceInfo *> getArgs() const { return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(), @@ -2409,7 +2434,7 @@ public: static bool classof(const Stmt *T) { return T->getStmtClass() == TypeTraitExprClass; } - + // Iterators child_range children() { return child_range(child_iterator(), child_iterator()); diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index 5dac0e037da11..bb0402c270808 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -90,16 +90,16 @@ public: Value(val), Loc(l) {} explicit ObjCBoolLiteralExpr(EmptyShell Empty) : Expr(ObjCBoolLiteralExprClass, Empty) {} - + bool getValue() const { return Value; } void setValue(bool V) { Value = V; } - + SourceLocation getLocStart() const LLVM_READONLY { return Loc; } SourceLocation getLocEnd() const LLVM_READONLY { return Loc; } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - + // Iterators child_range children() { return child_range(child_iterator(), child_iterator()); @@ -124,30 +124,30 @@ public: ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R) - : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary, - E->isTypeDependent(), E->isValueDependent(), + : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary, + E->isTypeDependent(), E->isValueDependent(), E->isInstantiationDependent(), - E->containsUnexpandedParameterPack()), + E->containsUnexpandedParameterPack()), SubExpr(E), BoxingMethod(method), Range(R) {} explicit ObjCBoxedExpr(EmptyShell Empty) : Expr(ObjCBoxedExprClass, Empty) {} - + Expr *getSubExpr() { return cast<Expr>(SubExpr); } const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } - + ObjCMethodDecl *getBoxingMethod() const { - return BoxingMethod; + return BoxingMethod; } - + SourceLocation getAtLoc() const { return Range.getBegin(); } - + SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } SourceRange getSourceRange() const LLVM_READONLY { return Range; } - + // Iterators child_range children() { return child_range(&SubExpr, &SubExpr+1); } @@ -208,7 +208,7 @@ public: /// getNumElements - Return number of elements of objective-c array literal. unsigned getNumElements() const { return NumElements; } - + /// getElement - Return the Element at the specified index. Expr *getElement(unsigned Index) { assert((Index < NumElements) && "Arg access out of range!"); @@ -218,11 +218,11 @@ public: assert((Index < NumElements) && "Arg access out of range!"); return getElements()[Index]; } - + ObjCMethodDecl *getArrayWithObjectsMethod() const { - return ArrayWithObjectsMethod; + return ArrayWithObjectsMethod; } - + // Iterators child_range children() { return child_range(reinterpret_cast<Stmt **>(getElements()), @@ -239,13 +239,13 @@ public: struct ObjCDictionaryElement { /// The key for the dictionary element. Expr *Key; - + /// The value of the dictionary element. Expr *Value; - + /// The location of the ellipsis, if this is a pack expansion. SourceLocation EllipsisLoc; - + /// The number of elements this pack expansion will expand to, if /// this is a pack expansion and is known. Optional<unsigned> NumExpansions; @@ -308,7 +308,7 @@ class ObjCDictionaryLiteral final using KeyValuePair = ObjCDictionaryLiteral_KeyValuePair; using ExpansionData = ObjCDictionaryLiteral_ExpansionData; - ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK, + ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR); @@ -328,16 +328,16 @@ public: friend TrailingObjects; static ObjCDictionaryLiteral *Create(const ASTContext &C, - ArrayRef<ObjCDictionaryElement> VK, + ArrayRef<ObjCDictionaryElement> VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR); - + static ObjCDictionaryLiteral *CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions); - - /// getNumElements - Return number of elements of objective-c dictionary + + /// getNumElements - Return number of elements of objective-c dictionary /// literal. unsigned getNumElements() const { return NumElements; } @@ -354,7 +354,7 @@ public: } return Result; } - + ObjCMethodDecl *getDictWithObjectsMethod() const { return DictWithObjectsMethod; } @@ -394,7 +394,7 @@ public: EncodedType->getType()->isDependentType(), EncodedType->getType()->isDependentType(), EncodedType->getType()->isInstantiationDependentType(), - EncodedType->getType()->containsUnexpandedParameterPack()), + EncodedType->getType()->containsUnexpandedParameterPack()), EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {} explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){} @@ -408,8 +408,8 @@ public: TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; } - void setEncodedTypeSourceInfo(TypeSourceInfo *EncType) { - EncodedType = EncType; + void setEncodedTypeSourceInfo(TypeSourceInfo *EncType) { + EncodedType = EncType; } SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; } @@ -531,9 +531,9 @@ public: bool arrow = false, bool freeIvar = false) : Expr(ObjCIvarRefExprClass, t, VK_LValue, d->isBitField() ? OK_BitField : OK_Ordinary, - /*TypeDependent=*/false, base->isValueDependent(), + /*TypeDependent=*/false, base->isValueDependent(), base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), + base->containsUnexpandedParameterPack()), D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow), IsFreeIvar(freeIvar) {} @@ -560,7 +560,7 @@ public: return isFreeIvar() ? Loc : getBase()->getLocStart(); } SourceLocation getLocEnd() const LLVM_READONLY { return Loc; } - + SourceLocation getOpLoc() const { return OpLoc; } void setOpLoc(SourceLocation L) { OpLoc = L; } @@ -600,13 +600,13 @@ private: // transformation is lossy on the first character). SourceLocation IdLoc; - + /// When the receiver in property access is 'super', this is /// the location of the 'super' keyword. When it's an interface, /// this is that interface. SourceLocation ReceiverLoc; llvm::PointerUnion3<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver; - + public: ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, @@ -618,7 +618,7 @@ public: PropertyOrGetter(PD, false), IdLoc(l), Receiver(base) { assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject)); } - + ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, SourceLocation sl, QualType st) @@ -716,19 +716,19 @@ public: setMethodRefFlag(MethodRef_Setter, val); } - const Expr *getBase() const { - return cast<Expr>(Receiver.get<Stmt*>()); + const Expr *getBase() const { + return cast<Expr>(Receiver.get<Stmt*>()); } - Expr *getBase() { - return cast<Expr>(Receiver.get<Stmt*>()); + Expr *getBase() { + return cast<Expr>(Receiver.get<Stmt*>()); } SourceLocation getLocation() const { return IdLoc; } - + SourceLocation getReceiverLocation() const { return ReceiverLoc; } - QualType getSuperReceiverType() const { - return QualType(Receiver.get<const Type*>(), 0); + QualType getSuperReceiverType() const { + return QualType(Receiver.get<const Type*>(), 0); } ObjCInterfaceDecl *getClassReceiver() const { @@ -796,7 +796,7 @@ private: SetterAndMethodRefFlags.setInt(f); } }; - + /// ObjCSubscriptRefExpr - used for array and dictionary subscripting. /// array[4] = array[3]; dictionary[key] = dictionary[alt_key]; class ObjCSubscriptRefExpr : public Expr { @@ -808,20 +808,20 @@ class ObjCSubscriptRefExpr : public Expr { // an objective-c object pointer expression. enum { BASE, KEY, END_EXPR }; Stmt* SubExprs[END_EXPR]; - + ObjCMethodDecl *GetAtIndexMethodDecl; - + // For immutable objects this is null. When ObjCSubscriptRefExpr is to read // an indexed object this is null too. ObjCMethodDecl *SetAtIndexMethodDecl; - + public: ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB) - : Expr(ObjCSubscriptRefExprClass, T, VK, OK, - base->isTypeDependent() || key->isTypeDependent(), + : Expr(ObjCSubscriptRefExprClass, T, VK, OK, + base->isTypeDependent() || key->isTypeDependent(), base->isValueDependent() || key->isValueDependent(), (base->isInstantiationDependent() || key->isInstantiationDependent()), @@ -834,7 +834,7 @@ public: explicit ObjCSubscriptRefExpr(EmptyShell Empty) : Expr(ObjCSubscriptRefExprClass, Empty) {} - + SourceLocation getRBracket() const { return RBracket; } void setRBracket(SourceLocation RB) { RBracket = RB; } @@ -843,25 +843,25 @@ public: } SourceLocation getLocEnd() const LLVM_READONLY { return RBracket; } - + Expr *getBaseExpr() const { return cast<Expr>(SubExprs[BASE]); } void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; } - + Expr *getKeyExpr() const { return cast<Expr>(SubExprs[KEY]); } void setKeyExpr(Stmt *S) { SubExprs[KEY] = S; } - + ObjCMethodDecl *getAtIndexMethodDecl() const { return GetAtIndexMethodDecl; } - + ObjCMethodDecl *setAtIndexMethodDecl() const { return SetAtIndexMethodDecl; } - + bool isArraySubscriptRefExpr() const { return getKeyExpr()->getType()->isIntegralOrEnumerationType(); } - + child_range children() { return child_range(SubExprs, SubExprs+END_EXPR); } @@ -913,7 +913,7 @@ class ObjCMessageExpr final /// The number of arguments in the message send, not /// including the receiver. unsigned NumArgs : NumArgsBitWidth; - + /// The kind of message send this is, which is one of the /// ReceiverKind values. /// @@ -958,7 +958,7 @@ class ObjCMessageExpr final SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, @@ -968,7 +968,7 @@ class ObjCMessageExpr final ObjCMessageExpr(QualType T, ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, @@ -978,7 +978,7 @@ class ObjCMessageExpr final ObjCMessageExpr(QualType T, ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, @@ -1091,7 +1091,7 @@ public: SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, @@ -1125,7 +1125,7 @@ public: ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, @@ -1159,7 +1159,7 @@ public: ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SeLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, @@ -1215,14 +1215,14 @@ public: /// Turn this message send into an instance message that /// computes the receiver object with the given expression. - void setInstanceReceiver(Expr *rec) { + void setInstanceReceiver(Expr *rec) { Kind = Instance; setReceiverPointer(rec); } - + /// Returns the type of a class message send, or NULL if the /// message is not a class message. - QualType getClassReceiver() const { + QualType getClassReceiver() const { if (TypeSourceInfo *TSInfo = getClassReceiverTypeInfo()) return TSInfo->getType(); @@ -1244,7 +1244,7 @@ public: /// Retrieve the location of the 'super' keyword for a class /// or instance message to 'super', otherwise an invalid source location. - SourceLocation getSuperLoc() const { + SourceLocation getSuperLoc() const { if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass) return SuperLoc; @@ -1274,7 +1274,7 @@ public: /// \returns The Objective-C interface if known, otherwise nullptr. ObjCInterfaceDecl *getReceiverInterface() const; - /// Retrieve the type referred to by 'super'. + /// Retrieve the type referred to by 'super'. /// /// The returned type will either be an ObjCInterfaceType (for an /// class message to super) or an ObjCObjectPointerType that refers @@ -1294,26 +1294,26 @@ public: Selector getSelector() const; - void setSelector(Selector S) { + void setSelector(Selector S) { HasMethod = false; SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr()); } - const ObjCMethodDecl *getMethodDecl() const { + const ObjCMethodDecl *getMethodDecl() const { if (HasMethod) return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod); return nullptr; } - ObjCMethodDecl *getMethodDecl() { + ObjCMethodDecl *getMethodDecl() { if (HasMethod) return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod); return nullptr; } - void setMethodDecl(ObjCMethodDecl *MD) { + void setMethodDecl(ObjCMethodDecl *MD) { HasMethod = true; SelectorOrMethod = reinterpret_cast<uintptr_t>(MD); } @@ -1414,16 +1414,16 @@ public: arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); } - arg_iterator arg_end() { - return reinterpret_cast<Stmt **>(getArgs() + NumArgs); + arg_iterator arg_end() { + return reinterpret_cast<Stmt **>(getArgs() + NumArgs); } - const_arg_iterator arg_begin() const { - return reinterpret_cast<Stmt const * const*>(getArgs()); + const_arg_iterator arg_begin() const { + return reinterpret_cast<Stmt const * const*>(getArgs()); } - const_arg_iterator arg_end() const { - return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs); + const_arg_iterator arg_end() const { + return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs); } static bool classof(const Stmt *T) { @@ -1439,7 +1439,7 @@ class ObjCIsaExpr : public Expr { /// IsaMemberLoc - This is the location of the 'isa'. SourceLocation IsaMemberLoc; - + /// OpLoc - This is the location of '.' or '->' SourceLocation OpLoc; @@ -1468,18 +1468,18 @@ public: /// location of 'F'. SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } - + SourceLocation getOpLoc() const { return OpLoc; } void setOpLoc(SourceLocation L) { OpLoc = L; } SourceLocation getLocStart() const LLVM_READONLY { return getBase()->getLocStart(); } - + SourceLocation getBaseLocEnd() const LLVM_READONLY { return getBase()->getLocEnd(); } - + SourceLocation getLocEnd() const LLVM_READONLY { return IsaMemberLoc; } SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; } @@ -1546,7 +1546,7 @@ public: /// copy-restore. If false, the temporary will be zero-initialized. bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; } - child_range children() { return child_range(&Operand, &Operand+1); } + child_range children() { return child_range(&Operand, &Operand+1); } // Source locations are determined by the subexpression. SourceLocation getLocStart() const LLVM_READONLY { @@ -1571,7 +1571,8 @@ public: /// \endcode class ObjCBridgedCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects< + ObjCBridgedCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { friend class ASTStmtReader; friend class ASTStmtWriter; friend class CastExpr; @@ -1581,6 +1582,10 @@ class ObjCBridgedCastExpr final SourceLocation BridgeKeywordLoc; unsigned Kind : 2; + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, @@ -1588,7 +1593,7 @@ public: : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue, CK, Operand, 0, TSInfo), LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {} - + /// Construct an empty Objective-C bridged cast. explicit ObjCBridgedCastExpr(EmptyShell Shell) : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0) {} @@ -1596,22 +1601,22 @@ public: SourceLocation getLParenLoc() const { return LParenLoc; } /// Determine which kind of bridge is being performed via this cast. - ObjCBridgeCastKind getBridgeKind() const { - return static_cast<ObjCBridgeCastKind>(Kind); + ObjCBridgeCastKind getBridgeKind() const { + return static_cast<ObjCBridgeCastKind>(Kind); } - + /// Retrieve the kind of bridge being performed as a string. StringRef getBridgeKindName() const; - + /// The location of the bridge keyword. SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; } - + SourceLocation getLocStart() const LLVM_READONLY { return LParenLoc; } SourceLocation getLocEnd() const LLVM_READONLY { return getSubExpr()->getLocEnd(); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCBridgedCastExprClass; } diff --git a/include/clang/AST/ExternalASTMerger.h b/include/clang/AST/ExternalASTMerger.h index ae8a761e127e5..7b01fa8cbced9 100644 --- a/include/clang/AST/ExternalASTMerger.h +++ b/include/clang/AST/ExternalASTMerger.h @@ -37,7 +37,7 @@ namespace clang { /// lookup. In this case, Origins contains an entry overriding lookup and /// specifying the correct pair of DeclContext/ASTContext. /// -/// - The DeclContext of origin was determined by another ExterenalASTMerger. +/// - The DeclContext of origin was determined by another ExterenalASTMerger. /// (This is possible when the source ASTContext for one of the Importers has /// its own ExternalASTMerger). The origin must be properly forwarded in this /// case. @@ -57,7 +57,7 @@ public: typedef std::map<const DeclContext *, DCOrigin> OriginMap; typedef std::vector<std::unique_ptr<ASTImporter>> ImporterVector; private: - /// One importer exists for each source. + /// One importer exists for each source. ImporterVector Importers; /// Overrides in case name lookup would return nothing or would return /// the wrong thing. @@ -106,7 +106,7 @@ public: /// Remove a set of ASTContexts as possible origins. /// /// Sometimes an origin goes away (for example, if a source file gets - /// superseded by a newer version). + /// superseded by a newer version). /// /// The caller is responsible for ensuring that this doesn't leave /// DeclContexts that can't be completed. @@ -163,7 +163,7 @@ private: template <typename CallbackType> void ForEachMatchingDC(const DeclContext *DC, CallbackType Callback); -public: +public: /// Log something if there is a logging callback installed. llvm::raw_ostream &logs() { return *LogStream; } diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h index 82255bb1c44c8..525d4c78b3627 100644 --- a/include/clang/AST/ExternalASTSource.h +++ b/include/clang/AST/ExternalASTSource.h @@ -270,10 +270,10 @@ public: /// /// The default implementation of this method is a no-op. virtual void PrintStats(); - + /// Perform layout on the given record. /// - /// This routine allows the external AST source to provide an specific + /// This routine allows the external AST source to provide an specific /// layout for a record, overriding the layout that would normally be /// constructed. It is intended for clients who receive specific layout /// details rather than source code (such as LLDB). The client is expected @@ -290,13 +290,13 @@ public: /// expressed in bits. All of the fields must be provided with offsets. /// /// \param BaseOffsets The offset of each of the direct, non-virtual base - /// classes. If any bases are not given offsets, the bases will be laid + /// classes. If any bases are not given offsets, the bases will be laid /// out according to the ABI. /// /// \param VirtualBaseOffsets The offset of each of the virtual base classes - /// (either direct or not). If any bases are not given offsets, the bases will be laid + /// (either direct or not). If any bases are not given offsets, the bases will be laid /// out according to the ABI. - /// + /// /// \returns true if the record layout was provided, false otherwise. virtual bool layoutRecordType( const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, @@ -307,15 +307,15 @@ public: //===--------------------------------------------------------------------===// // Queries for performance analysis. //===--------------------------------------------------------------------===// - + struct MemoryBufferSizes { size_t malloc_bytes; size_t mmap_bytes; - + MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes) : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {} }; - + /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. MemoryBufferSizes getMemoryBufferSizes() const { @@ -512,10 +512,10 @@ namespace clang { /// Represents a lazily-loaded vector of data. /// /// The lazily-loaded vector of data contains data that is partially loaded -/// from an external source and partially added by local translation. The +/// from an external source and partially added by local translation. The /// items loaded from the external source are loaded lazily, when needed for /// iteration over the complete vector. -template<typename T, typename Source, +template<typename T, typename Source, void (Source::*Loader)(SmallVectorImpl<T>&), unsigned LoadedStorage = 2, unsigned LocalStorage = 4> class LazyVector { @@ -564,20 +564,20 @@ public: iterator begin(Source *source, bool LocalOnly = false) { if (LocalOnly) return iterator(this, 0); - + if (source) (source->*Loader)(Loaded); return iterator(this, -(int)Loaded.size()); } - + iterator end() { return iterator(this, Local.size()); } - + void push_back(const T& LocalValue) { Local.push_back(LocalValue); } - + void erase(iterator From, iterator To) { if (From.isLoaded() && To.isLoaded()) { Loaded.erase(&*From, &*To); diff --git a/include/clang/AST/GlobalDecl.h b/include/clang/AST/GlobalDecl.h index 3b3e4367d56c3..7f017994216fa 100644 --- a/include/clang/AST/GlobalDecl.h +++ b/include/clang/AST/GlobalDecl.h @@ -57,7 +57,7 @@ public: GlobalDecl CanonGD; CanonGD.Value.setPointer(Value.getPointer()->getCanonicalDecl()); CanonGD.Value.setInt(Value.getInt()); - + return CanonGD; } @@ -72,11 +72,11 @@ public: assert(isa<CXXDestructorDecl>(getDecl()) && "Decl is not a dtor!"); return static_cast<CXXDtorType>(Value.getInt()); } - + friend bool operator==(const GlobalDecl &LHS, const GlobalDecl &RHS) { return LHS.Value == RHS.Value; } - + void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } static GlobalDecl getFromOpaquePtr(void *P) { @@ -84,7 +84,7 @@ public: GD.Value.setFromOpaqueValue(P); return GD; } - + GlobalDecl getWithDecl(const Decl *D) { GlobalDecl Result(*this); Result.Value.setPointer(D); @@ -100,7 +100,7 @@ namespace llvm { static inline clang::GlobalDecl getEmptyKey() { return clang::GlobalDecl(); } - + static inline clang::GlobalDecl getTombstoneKey() { return clang::GlobalDecl:: getFromOpaquePtr(reinterpret_cast<void*>(-1)); @@ -109,13 +109,13 @@ namespace llvm { static unsigned getHashValue(clang::GlobalDecl GD) { return DenseMapInfo<void*>::getHashValue(GD.getAsOpaquePtr()); } - - static bool isEqual(clang::GlobalDecl LHS, + + static bool isEqual(clang::GlobalDecl LHS, clang::GlobalDecl RHS) { return LHS == RHS; } }; - + // GlobalDecl isn't *technically* a POD type. However, its copy constructor, // copy assignment operator, and destructor are all trivial. template <> diff --git a/include/clang/AST/LambdaCapture.h b/include/clang/AST/LambdaCapture.h index bcc5352c1c9dd..f246bc423bfb8 100644 --- a/include/clang/AST/LambdaCapture.h +++ b/include/clang/AST/LambdaCapture.h @@ -41,7 +41,7 @@ class LambdaCapture { }; // Decl could represent: - // - a VarDecl* that represents the variable that was captured or the + // - a VarDecl* that represents the variable that was captured or the // init-capture. // - or, is a nullptr and Capture_This is set in Bits if this represents a // capture of '*this' by value or reference. diff --git a/include/clang/AST/Mangle.h b/include/clang/AST/Mangle.h index 401574b265b0e..c42fe91b32469 100644 --- a/include/clang/AST/Mangle.h +++ b/include/clang/AST/Mangle.h @@ -73,7 +73,7 @@ public: DiagnosticsEngine &getDiags() const { return Diags; } virtual void startNewFunction() { LocalBlockIds.clear(); } - + unsigned getBlockId(const BlockDecl *BD, bool Local) { llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds = Local? LocalBlockIds : GlobalBlockIds; diff --git a/include/clang/AST/NSAPI.h b/include/clang/AST/NSAPI.h index ee07745b1242f..bf2afe38cbcab 100644 --- a/include/clang/AST/NSAPI.h +++ b/include/clang/AST/NSAPI.h @@ -113,7 +113,7 @@ public: NSMutableDict_setValueForKey }; static const unsigned NumNSDictionaryMethods = 13; - + /// The Objective-C NSDictionary selectors. Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const; diff --git a/include/clang/AST/NestedNameSpecifier.h b/include/clang/AST/NestedNameSpecifier.h index 2255d5114350e..3a7b45767dac7 100644 --- a/include/clang/AST/NestedNameSpecifier.h +++ b/include/clang/AST/NestedNameSpecifier.h @@ -44,7 +44,7 @@ class TypeLoc; /// specifier. Nested name specifiers are made up of a sequence of /// specifiers, each of which can be a namespace, type, identifier /// (for dependent names), decltype specifier, or the global specifier ('::'). -/// The last two specifiers can only appear at the start of a +/// The last two specifiers can only appear at the start of a /// nested-namespace-specifier. class NestedNameSpecifier : public llvm::FoldingSetNode { /// Enumeration describing @@ -438,7 +438,7 @@ public: /// Turn this (empty) nested-name-specifier into the global /// nested-name-specifier '::'. void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc); - + /// Turns this (empty) nested-name-specifier into '__super' /// nested-name-specifier. /// @@ -452,7 +452,7 @@ public: /// name. /// /// \param ColonColonLoc The location of the trailing '::'. - void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, + void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc); /// Make a new nested-name-specifier from incomplete source-location diff --git a/include/clang/AST/OperationKinds.def b/include/clang/AST/OperationKinds.def index 823e32424f1ee..e2d65d84880cb 100644 --- a/include/clang/AST/OperationKinds.def +++ b/include/clang/AST/OperationKinds.def @@ -307,7 +307,7 @@ CAST_OPERATION(AtomicToNonAtomic) /// Converts from T to _Atomic(T). CAST_OPERATION(NonAtomicToAtomic) -/// Causes a block literal to by copied to the heap and then +/// Causes a block literal to by copied to the heap and then /// autoreleased. /// /// This particular cast kind is used for the conversion from a C++11 @@ -391,13 +391,13 @@ BINARY_OPERATION(Comma, ",") // [C99 6.5.2.4] Postfix increment and decrement UNARY_OPERATION(PostInc, "++") UNARY_OPERATION(PostDec, "--") -// [C99 6.5.3.1] Prefix increment and decrement +// [C99 6.5.3.1] Prefix increment and decrement UNARY_OPERATION(PreInc, "++") UNARY_OPERATION(PreDec, "--") // [C99 6.5.3.2] Address and indirection UNARY_OPERATION(AddrOf, "&") UNARY_OPERATION(Deref, "*") -// [C99 6.5.3.3] Unary arithmetic +// [C99 6.5.3.3] Unary arithmetic UNARY_OPERATION(Plus, "+") UNARY_OPERATION(Minus, "-") UNARY_OPERATION(Not, "~") diff --git a/include/clang/AST/OperationKinds.h b/include/clang/AST/OperationKinds.h index c7e01fa1834e8..ac512d721e34e 100644 --- a/include/clang/AST/OperationKinds.h +++ b/include/clang/AST/OperationKinds.h @@ -16,7 +16,7 @@ #define LLVM_CLANG_AST_OPERATIONKINDS_H namespace clang { - + /// CastKind - The kind of operation required for a conversion. enum CastKind { #define CAST_OPERATION(Name) CK_##Name, diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h index 41c804486c358..b49f5be1b1e6e 100644 --- a/include/clang/AST/PrettyPrinter.h +++ b/include/clang/AST/PrettyPrinter.h @@ -109,7 +109,7 @@ struct PrintingPolicy { /// Suppress printing parts of scope specifiers that don't need /// to be written, e.g., for inline or anonymous namespaces. bool SuppressUnwrittenScope : 1; - + /// Suppress printing of variable initializers. /// /// This flag is used when printing the loop variable in a for-range @@ -140,15 +140,15 @@ struct PrintingPolicy { /// char a[9] = "A string"; /// \endcode bool ConstantArraySizeAsWritten : 1; - + /// When printing an anonymous tag name, also print the location of that /// entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just prints /// "(anonymous)" for the name. bool AnonymousTagLocations : 1; - + /// When true, suppress printing of the __strong lifetime qualifier in ARC. unsigned SuppressStrongLifetime : 1; - + /// When true, suppress printing of lifetime qualifier in ARC. unsigned SuppressLifetimeQualifiers : 1; @@ -179,7 +179,7 @@ struct PrintingPolicy { /// declarations inside namespaces etc. Effectively, this should print /// only the requested declaration. unsigned TerseOutput : 1; - + /// When true, do certain refinement needed for producing proper declaration /// tag; such as, do not print attributes attached to the declaration. /// diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h index dc60ef892b073..a546c200ffe03 100644 --- a/include/clang/AST/RecordLayout.h +++ b/include/clang/AST/RecordLayout.h @@ -71,6 +71,10 @@ private: // Alignment - Alignment of record in characters. CharUnits Alignment; + // UnadjustedAlignment - Maximum of the alignments of the record members in + // characters. + CharUnits UnadjustedAlignment; + /// RequiredAlignment - The required alignment of the object. In the MS-ABI /// the __declspec(align()) trumps #pramga pack and must always be obeyed. CharUnits RequiredAlignment; @@ -120,10 +124,10 @@ private: /// BaseSharingVBPtr - The base we share vbptr with. const CXXRecordDecl *BaseSharingVBPtr; - + /// FIXME: This should really use a SmallPtrMap, once we have one in LLVM :) using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>; - + /// BaseOffsets - Contains a map from base classes to their offset. BaseOffsetsMapTy BaseOffsets; @@ -136,6 +140,7 @@ private: CXXRecordLayoutInfo *CXXInfo = nullptr; ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, + CharUnits unadjustedAlignment, CharUnits requiredAlignment, CharUnits datasize, ArrayRef<uint64_t> fieldoffsets); @@ -144,6 +149,7 @@ private: // Constructor for C++ records. ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, + CharUnits unadjustedAlignment, CharUnits requiredAlignment, bool hasOwnVFPtr, bool hasExtendableVFPtr, CharUnits vbptroffset, @@ -162,7 +168,7 @@ private: ~ASTRecordLayout() = default; void Destroy(ASTContext &Ctx); - + public: ASTRecordLayout(const ASTRecordLayout &) = delete; ASTRecordLayout &operator=(const ASTRecordLayout &) = delete; @@ -170,6 +176,10 @@ public: /// getAlignment - Get the record alignment in characters. CharUnits getAlignment() const { return Alignment; } + /// getUnadjustedAlignment - Get the record alignment in characters, before + /// alignment adjustement. + CharUnits getUnadjustedAlignment() const { return UnadjustedAlignment; } + /// getSize - Get the record size in characters. CharUnits getSize() const { return Size; } @@ -259,7 +269,7 @@ public: assert(CXXInfo && "Record layout does not have C++ specific info!"); return CXXInfo->HasExtendableVFPtr; } - + /// hasOwnVBPtr - Does this class provide its own virtual-base /// table pointer, rather than inheriting one from a primary base /// class? diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 91dbcb71a600c..aa0f88b710237 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -204,7 +204,7 @@ protected: unsigned Kind : 6; unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr. - unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; + unsigned BasePathIsEmpty : 1; }; class CallExprBitfields { @@ -271,12 +271,12 @@ protected: friend class ASTStmtReader; friend class ASTStmtWriter; friend class TypeTraitExpr; - + unsigned : NumExprBits; - + /// The kind of type trait, which is a value of a TypeTrait enumerator. unsigned Kind : 8; - + /// If this expression is not value-dependent, this indicates whether /// the trait evaluated true or false. unsigned Value : 1; @@ -1556,7 +1556,7 @@ public: /// getInputConstraint - Return the specified input constraint. Unlike output /// constraints, these can be empty. StringRef getInputConstraint(unsigned i) const; - + const Expr *getInputExpr(unsigned i) const; //===--- Other ---===// @@ -2133,7 +2133,7 @@ private: /// The number of variable captured, including 'this'. unsigned NumCaptures; - /// The pointer part is the implicit the outlined function and the + /// The pointer part is the implicit the outlined function and the /// int part is the captured region kind, 'CR_Default' etc. llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind; diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h index 33aab08bbb713..806edaa38821d 100644 --- a/include/clang/AST/StmtIterator.h +++ b/include/clang/AST/StmtIterator.h @@ -33,14 +33,14 @@ protected: DeclGroupMode = 0x2, Flags = 0x3 }; - + union { Stmt **stmt; Decl **DGI; }; uintptr_t RawVAPtr = 0; Decl **DGE; - + StmtIteratorBase(Stmt **s) : stmt(s) {} StmtIteratorBase(const VariableArrayType *t); StmtIteratorBase(Decl **dgi, Decl **dge); diff --git a/include/clang/AST/StmtObjC.h b/include/clang/AST/StmtObjC.h index 571ad76be8a9d..0b2cc78b65be9 100644 --- a/include/clang/AST/StmtObjC.h +++ b/include/clang/AST/StmtObjC.h @@ -81,7 +81,7 @@ public: ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, VarDecl *catchVarDecl, Stmt *atCatchStmt) - : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl), + : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl), Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { } explicit ObjCAtCatchStmt(EmptyShell Empty) : @@ -155,27 +155,27 @@ class ObjCAtTryStmt : public Stmt { private: // The location of the @ in the \@try. SourceLocation AtTryLoc; - + // The number of catch blocks in this statement. unsigned NumCatchStmts : 16; - + // Whether this statement has a \@finally statement. bool HasFinally : 1; - + /// Retrieve the statements that are stored after this \@try statement. /// /// The order of the statements in memory follows the order in the source, /// with the \@try body first, followed by the \@catch statements (if any) /// and, finally, the \@finally (if it exists). Stmt **getStmts() { return reinterpret_cast<Stmt **> (this + 1); } - const Stmt* const *getStmts() const { - return reinterpret_cast<const Stmt * const*> (this + 1); + const Stmt* const *getStmts() const { + return reinterpret_cast<const Stmt * const*> (this + 1); } - + ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt); - + explicit ObjCAtTryStmt(EmptyShell Empty, unsigned NumCatchStmts, bool HasFinally) : Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts), @@ -188,7 +188,7 @@ public: Stmt *atFinallyStmt); static ObjCAtTryStmt *CreateEmpty(const ASTContext &Context, unsigned NumCatchStmts, bool HasFinally); - + /// Retrieve the location of the @ in the \@try. SourceLocation getAtTryLoc() const { return AtTryLoc; } void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; } @@ -201,41 +201,41 @@ public: /// Retrieve the number of \@catch statements in this try-catch-finally /// block. unsigned getNumCatchStmts() const { return NumCatchStmts; } - + /// Retrieve a \@catch statement. const ObjCAtCatchStmt *getCatchStmt(unsigned I) const { assert(I < NumCatchStmts && "Out-of-bounds @catch index"); return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]); } - + /// Retrieve a \@catch statement. ObjCAtCatchStmt *getCatchStmt(unsigned I) { assert(I < NumCatchStmts && "Out-of-bounds @catch index"); return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]); } - + /// Set a particular catch statement. void setCatchStmt(unsigned I, ObjCAtCatchStmt *S) { assert(I < NumCatchStmts && "Out-of-bounds @catch index"); getStmts()[I + 1] = S; } - + /// Retrieve the \@finally statement, if any. const ObjCAtFinallyStmt *getFinallyStmt() const { if (!HasFinally) return nullptr; - + return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]); } ObjCAtFinallyStmt *getFinallyStmt() { if (!HasFinally) return nullptr; - + return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]); } - void setFinallyStmt(Stmt *S) { + void setFinallyStmt(Stmt *S) { assert(HasFinally && "@try does not have a @finally slot!"); - getStmts()[1 + NumCatchStmts] = S; + getStmts()[1 + NumCatchStmts] = S; } SourceLocation getLocStart() const LLVM_READONLY { return AtTryLoc; } diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h index 84a35db938b06..d23375e7606ba 100644 --- a/include/clang/AST/StmtOpenMP.h +++ b/include/clang/AST/StmtOpenMP.h @@ -2319,7 +2319,7 @@ class OMPTargetDataDirective : public OMPExecutableDirective { /// OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc, unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, + : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, OMPD_target_data, StartLoc, EndLoc, NumClauses, 1) {} @@ -2328,7 +2328,7 @@ class OMPTargetDataDirective : public OMPExecutableDirective { /// \param NumClauses Number of clauses. /// explicit OMPTargetDataDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, + : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, OMPD_target_data, SourceLocation(), SourceLocation(), NumClauses, 1) {} @@ -3157,7 +3157,7 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective { unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass, - OMPD_distribute_parallel_for_simd, StartLoc, + OMPD_distribute_parallel_for_simd, StartLoc, EndLoc, CollapsedNum, NumClauses) {} /// Build an empty directive. @@ -3168,7 +3168,7 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective { explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass, - OMPD_distribute_parallel_for_simd, + OMPD_distribute_parallel_for_simd, SourceLocation(), SourceLocation(), CollapsedNum, NumClauses) {} @@ -3232,7 +3232,7 @@ class OMPDistributeSimdDirective final : public OMPLoopDirective { /// \param CollapsedNum Number of collapsed nested loops. /// \param NumClauses Number of clauses. /// - explicit OMPDistributeSimdDirective(unsigned CollapsedNum, + explicit OMPDistributeSimdDirective(unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass, OMPD_distribute_simd, SourceLocation(), @@ -3369,7 +3369,7 @@ class OMPTargetSimdDirective final : public OMPLoopDirective { /// \param NumClauses Number of clauses. /// explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd, + : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd, SourceLocation(),SourceLocation(), CollapsedNum, NumClauses) {} @@ -3425,8 +3425,8 @@ class OMPTeamsDistributeDirective final : public OMPLoopDirective { /// OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, - OMPD_teams_distribute, StartLoc, EndLoc, + : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, + OMPD_teams_distribute, StartLoc, EndLoc, CollapsedNum, NumClauses) {} /// Build an empty directive. @@ -3567,7 +3567,7 @@ class OMPTeamsDistributeParallelForSimdDirective final unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, - OMPD_teams_distribute_parallel_for_simd, StartLoc, + OMPD_teams_distribute_parallel_for_simd, StartLoc, EndLoc, CollapsedNum, NumClauses) {} /// Build an empty directive. @@ -3578,7 +3578,7 @@ class OMPTeamsDistributeParallelForSimdDirective final explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, - OMPD_teams_distribute_parallel_for_simd, + OMPD_teams_distribute_parallel_for_simd, SourceLocation(), SourceLocation(), CollapsedNum, NumClauses) {} diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h index a1920253de78a..6898ef4e1b8a4 100644 --- a/include/clang/AST/TemplateBase.h +++ b/include/clang/AST/TemplateBase.h @@ -252,7 +252,7 @@ public: /// Determine whether this template argument is a pack expansion. bool isPackExpansion() const; - + /// Retrieve the type for a type template argument. QualType getAsType() const { assert(getKind() == Type && "Unexpected kind"); @@ -288,14 +288,14 @@ public: TemplateName getAsTemplateOrTemplatePattern() const { assert((getKind() == Template || getKind() == TemplateExpansion) && "Unexpected kind"); - + return TemplateName::getFromVoidPointer(TemplateArg.Name); } /// Retrieve the number of expansions that a template template argument /// expansion will produce, if known. Optional<unsigned> getNumTemplateExpansions() const; - + /// Retrieve the template argument as an integral value. // FIXME: Provide a way to read the integral data without copying the value. llvm::APSInt getAsIntegral() const { @@ -378,13 +378,13 @@ public: /// Print this template argument to the given output stream. void print(const PrintingPolicy &Policy, raw_ostream &Out) const; - + /// Debugging aid that dumps the template argument. void dump(raw_ostream &Out) const; /// Debugging aid that dumps the template argument to standard error. void dump() const; - + /// Used to insert TemplateArguments into FoldingSets. void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const; }; @@ -411,9 +411,9 @@ public: constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, 0, 0}) {} TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {} - + TemplateArgumentLocInfo(Expr *E) : Expression(E) {} - + TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc) { @@ -432,14 +432,14 @@ public: } NestedNameSpecifierLoc getTemplateQualifierLoc() const { - return NestedNameSpecifierLoc(Template.Qualifier, + return NestedNameSpecifierLoc(Template.Qualifier, Template.QualifierLocData); } - + SourceLocation getTemplateNameLoc() const { return SourceLocation::getFromRawEncoding(Template.TemplateNameLoc); } - + SourceLocation getTemplateEllipsisLoc() const { return SourceLocation::getFromRawEncoding(Template.EllipsisLoc); } @@ -465,10 +465,16 @@ public: TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E) : Argument(Argument), LocInfo(E) { - assert(Argument.getKind() == TemplateArgument::Expression); + + // Permit any kind of template argument that can be represented with an + // expression + assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } - TemplateArgumentLoc(const TemplateArgument &Argument, + TemplateArgumentLoc(const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc = SourceLocation()) @@ -477,13 +483,13 @@ public: assert(Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion); } - + /// - Fetches the primary location of the argument. SourceLocation getLocation() const { if (Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion) return getTemplateNameLoc(); - + return getSourceRange().getBegin(); } @@ -528,13 +534,13 @@ public: Argument.getKind() == TemplateArgument::TemplateExpansion); return LocInfo.getTemplateQualifierLoc(); } - + SourceLocation getTemplateNameLoc() const { assert(Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion); return LocInfo.getTemplateNameLoc(); - } - + } + SourceLocation getTemplateEllipsisLoc() const { assert(Argument.getKind() == TemplateArgument::TemplateExpansion); return LocInfo.getTemplateEllipsisLoc(); @@ -689,7 +695,7 @@ inline const TemplateArgument & assert(Idx < getNumArgs() && "Template argument out of range"); return getArgs()[Idx]; } - + } // namespace clang #endif // LLVM_CLANG_AST_TEMPLATEBASE_H diff --git a/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h index 50549e1a0a6a3..d88d58d0a2aad 100644 --- a/include/clang/AST/TemplateName.h +++ b/include/clang/AST/TemplateName.h @@ -22,7 +22,7 @@ #include <cassert> namespace clang { - + class ASTContext; class DependentTemplateName; class DiagnosticBuilder; @@ -38,7 +38,7 @@ class SubstTemplateTemplateParmStorage; class TemplateArgument; class TemplateDecl; class TemplateTemplateParmDecl; - + /// Implementation class used to describe either a set of overloaded /// template names or an already-substituted template template parameter pack. class UncommonTemplateNameStorage { @@ -52,7 +52,7 @@ protected: struct BitsTag { /// A Kind. unsigned Kind : 2; - + /// The number of stored templates or template arguments, /// depending on which subclass we have. unsigned Size : 30; @@ -62,21 +62,21 @@ protected: struct BitsTag Bits; void *PointerAlignment; }; - + UncommonTemplateNameStorage(Kind kind, unsigned size) { Bits.Kind = kind; Bits.Size = size; } - + public: unsigned size() const { return Bits.Size; } - + OverloadedTemplateStorage *getAsOverloadedStorage() { return Bits.Kind == Overloaded - ? reinterpret_cast<OverloadedTemplateStorage *>(this) + ? reinterpret_cast<OverloadedTemplateStorage *>(this) : nullptr; } - + SubstTemplateTemplateParmStorage *getAsSubstTemplateTemplateParm() { return Bits.Kind == SubstTemplateTemplateParm ? reinterpret_cast<SubstTemplateTemplateParmStorage *>(this) @@ -89,13 +89,13 @@ public: : nullptr; } }; - + /// A structure for storing the information associated with an /// overloaded template name. class OverloadedTemplateStorage : public UncommonTemplateNameStorage { friend class ASTContext; - OverloadedTemplateStorage(unsigned size) + OverloadedTemplateStorage(unsigned size) : UncommonTemplateNameStorage(Overloaded, size) {} NamedDecl **getStorage() { @@ -115,7 +115,7 @@ public: /// A structure for storing an already-substituted template template /// parameter pack. /// -/// This kind of template names occurs when the parameter pack has been +/// This kind of template names occurs when the parameter pack has been /// provided with a template template argument pack in a context where its /// enclosing pack expansion could not be fully expanded. class SubstTemplateTemplateParmPackStorage @@ -123,25 +123,25 @@ class SubstTemplateTemplateParmPackStorage { TemplateTemplateParmDecl *Parameter; const TemplateArgument *Arguments; - + public: SubstTemplateTemplateParmPackStorage(TemplateTemplateParmDecl *Parameter, - unsigned Size, + unsigned Size, const TemplateArgument *Arguments) : UncommonTemplateNameStorage(SubstTemplateTemplateParmPack, Size), Parameter(Parameter), Arguments(Arguments) {} - + /// Retrieve the template template parameter pack being substituted. TemplateTemplateParmDecl *getParameterPack() const { return Parameter; } - + /// Retrieve the template template argument pack with which this /// parameter was substituted. TemplateArgument getArgumentPack() const; - + void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context); - + static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, TemplateTemplateParmDecl *Parameter, @@ -193,11 +193,11 @@ public: /// A set of overloaded template declarations. OverloadedTemplate, - /// A qualified template name, where the qualification is kept + /// A qualified template name, where the qualification is kept /// to describe the source code as written. QualifiedTemplate, - /// A dependent template name that has not been resolved to a + /// A dependent template name that has not been resolved to a /// template (or set of templates). DependentTemplate, @@ -205,7 +205,7 @@ public: /// for some other template name. SubstTemplateTemplateParm, - /// A template template parameter pack that has been substituted for + /// A template template parameter pack that has been substituted for /// a template template argument pack, but has not yet been expanded into /// individual arguments. SubstTemplateTemplateParmPack @@ -221,7 +221,7 @@ public: /// Determine whether this template name is NULL. bool isNull() const; - + // Get the kind of name that is actually stored. NameKind getKind() const; @@ -243,14 +243,14 @@ public: /// refers to a single template, returns NULL. OverloadedTemplateStorage *getAsOverloadedTemplate() const; - /// Retrieve the substituted template template parameter, if + /// 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; - /// Retrieve the substituted template template parameter pack, if + /// Retrieve the substituted template template parameter pack, if /// known. /// /// \returns The storage for the substituted template template parameter pack, @@ -339,7 +339,7 @@ public: TemplateName getReplacement() const { return Replacement; } void Profile(llvm::FoldingSetNodeID &ID); - + static void Profile(llvm::FoldingSetNodeID &ID, TemplateTemplateParmDecl *parameter, TemplateName replacement); @@ -436,7 +436,7 @@ class DependentTemplateName : public llvm::FoldingSetNode { /// /// Only valid when the bit on \c Qualifier is clear. const IdentifierInfo *Identifier; - + /// The overloaded operator name. /// /// Only valid when the bit on \c Qualifier is set. @@ -453,26 +453,26 @@ class DependentTemplateName : public llvm::FoldingSetNode { DependentTemplateName(NestedNameSpecifier *Qualifier, const IdentifierInfo *Identifier) - : Qualifier(Qualifier, false), Identifier(Identifier), + : Qualifier(Qualifier, false), Identifier(Identifier), CanonicalTemplateName(this) {} DependentTemplateName(NestedNameSpecifier *Qualifier, const IdentifierInfo *Identifier, TemplateName Canon) - : Qualifier(Qualifier, false), Identifier(Identifier), + : Qualifier(Qualifier, false), Identifier(Identifier), CanonicalTemplateName(Canon) {} DependentTemplateName(NestedNameSpecifier *Qualifier, OverloadedOperatorKind Operator) - : Qualifier(Qualifier, true), Operator(Operator), + : Qualifier(Qualifier, true), Operator(Operator), CanonicalTemplateName(this) {} - + DependentTemplateName(NestedNameSpecifier *Qualifier, OverloadedOperatorKind Operator, TemplateName Canon) - : Qualifier(Qualifier, true), Operator(Operator), + : Qualifier(Qualifier, true), Operator(Operator), CanonicalTemplateName(Canon) {} - + public: /// Return the nested name specifier that qualifies this name. NestedNameSpecifier *getQualifier() const { return Qualifier.getPointer(); } @@ -481,22 +481,22 @@ public: bool isIdentifier() const { return !Qualifier.getInt(); } /// Returns the identifier to which this template name refers. - const IdentifierInfo *getIdentifier() const { + const IdentifierInfo *getIdentifier() const { assert(isIdentifier() && "Template name isn't an identifier?"); return Identifier; } - + /// Determine whether this template name refers to an overloaded /// operator. bool isOverloadedOperator() const { return Qualifier.getInt(); } - + /// Return the overloaded operator to which this template name refers. - OverloadedOperatorKind getOperator() const { + OverloadedOperatorKind getOperator() const { assert(isOverloadedOperator() && "Template name isn't an overloaded operator?"); - return Operator; + return Operator; } - + void Profile(llvm::FoldingSetNodeID &ID) { if (isIdentifier()) Profile(ID, getQualifier(), getIdentifier()); diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index c692707847a69..9a8dd6faff31c 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -992,7 +992,7 @@ public: static std::string getAsString(const Type *ty, Qualifiers qs, const PrintingPolicy &Policy); - std::string getAsString() const; + std::string getAsString() const; std::string getAsString(const PrintingPolicy &Policy) const; void print(raw_ostream &OS, const PrintingPolicy &Policy, @@ -2017,6 +2017,9 @@ public: /// type of a class template or class template partial specialization. CXXRecordDecl *getAsCXXRecordDecl() const; + /// Retrieves the RecordDecl this type refers to. + RecordDecl *getAsRecordDecl() const; + /// Retrieves the TagDecl that this type refers to, either /// because the type is a TagType or because it is the injected-class-name /// type of a class template or class template partial specialization. @@ -2926,7 +2929,7 @@ public: }; /// Represents an extended address space qualifier where the input address space -/// value is dependent. Non-dependent address spaces are not represented with a +/// value is dependent. Non-dependent address spaces are not represented with a /// special Type subclass; they are stored on an ExtQuals node as part of a QualType. /// /// For example: @@ -2945,7 +2948,7 @@ class DependentAddressSpaceType : public Type, public llvm::FoldingSetNode { SourceLocation loc; DependentAddressSpaceType(const ASTContext &Context, QualType PointeeType, - QualType can, Expr *AddrSpaceExpr, + QualType can, Expr *AddrSpaceExpr, SourceLocation loc); public: @@ -3264,7 +3267,7 @@ public: Bits = ((unsigned)cc) | (noReturn ? NoReturnMask : 0) | (producesResult ? ProducesResultMask : 0) | (noCallerSavedRegs ? NoCallerSavedRegsMask : 0) | - (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) | + (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) | (NoCfCheck ? NoCfCheckMask : 0); } @@ -4234,6 +4237,7 @@ public: attr_null_unspecified, attr_objc_kindof, attr_objc_inert_unsafe_unretained, + attr_lifetimebound, }; private: @@ -5336,7 +5340,7 @@ public: /// with base C and no protocols. /// /// 'C<P>' is an unspecialized ObjCObjectType with base C and protocol list [P]. -/// 'C<C*>' is a specialized ObjCObjectType with type arguments 'C*' and no +/// 'C<C*>' is a specialized ObjCObjectType with type arguments 'C*' and no /// protocol list. /// 'C<C*><P>' is a specialized ObjCObjectType with base C, type arguments 'C*', /// and protocol list [P]. @@ -5968,7 +5972,7 @@ inline QualType QualType::getUnqualifiedType() const { return QualType(getSplitUnqualifiedTypeImpl(*this).Ty, 0); } - + inline SplitQualType QualType::getSplitUnqualifiedType() const { if (!getTypePtr()->getCanonicalTypeInternal().hasLocalQualifiers()) return split(); @@ -6443,7 +6447,7 @@ inline bool Type::isIntegralOrEnumerationType() const { if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) return IsEnumDeclComplete(ET->getDecl()); - return false; + return false; } inline bool Type::isBooleanType() const { diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 25cd014efe5f4..c69f4aa4abcf1 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -992,7 +992,7 @@ class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, return (TypeSourceInfo**)this->getExtraLocalData(); } - // SourceLocations are stored after the type argument information, one for + // SourceLocations are stored after the type argument information, one for // each Protocol. SourceLocation *getProtocolLocArray() const { return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs()); @@ -1131,11 +1131,11 @@ public: void setNameLoc(SourceLocation Loc) { getLocalData()->NameLoc = Loc; } - + SourceRange getLocalSourceRange() const { return SourceRange(getNameLoc(), getNameEndLoc()); } - + SourceLocation getNameEndLoc() const { return getLocalData()->NameEndLoc; } @@ -1766,10 +1766,10 @@ public: return range; } - /// Returns the type before the address space attribute application - /// area. + /// Returns the type before the address space attribute application + /// area. /// int * __attribute__((address_space(11))) * - /// ^ ^ + /// ^ ^ QualType getInnerType() const { return this->getTypePtr()->getPointeeType(); } diff --git a/include/clang/AST/TypeOrdering.h b/include/clang/AST/TypeOrdering.h index d29dd6d601247..7ea78071f5cf0 100644 --- a/include/clang/AST/TypeOrdering.h +++ b/include/clang/AST/TypeOrdering.h @@ -56,20 +56,20 @@ namespace llvm { }; template<> struct DenseMapInfo<clang::CanQualType> { - static inline clang::CanQualType getEmptyKey() { - return clang::CanQualType(); + static inline clang::CanQualType getEmptyKey() { + return clang::CanQualType(); } - + static inline clang::CanQualType getTombstoneKey() { using clang::CanQualType; return CanQualType::getFromOpaquePtr(reinterpret_cast<clang::Type *>(-1)); } - + static unsigned getHashValue(clang::CanQualType Val) { return (unsigned)((uintptr_t)Val.getAsOpaquePtr()) ^ ((unsigned)((uintptr_t)Val.getAsOpaquePtr() >> 9)); } - + static bool isEqual(clang::CanQualType LHS, clang::CanQualType RHS) { return LHS == RHS; } diff --git a/include/clang/AST/UnresolvedSet.h b/include/clang/AST/UnresolvedSet.h index d6b01cb573347..b62e9f138bb64 100644 --- a/include/clang/AST/UnresolvedSet.h +++ b/include/clang/AST/UnresolvedSet.h @@ -146,7 +146,7 @@ template <unsigned InlineCapacity> class UnresolvedSet : SmallVector<DeclAccessPair, InlineCapacity> Decls; }; - + } // namespace clang #endif // LLVM_CLANG_AST_UNRESOLVEDSET_H diff --git a/include/clang/AST/VTTBuilder.h b/include/clang/AST/VTTBuilder.h index 84661c8cc7f24..3a8a6a9c15f0e 100644 --- a/include/clang/AST/VTTBuilder.h +++ b/include/clang/AST/VTTBuilder.h @@ -76,15 +76,15 @@ class VTTBuilder { const CXXRecordDecl *MostDerivedClass; using VTTVTablesVectorTy = SmallVector<VTTVTable, 64>; - + /// The VTT vtables. VTTVTablesVectorTy VTTVTables; - + using VTTComponentsVectorTy = SmallVector<VTTComponent, 64>; - + /// The VTT components. VTTComponentsVectorTy VTTComponents; - + /// The AST record layout of the most derived class. const ASTRecordLayout &MostDerivedClassLayout; @@ -105,35 +105,35 @@ class VTTBuilder { /// Add a vtable pointer to the VTT currently being built. void AddVTablePointer(BaseSubobject Base, uint64_t VTableIndex, const CXXRecordDecl *VTableClass); - + /// Lay out the secondary VTTs of the given base subobject. void LayoutSecondaryVTTs(BaseSubobject Base); - + /// Lay out the secondary virtual pointers for the given base /// subobject. /// /// \param BaseIsMorallyVirtual whether the base subobject is a virtual base /// or a direct or indirect base of a virtual base. - void LayoutSecondaryVirtualPointers(BaseSubobject Base, + void LayoutSecondaryVirtualPointers(BaseSubobject Base, bool BaseIsMorallyVirtual, uint64_t VTableIndex, const CXXRecordDecl *VTableClass, VisitedVirtualBasesSetTy &VBases); - + /// Lay out the secondary virtual pointers for the given base /// subobject. - void LayoutSecondaryVirtualPointers(BaseSubobject Base, + void LayoutSecondaryVirtualPointers(BaseSubobject Base, uint64_t VTableIndex); /// Lay out the VTTs for the virtual base classes of the given /// record declaration. void LayoutVirtualVTTs(const CXXRecordDecl *RD, VisitedVirtualBasesSetTy &VBases); - + /// Lay out the VTT for the given subobject, including any /// secondary VTTs, secondary virtual pointers and virtual VTTs. void LayoutVTT(BaseSubobject Base, bool BaseIsVirtual); - + public: VTTBuilder(ASTContext &Ctx, const CXXRecordDecl *MostDerivedClass, bool GenerateDefinition); @@ -142,17 +142,17 @@ public: const VTTComponentsVectorTy &getVTTComponents() const { return VTTComponents; } - + // Returns a reference to the VTT vtables. const VTTVTablesVectorTy &getVTTVTables() const { return VTTVTables; } - + /// Returns a reference to the sub-VTT indices. const llvm::DenseMap<BaseSubobject, uint64_t> &getSubVTTIndicies() const { return SubVTTIndicies; } - + /// Returns a reference to the secondary virtual pointer indices. const llvm::DenseMap<BaseSubobject, uint64_t> & getSecondaryVirtualPointerIndices() const { diff --git a/include/clang/AST/VTableBuilder.h b/include/clang/AST/VTableBuilder.h index 643103916149b..4a779db01ff8b 100644 --- a/include/clang/AST/VTableBuilder.h +++ b/include/clang/AST/VTableBuilder.h @@ -394,7 +394,7 @@ public: /// Return the offset in chars (relative to the vtable address point) where /// the offset of the virtual base that contains the given base is stored, - /// otherwise, if no virtual base contains the given class, return 0. + /// otherwise, if no virtual base contains the given class, return 0. /// /// Base must be a virtual base class or an unambiguous base. CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, |