From 993e3aa6b96adce7b48000b9ba4ff27266c87104 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 14 Dec 2016 00:03:17 +0000 Subject: Remove custom handling of array copies in lambda by-value array capture and copy constructors of classes with array members, instead using ArrayInitLoopExpr to represent the initialization loop. This exposed a bug in the static analyzer where it was unable to differentiate between zero-initialized and unknown array values, which has also been fixed here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289618 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclCXX.h | 59 +++++++-------------------------------------- 1 file changed, 9 insertions(+), 50 deletions(-) (limited to 'include/clang/AST/DeclCXX.h') diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index b40ca28cef..46434c4c7b 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1928,8 +1928,7 @@ public: /// B(A& a) : A(a), f(3.14159) { } /// }; /// \endcode -class CXXCtorInitializer final - : private llvm::TrailingObjects { +class CXXCtorInitializer final { /// \brief Either the base class name/delegating constructor type (stored as /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field /// (IndirectFieldDecl*) being initialized. @@ -1967,14 +1966,8 @@ class CXXCtorInitializer final unsigned IsWritten : 1; /// If IsWritten is true, then this number keeps track of the textual order - /// of this initializer in the original sources, counting from 0; otherwise, - /// it stores the number of array index variables stored after this object - /// in memory. - unsigned SourceOrderOrNumArrayIndices : 13; - - CXXCtorInitializer(ASTContext &Context, FieldDecl *Member, - SourceLocation MemberLoc, SourceLocation L, Expr *Init, - SourceLocation R, VarDecl **Indices, unsigned NumIndices); + /// of this initializer in the original sources, counting from 0. + unsigned SourceOrder : 13; public: /// \brief Creates a new base-class initializer. @@ -2000,13 +1993,6 @@ public: CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, SourceLocation L, Expr *Init, SourceLocation R); - /// \brief Creates a new member initializer that optionally contains - /// array indices used to describe an elementwise initialization. - static CXXCtorInitializer *Create(ASTContext &Context, FieldDecl *Member, - SourceLocation MemberLoc, SourceLocation L, - Expr *Init, SourceLocation R, - VarDecl **Indices, unsigned NumIndices); - /// \brief Determine whether this initializer is initializing a base class. bool isBaseInitializer() const { return Initializee.is() && !IsDelegating; @@ -2111,7 +2097,7 @@ public: /// \brief Return the source position of the initializer, counting from 0. /// If the initializer was implicit, -1 is returned. int getSourceOrder() const { - return IsWritten ? static_cast(SourceOrderOrNumArrayIndices) : -1; + return IsWritten ? static_cast(SourceOrder) : -1; } /// \brief Set the source order of this initializer. @@ -2121,49 +2107,22 @@ public: /// /// This assumes that the initializer was written in the source code, and /// ensures that isWritten() returns true. - void setSourceOrder(int pos) { + void setSourceOrder(int Pos) { assert(!IsWritten && + "setSourceOrder() used on implicit initializer"); + assert(SourceOrder == 0 && "calling twice setSourceOrder() on the same initializer"); - assert(SourceOrderOrNumArrayIndices == 0 && - "setSourceOrder() used when there are implicit array indices"); - assert(pos >= 0 && + assert(Pos >= 0 && "setSourceOrder() used to make an initializer implicit"); IsWritten = true; - SourceOrderOrNumArrayIndices = static_cast(pos); + SourceOrder = static_cast(Pos); } SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } - /// \brief Determine the number of implicit array indices used while - /// described an array member initialization. - unsigned getNumArrayIndices() const { - return IsWritten ? 0 : SourceOrderOrNumArrayIndices; - } - - /// \brief Retrieve a particular array index variable used to - /// describe an array member initialization. - VarDecl *getArrayIndex(unsigned I) { - assert(I < getNumArrayIndices() && "Out of bounds member array index"); - return getTrailingObjects()[I]; - } - const VarDecl *getArrayIndex(unsigned I) const { - assert(I < getNumArrayIndices() && "Out of bounds member array index"); - return getTrailingObjects()[I]; - } - void setArrayIndex(unsigned I, VarDecl *Index) { - assert(I < getNumArrayIndices() && "Out of bounds member array index"); - getTrailingObjects()[I] = Index; - } - ArrayRef getArrayIndices() { - return llvm::makeArrayRef(getTrailingObjects(), - getNumArrayIndices()); - } - /// \brief Get the initializer. Expr *getInit() const { return static_cast(Init); } - - friend TrailingObjects; }; /// Description of a constructor that was inherited from a base class. -- cgit v1.2.3