diff options
36 files changed, 196 insertions, 167 deletions
diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h index b515b6e04a..57d1e2acd0 100644 --- a/include/clang/AST/DataRecursiveASTVisitor.h +++ b/include/clang/AST/DataRecursiveASTVisitor.h @@ -244,7 +244,7 @@ public: /// \brief Recursively visit a lambda capture. /// /// \returns false if the visitation was terminated early, true otherwise. - bool TraverseLambdaCapture(LambdaExpr::Capture C); + bool TraverseLambdaCapture(LambdaCapture C); // ---- Methods on Attrs ---- @@ -783,8 +783,8 @@ bool DataRecursiveASTVisitor<Derived>::TraverseConstructorInitializer( return true; } -template<typename Derived> -bool DataRecursiveASTVisitor<Derived>::TraverseLambdaCapture(LambdaExpr::Capture C){ +template <typename Derived> +bool DataRecursiveASTVisitor<Derived>::TraverseLambdaCapture(LambdaCapture C) { return true; } diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index d18653ef9a..91b1b23e22 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -21,10 +21,10 @@ #include "clang/AST/Redeclarable.h" #include "clang/AST/Type.h" #include "clang/Basic/Linkage.h" +#include "clang/Basic/OperatorKinds.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/raw_ostream.h" namespace clang { struct ASTTemplateArgumentListInfo; diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index eb11d8bbec..b832123719 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -16,7 +16,6 @@ #include "clang/AST/AttrIterator.h" #include "clang/AST/DeclarationName.h" -#include "clang/Basic/Linkage.h" #include "clang/Basic/Specifiers.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/iterator_range.h" @@ -34,6 +33,7 @@ class DependentDiagnostic; class EnumDecl; class FunctionDecl; class FunctionType; +enum Linkage : unsigned char; class LinkageComputer; class LinkageSpecDecl; class Module; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 57c3b6fcb4..8f0b36cb6b 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -20,11 +20,9 @@ #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" -#include "clang/AST/ExprCXX.h" -#include "clang/AST/TypeLoc.h" +#include "clang/AST/LambdaCapture.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Compiler.h" namespace clang { @@ -500,7 +498,7 @@ class CXXRecordDecl : public RecordDecl { /// \brief Describes a C++ closure type (generated by a lambda expression). struct LambdaDefinitionData : public DefinitionData { - typedef LambdaExpr::Capture Capture; + typedef LambdaCapture Capture; LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, bool Dependent, bool IsGeneric, @@ -1019,7 +1017,7 @@ public: void getCaptureFields(llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures, FieldDecl *&ThisCapture) const; - typedef const LambdaExpr::Capture* capture_const_iterator; + typedef const LambdaCapture *capture_const_iterator; typedef llvm::iterator_range<capture_const_iterator> capture_const_range; capture_const_range captures() const { @@ -1943,7 +1941,7 @@ public: /// In-class member initializers (also known as "non-static data member /// initializations", NSDMIs) were introduced in C++11. bool isInClassMemberInitializer() const { - return isa<CXXDefaultInitExpr>(Init); + return Init->getStmtClass() == Stmt::CXXDefaultInitExprClass; } /// \brief Determine whether this initializer is creating a delegating diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index cd1aa717b4..97741c1c37 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -17,6 +17,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" +#include "clang/AST/TypeLoc.h" #include "llvm/Support/Compiler.h" namespace clang { diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index ab1575c220..08f45fcdcf 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -29,6 +29,7 @@ namespace clang { class DeclarationNameExtra; class IdentifierInfo; class MultiKeywordSelector; + enum OverloadedOperatorKind : unsigned char; class QualType; class Type; class TypeSourceInfo; diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 3cc00480b9..d641442f0a 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -20,7 +20,7 @@ #include "clang/AST/TemplateBase.h" #include "clang/AST/UnresolvedSet.h" #include "clang/Basic/ExpressionTraits.h" -#include "clang/Basic/Lambda.h" +#include "clang/AST/LambdaCapture.h" #include "clang/Basic/TypeTraits.h" #include "llvm/Support/Compiler.h" @@ -1310,18 +1310,6 @@ public: /// includes an initializing expression (rather than capturing a variable), /// and which can never occur implicitly. class LambdaExpr : public Expr { - enum { - /// \brief Flag used by the Capture class to indicate that the given - /// capture was implicit. - Capture_Implicit = 0x01, - - /// \brief Flag used by the Capture class to indicate that the - /// given capture was by-copy. - /// - /// This includes the case of a non-reference init-capture. - Capture_ByCopy = 0x02 - }; - /// \brief The source range that covers the lambda introducer ([...]). SourceRange IntroducerRange; @@ -1360,93 +1348,8 @@ class LambdaExpr : public Expr { // expression, along with the index variables used to initialize by-copy // array captures. -public: - /// \brief Describes the capture of a variable or of \c this, or of a - /// C++1y init-capture. - class Capture { - llvm::PointerIntPair<Decl *, 2> DeclAndBits; - SourceLocation Loc; - SourceLocation EllipsisLoc; - - friend class ASTStmtReader; - friend class ASTStmtWriter; - - public: - /// \brief Create a new capture of a variable or of \c this. - /// - /// \param Loc The source location associated with this capture. - /// - /// \param Kind The kind of capture (this, byref, bycopy), which must - /// not be init-capture. - /// - /// \param Implicit Whether the capture was implicit or explicit. - /// - /// \param Var The local variable being captured, or null if capturing - /// \c this. - /// - /// \param EllipsisLoc The location of the ellipsis (...) for a - /// capture that is a pack expansion, or an invalid source - /// location to indicate that this is not a pack expansion. - Capture(SourceLocation Loc, bool Implicit, - LambdaCaptureKind Kind, VarDecl *Var = nullptr, - SourceLocation EllipsisLoc = SourceLocation()); - - /// \brief Determine the kind of capture. - LambdaCaptureKind getCaptureKind() const; - - /// \brief Determine whether this capture handles the C++ \c this - /// pointer. - bool capturesThis() const { return DeclAndBits.getPointer() == nullptr; } - - /// \brief Determine whether this capture handles a variable. - bool capturesVariable() const { - return dyn_cast_or_null<VarDecl>(DeclAndBits.getPointer()); - } - - /// \brief Determine whether this is an init-capture. - bool isInitCapture() const { - return capturesVariable() && getCapturedVar()->isInitCapture(); - } - - /// \brief Retrieve the declaration of the local variable being - /// captured. - /// - /// This operation is only valid if this capture is a variable capture - /// (other than a capture of \c this). - VarDecl *getCapturedVar() const { - assert(capturesVariable() && "No variable available for 'this' capture"); - return cast<VarDecl>(DeclAndBits.getPointer()); - } + typedef LambdaCapture Capture; - /// \brief Determine whether this was an implicit capture (not - /// written between the square brackets introducing the lambda). - bool isImplicit() const { return DeclAndBits.getInt() & Capture_Implicit; } - - /// \brief Determine whether this was an explicit capture (written - /// between the square brackets introducing the lambda). - bool isExplicit() const { return !isImplicit(); } - - /// \brief Retrieve the source location of the capture. - /// - /// For an explicit capture, this returns the location of the - /// explicit capture in the source. For an implicit capture, this - /// returns the location at which the variable or \c this was first - /// used. - SourceLocation getLocation() const { return Loc; } - - /// \brief Determine whether this capture is a pack expansion, - /// which captures a function parameter pack. - bool isPackExpansion() const { return EllipsisLoc.isValid(); } - - /// \brief Retrieve the location of the ellipsis for a capture - /// that is a pack expansion. - SourceLocation getEllipsisLoc() const { - assert(isPackExpansion() && "No ellipsis location for a non-expansion"); - return EllipsisLoc; - } - }; - -private: /// \brief Construct a lambda expression. LambdaExpr(QualType T, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, diff --git a/include/clang/AST/LambdaCapture.h b/include/clang/AST/LambdaCapture.h new file mode 100644 index 0000000000..8633c97965 --- /dev/null +++ b/include/clang/AST/LambdaCapture.h @@ -0,0 +1,123 @@ +//===--- LambdaCapture.h - Types for C++ Lambda Captures --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief Defines the LambdaCapture class. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_LAMBDACAPTURE_H +#define LLVM_CLANG_AST_LAMBDACAPTURE_H + +#include "clang/AST/Decl.h" +#include "clang/Basic/Lambda.h" +#include "llvm/ADT/PointerIntPair.h" + +namespace clang { + +/// \brief Describes the capture of a variable or of \c this, or of a +/// C++1y init-capture. +class LambdaCapture { + enum { + /// \brief Flag used by the Capture class to indicate that the given + /// capture was implicit. + Capture_Implicit = 0x01, + + /// \brief Flag used by the Capture class to indicate that the + /// given capture was by-copy. + /// + /// This includes the case of a non-reference init-capture. + Capture_ByCopy = 0x02 + }; + + llvm::PointerIntPair<Decl *, 2> DeclAndBits; + SourceLocation Loc; + SourceLocation EllipsisLoc; + + friend class ASTStmtReader; + friend class ASTStmtWriter; + +public: + /// \brief Create a new capture of a variable or of \c this. + /// + /// \param Loc The source location associated with this capture. + /// + /// \param Kind The kind of capture (this, byref, bycopy), which must + /// not be init-capture. + /// + /// \param Implicit Whether the capture was implicit or explicit. + /// + /// \param Var The local variable being captured, or null if capturing + /// \c this. + /// + /// \param EllipsisLoc The location of the ellipsis (...) for a + /// capture that is a pack expansion, or an invalid source + /// location to indicate that this is not a pack expansion. + LambdaCapture(SourceLocation Loc, bool Implicit, LambdaCaptureKind Kind, + VarDecl *Var = nullptr, + SourceLocation EllipsisLoc = SourceLocation()); + + /// \brief Determine the kind of capture. + LambdaCaptureKind getCaptureKind() const; + + /// \brief Determine whether this capture handles the C++ \c this + /// pointer. + bool capturesThis() const { return DeclAndBits.getPointer() == nullptr; } + + /// \brief Determine whether this capture handles a variable. + bool capturesVariable() const { + return dyn_cast_or_null<VarDecl>(DeclAndBits.getPointer()); + } + + /// \brief Determine whether this is an init-capture. + bool isInitCapture() const { + return capturesVariable() && getCapturedVar()->isInitCapture(); + } + + /// \brief Retrieve the declaration of the local variable being + /// captured. + /// + /// This operation is only valid if this capture is a variable capture + /// (other than a capture of \c this). + VarDecl *getCapturedVar() const { + assert(capturesVariable() && "No variable available for 'this' capture"); + return cast<VarDecl>(DeclAndBits.getPointer()); + } + + /// \brief Determine whether this was an implicit capture (not + /// written between the square brackets introducing the lambda). + bool isImplicit() const { return DeclAndBits.getInt() & Capture_Implicit; } + + /// \brief Determine whether this was an explicit capture (written + /// between the square brackets introducing the lambda). + bool isExplicit() const { return !isImplicit(); } + + /// \brief Retrieve the source location of the capture. + /// + /// For an explicit capture, this returns the location of the + /// explicit capture in the source. For an implicit capture, this + /// returns the location at which the variable or \c this was first + /// used. + SourceLocation getLocation() const { return Loc; } + + /// \brief Determine whether this capture is a pack expansion, + /// which captures a function parameter pack. + bool isPackExpansion() const { return EllipsisLoc.isValid(); } + + /// \brief Retrieve the location of the ellipsis for a capture + /// that is a pack expansion. + SourceLocation getEllipsisLoc() const { + assert(isPackExpansion() && "No ellipsis location for a non-expansion"); + return EllipsisLoc; + } +}; + +} // end namespace clang + +#endif // LLVM_CLANG_AST_LAMBDACAPTURE_H diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 31afa138d3..874853276b 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -252,7 +252,7 @@ public: /// \brief Recursively visit a lambda capture. /// /// \returns false if the visitation was terminated early, true otherwise. - bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaExpr::Capture *C); + bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C); /// \brief Recursively visit the body of a lambda expression. /// @@ -856,7 +856,7 @@ bool RecursiveASTVisitor<Derived>::TraverseConstructorInitializer( template<typename Derived> bool RecursiveASTVisitor<Derived>::TraverseLambdaCapture( - LambdaExpr *LE, const LambdaExpr::Capture *C) { + LambdaExpr *LE, const LambdaCapture *C) { if (C->isInitCapture()) TRY_TO(TraverseDecl(C->getCapturedVar())); return true; diff --git a/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h index f2eab057e2..8350ccd548 100644 --- a/include/clang/AST/TemplateName.h +++ b/include/clang/AST/TemplateName.h @@ -15,7 +15,6 @@ #define LLVM_CLANG_AST_TEMPLATENAME_H #include "clang/Basic/LLVM.h" -#include "clang/Basic/OperatorKinds.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerUnion.h" @@ -25,13 +24,14 @@ class ASTContext; class DependentTemplateName; class DiagnosticBuilder; class IdentifierInfo; +class NamedDecl; class NestedNameSpecifier; +enum OverloadedOperatorKind : unsigned char; class OverloadedTemplateStorage; struct PrintingPolicy; class QualifiedTemplateName; -class NamedDecl; -class SubstTemplateTemplateParmStorage; class SubstTemplateTemplateParmPackStorage; +class SubstTemplateTemplateParmStorage; class TemplateArgument; class TemplateDecl; class TemplateTemplateParmDecl; diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index c51fc15c4a..36866e72cb 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -18,13 +18,12 @@ #include "clang/AST/TemplateName.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/ExceptionSpecificationType.h" -#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/Linkage.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/Specifiers.h" #include "clang/Basic/Visibility.h" -#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/APInt.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/iterator_range.h" #include "llvm/ADT/Optional.h" diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 7739631f63..ebc044ce88 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -16,7 +16,6 @@ #define LLVM_CLANG_DIAGNOSTIC_H #include "clang/Basic/DiagnosticIDs.h" -#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" @@ -26,14 +25,15 @@ #include <vector> namespace clang { - class DiagnosticConsumer; + class DeclContext; class DiagnosticBuilder; + class DiagnosticConsumer; + class DiagnosticErrorTrap; class DiagnosticOptions; class IdentifierInfo; - class DeclContext; class LangOptions; + enum OverloadsShown : unsigned; class Preprocessor; - class DiagnosticErrorTrap; class StoredDiagnostic; namespace tok { enum TokenKind : unsigned short; diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h index 2fba3844a0..a9c8cf5fc2 100644 --- a/include/clang/Basic/DiagnosticOptions.h +++ b/include/clang/Basic/DiagnosticOptions.h @@ -19,7 +19,7 @@ namespace clang { /// \brief Specifies which overload candidates to display when overload /// resolution fails. -enum OverloadsShown { +enum OverloadsShown : unsigned { Ovl_All, ///< Show all overloads. Ovl_Best ///< Show just the "best" overload candidates. }; diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index f65ba86354..0c278a17a3 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -17,12 +17,9 @@ #define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H #include "clang/Basic/LLVM.h" -#include "clang/Basic/OperatorKinds.h" #include "clang/Basic/TokenKinds.h" -#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/PointerLikeTypeTraits.h" #include <cassert> #include <string> @@ -814,6 +811,8 @@ struct DenseMapInfo<clang::Selector> { template <> struct isPodLike<clang::Selector> { static const bool value = true; }; +template <typename T> class PointerLikeTypeTraits; + template<> class PointerLikeTypeTraits<clang::Selector> { public: diff --git a/include/clang/Basic/Linkage.h b/include/clang/Basic/Linkage.h index e19a9f8a1f..f3b47699cf 100644 --- a/include/clang/Basic/Linkage.h +++ b/include/clang/Basic/Linkage.h @@ -18,7 +18,7 @@ namespace clang { /// \brief Describes the different kinds of linkage /// (C++ [basic.link], C99 6.2.2) that an entity may have. -enum Linkage { +enum Linkage : unsigned char { /// \brief No linkage, which means that the entity is unique and /// can only be referred to from within its scope. NoLinkage = 0, diff --git a/include/clang/Basic/OperatorKinds.h b/include/clang/Basic/OperatorKinds.h index 2ceab9cbab..8064fe0519 100644 --- a/include/clang/Basic/OperatorKinds.h +++ b/include/clang/Basic/OperatorKinds.h @@ -19,7 +19,7 @@ namespace clang { /// \brief Enumeration specifying the different kinds of C++ overloaded /// operators. -enum OverloadedOperatorKind { +enum OverloadedOperatorKind : unsigned char { OO_None, ///< Not an overloaded operator #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ OO_##Name, diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index e57754d770..845e751351 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -2153,25 +2153,23 @@ private: SourceLocation LastLocation; }; -/// \brief An individual capture in a lambda introducer. -struct LambdaCapture { - LambdaCaptureKind Kind; - SourceLocation Loc; - IdentifierInfo *Id; - SourceLocation EllipsisLoc; - ExprResult Init; - ParsedType InitCaptureType; - LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, - IdentifierInfo* Id, - SourceLocation EllipsisLoc, - ExprResult Init, ParsedType InitCaptureType) - : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc), Init(Init), - InitCaptureType(InitCaptureType) - {} -}; - /// \brief Represents a complete lambda introducer. struct LambdaIntroducer { + /// \brief An individual capture in a lambda introducer. + struct LambdaCapture { + LambdaCaptureKind Kind; + SourceLocation Loc; + IdentifierInfo *Id; + SourceLocation EllipsisLoc; + ExprResult Init; + ParsedType InitCaptureType; + LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, + IdentifierInfo *Id, SourceLocation EllipsisLoc, + ExprResult Init, ParsedType InitCaptureType) + : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc), Init(Init), + InitCaptureType(InitCaptureType) {} + }; + SourceRange Range; SourceLocation DefaultLoc; LambdaCaptureDefault Default; diff --git a/include/clang/Serialization/ASTDeserializationListener.h b/include/clang/Serialization/ASTDeserializationListener.h index 1f61c8454b..180f554daf 100644 --- a/include/clang/Serialization/ASTDeserializationListener.h +++ b/include/clang/Serialization/ASTDeserializationListener.h @@ -15,6 +15,7 @@ #ifndef LLVM_CLANG_FRONTEND_AST_DESERIALIZATION_LISTENER_H #define LLVM_CLANG_FRONTEND_AST_DESERIALIZATION_LISTENER_H +#include "clang/Basic/IdentifierTable.h" #include "clang/Serialization/ASTBitCodes.h" namespace clang { diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 20d240b9e6..8d183b2534 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -1011,7 +1011,7 @@ void CXXRecordDecl::getCaptureFields( LambdaDefinitionData &Lambda = getLambdaData(); RecordDecl::field_iterator Field = field_begin(); - for (LambdaExpr::Capture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures; + for (const LambdaCapture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures; C != CEnd; ++C, ++Field) { if (C->capturesThis()) ThisCapture = *Field; diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 0181235bff..04f4d40c77 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -884,7 +884,7 @@ CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC, } } -LambdaExpr::Capture::Capture(SourceLocation Loc, bool Implicit, +LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit, LambdaCaptureKind Kind, VarDecl *Var, SourceLocation EllipsisLoc) : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) @@ -908,7 +908,7 @@ LambdaExpr::Capture::Capture(SourceLocation Loc, bool Implicit, DeclAndBits.setInt(Bits); } -LambdaCaptureKind LambdaExpr::Capture::getCaptureKind() const { +LambdaCaptureKind LambdaCapture::getCaptureKind() const { Decl *D = DeclAndBits.getPointer(); if (!D) return LCK_This; diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 943d2060b2..2198459963 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -12,11 +12,13 @@ // //===----------------------------------------------------------------------===// -#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/CharInfo.h" +#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/OperatorKinds.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include <cstdio> diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c4c2644386..4279e4985e 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -830,7 +830,7 @@ CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, unsigned fieldno = 0; for (CXXRecordDecl::capture_const_iterator I = CXXDecl->captures_begin(), E = CXXDecl->captures_end(); I != E; ++I, ++Field, ++fieldno) { - const LambdaExpr::Capture C = *I; + const LambdaCapture &C = *I; if (C.capturesVariable()) { VarDecl *V = C.getCapturedVar(); llvm::DIFile VUnit = getOrCreateFile(C.getLocation()); diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index dcbc950265..30dc88994e 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -18,6 +18,7 @@ #include "UnwrappedLineParser.h" #include "WhitespaceManager.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/SourceManager.h" #include "clang/Format/Format.h" #include "clang/Lex/Lexer.h" diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 77f8a87ca9..7533b39ce6 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -21,6 +21,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtCXX.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/TargetInfo.h" diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 4b23c37a63..7e34b642ad 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -4327,15 +4327,13 @@ void Sema::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, // Note what has already been captured. llvm::SmallPtrSet<IdentifierInfo *, 4> Known; bool IncludedThis = false; - for (SmallVectorImpl<LambdaCapture>::iterator C = Intro.Captures.begin(), - CEnd = Intro.Captures.end(); - C != CEnd; ++C) { - if (C->Kind == LCK_This) { + for (const auto &C : Intro.Captures) { + if (C.Kind == LCK_This) { IncludedThis = true; continue; } - Known.insert(C->Id); + Known.insert(C.Id); } // Look for other capturable variables. diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index c33408f193..5ca5a8fc26 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -18,6 +18,7 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/Mangle.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/SourceManager.h" diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index d75cf4b2bb..7c4f60e511 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -957,10 +957,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // Handle explicit captures. SourceLocation PrevCaptureLoc = Intro.Default == LCD_None? Intro.Range.getBegin() : Intro.DefaultLoc; - for (SmallVectorImpl<LambdaCapture>::const_iterator - C = Intro.Captures.begin(), - E = Intro.Captures.end(); - C != E; + for (auto C = Intro.Captures.begin(), E = Intro.Captures.end(); C != E; PrevCaptureLoc = C->Loc, ++C) { if (C->Kind == LCK_This) { // C++11 [expr.prim.lambda]p8: @@ -1379,7 +1376,7 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, Scope *CurScope, bool IsInstantiation) { // Collect information from the lambda scope. - SmallVector<LambdaExpr::Capture, 4> Captures; + SmallVector<LambdaCapture, 4> Captures; SmallVector<Expr *, 4> CaptureInits; LambdaCaptureDefault CaptureDefault; SourceLocation CaptureDefaultLoc; @@ -1412,9 +1409,8 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, // Handle 'this' capture. if (From.isThisCapture()) { - Captures.push_back(LambdaExpr::Capture(From.getLocation(), - IsImplicit, - LCK_This)); + Captures.push_back( + LambdaCapture(From.getLocation(), IsImplicit, LCK_This)); CaptureInits.push_back(new (Context) CXXThisExpr(From.getLocation(), getCurrentThisType(), /*isImplicit=*/true)); @@ -1423,8 +1419,8 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, VarDecl *Var = From.getVariable(); LambdaCaptureKind Kind = From.isCopyCapture()? LCK_ByCopy : LCK_ByRef; - Captures.push_back(LambdaExpr::Capture(From.getLocation(), IsImplicit, - Kind, Var, From.getEllipsisLoc())); + Captures.push_back(LambdaCapture(From.getLocation(), IsImplicit, Kind, + Var, From.getEllipsisLoc())); CaptureInits.push_back(From.getInitExpr()); } diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 51d130c685..df4970ec8e 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -20,6 +20,7 @@ #include "clang/AST/ExprObjC.h" #include "clang/AST/TypeOrdering.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/TargetInfo.h" #include "clang/Sema/Initialization.h" diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index a8463cdbd4..a28ad5eb07 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -31,6 +31,7 @@ //===----------------------------------------------------------------------===// #include "clang/Sema/SemaInternal.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/Basic/CharInfo.h" #include "clang/Lex/Preprocessor.h" diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 10a9282c98..bd2174046b 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -22,6 +22,7 @@ #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLocVisitor.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManagerInternals.h" diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 50d03a32a8..a525f2f089 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1247,7 +1247,7 @@ void ASTDeclReader::ReadCXXDefinitionData( Data.FirstFriend = ReadDeclID(Record, Idx); if (Data.IsLambda) { - typedef LambdaExpr::Capture Capture; + typedef LambdaCapture Capture; CXXRecordDecl::LambdaDefinitionData &Lambda = static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data); Lambda.Dependent = Record[Idx++]; diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 11b70e3925..d9bef82130 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -23,6 +23,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLocVisitor.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemStatCache.h" #include "clang/Basic/SourceManager.h" @@ -5370,7 +5371,7 @@ void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Rec AddDeclRef(Lambda.ContextDecl, Record); AddTypeSourceInfo(Lambda.MethodTyInfo, Record); for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) { - LambdaExpr::Capture &Capture = Lambda.Captures[I]; + const LambdaCapture &Capture = Lambda.Captures[I]; AddSourceLocation(Capture.getLocation(), Record); Record.push_back(Capture.isImplicit()); Record.push_back(Capture.getCaptureKind()); diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 5b2aa35365..fd93620d0b 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -16,6 +16,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/ParentMap.h" #include "clang/AST/StmtCXX.h" #include "clang/Basic/SourceManager.h" diff --git a/lib/Tooling/CompilationDatabase.cpp b/lib/Tooling/CompilationDatabase.cpp index ec4d604825..a70e066d29 100644 --- a/lib/Tooling/CompilationDatabase.cpp +++ b/lib/Tooling/CompilationDatabase.cpp @@ -14,6 +14,7 @@ #include "clang/Tooling/CompilationDatabase.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Driver/Action.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp index 6cc8062382..1cb9e078f5 100644 --- a/tools/libclang/IndexBody.cpp +++ b/tools/libclang/IndexBody.cpp @@ -149,7 +149,7 @@ public: return true; } - bool TraverseLambdaCapture(LambdaExpr::Capture C) { + bool TraverseLambdaCapture(LambdaCapture C) { if (C.capturesThis()) return true; diff --git a/unittests/Lex/PPCallbacksTest.cpp b/unittests/Lex/PPCallbacksTest.cpp index d3138c0500..25dc7db53e 100644 --- a/unittests/Lex/PPCallbacksTest.cpp +++ b/unittests/Lex/PPCallbacksTest.cpp @@ -11,6 +11,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SourceManager.h" |