r325659 - [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

Eugene Zelenko via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 17:45:26 PST 2018


Author: eugenezelenko
Date: Tue Feb 20 17:45:26 2018
New Revision: 325659

URL: http://llvm.org/viewvc/llvm-project?rev=325659&view=rev
Log:
[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

Modified:
    cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
    cfe/trunk/include/clang/Sema/IdentifierResolver.h
    cfe/trunk/include/clang/Sema/Initialization.h
    cfe/trunk/include/clang/Sema/Lookup.h
    cfe/trunk/include/clang/Sema/Overload.h
    cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
    cfe/trunk/lib/Sema/IdentifierResolver.cpp

Modified: cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DelayedDiagnostic.h?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DelayedDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/DelayedDiagnostic.h Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===--- DelayedDiagnostic.h - Delayed declarator diagnostics ---*- C++ -*-===//
+//===- DelayedDiagnostic.h - Delayed declarator diagnostics -----*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -6,7 +6,7 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
-///
+//
 /// \file
 /// \brief Defines the classes clang::DelayedDiagnostic and 
 /// clang::AccessedEntity.
@@ -16,15 +16,33 @@
 /// diagnostics -- notably deprecation and access control -- are suppressed
 /// based on semantic properties of the parsed declaration that aren't known
 /// until it is fully parsed.
-///
+//
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H
 #define LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H
 
+#include "clang/AST/DeclAccessPair.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Sema/Sema.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <cstddef>
+#include <utility>
 
 namespace clang {
+
+class ObjCInterfaceDecl;
+class ObjCPropertyDecl;
+
 namespace sema {
 
 /// A declaration being accessed, together with information about how
@@ -39,16 +57,14 @@ public:
   /// The target is the base class.
   enum BaseNonce { Base };
 
-  bool isMemberAccess() const { return IsMember; }
-
   AccessedEntity(PartialDiagnostic::StorageAllocator &Allocator,
                  MemberNonce _,
                  CXXRecordDecl *NamingClass,
                  DeclAccessPair FoundDecl,
                  QualType BaseObjectType)
-    : Access(FoundDecl.getAccess()), IsMember(true),
-      Target(FoundDecl.getDecl()), NamingClass(NamingClass),
-      BaseObjectType(BaseObjectType), Diag(0, Allocator) {
+      : Access(FoundDecl.getAccess()), IsMember(true),
+        Target(FoundDecl.getDecl()), NamingClass(NamingClass),
+        BaseObjectType(BaseObjectType), Diag(0, Allocator) {
   }
 
   AccessedEntity(PartialDiagnostic::StorageAllocator &Allocator,
@@ -56,11 +72,10 @@ public:
                  CXXRecordDecl *BaseClass,
                  CXXRecordDecl *DerivedClass,
                  AccessSpecifier Access)
-    : Access(Access), IsMember(false),
-      Target(BaseClass),
-      NamingClass(DerivedClass),
-      Diag(0, Allocator) {
-  }
+      : Access(Access), IsMember(false), Target(BaseClass),
+        NamingClass(DerivedClass), Diag(0, Allocator) {}
+
+  bool isMemberAccess() const { return IsMember; }
 
   bool isQuiet() const { return Diag.getDiagID() == 0; }
 
@@ -216,7 +231,6 @@ public:
   }
 
 private:
-
   struct AD {
     const NamedDecl *ReferringDecl;
     const NamedDecl *OffendingDecl;
@@ -248,20 +262,17 @@ class DelayedDiagnosticPool {
   const DelayedDiagnosticPool *Parent;
   SmallVector<DelayedDiagnostic, 4> Diagnostics;
 
-  DelayedDiagnosticPool(const DelayedDiagnosticPool &) = delete;
-  void operator=(const DelayedDiagnosticPool &) = delete;
 public:
   DelayedDiagnosticPool(const DelayedDiagnosticPool *parent) : Parent(parent) {}
-  ~DelayedDiagnosticPool() {
-    for (SmallVectorImpl<DelayedDiagnostic>::iterator
-           i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i)
-      i->Destroy();
-  }
+
+  DelayedDiagnosticPool(const DelayedDiagnosticPool &) = delete;
+  DelayedDiagnosticPool &operator=(const DelayedDiagnosticPool &) = delete;
 
   DelayedDiagnosticPool(DelayedDiagnosticPool &&Other)
-    : Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) {
+      : Parent(Other.Parent), Diagnostics(std::move(Other.Diagnostics)) {
     Other.Diagnostics.clear();
   }
+
   DelayedDiagnosticPool &operator=(DelayedDiagnosticPool &&Other) {
     Parent = Other.Parent;
     Diagnostics = std::move(Other.Diagnostics);
@@ -269,6 +280,12 @@ public:
     return *this;
   }
 
+  ~DelayedDiagnosticPool() {
+    for (SmallVectorImpl<DelayedDiagnostic>::iterator
+           i = Diagnostics.begin(), e = Diagnostics.end(); i != e; ++i)
+      i->Destroy();
+  }
+
   const DelayedDiagnosticPool *getParent() const { return Parent; }
 
   /// Does this pool, or any of its ancestors, contain any diagnostics?
@@ -293,13 +310,14 @@ public:
     pool.Diagnostics.clear();
   }
 
-  typedef SmallVectorImpl<DelayedDiagnostic>::const_iterator pool_iterator;
+  using pool_iterator = SmallVectorImpl<DelayedDiagnostic>::const_iterator;
+
   pool_iterator pool_begin() const { return Diagnostics.begin(); }
   pool_iterator pool_end() const { return Diagnostics.end(); }
   bool pool_empty() const { return Diagnostics.empty(); }
 };
 
-}
+} // namespace clang
 
 /// Add a diagnostic to the current delay pool.
 inline void Sema::DelayedDiagnostics::add(const sema::DelayedDiagnostic &diag) {
@@ -307,7 +325,6 @@ inline void Sema::DelayedDiagnostics::ad
   CurPool->add(diag);
 }
 
+} // namespace clang
 
-}
-
-#endif
+#endif // LLVM_CLANG_SEMA_DELAYEDDIAGNOSTIC_H

Modified: cfe/trunk/include/clang/Sema/IdentifierResolver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/IdentifierResolver.h?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/IdentifierResolver.h (original)
+++ cfe/trunk/include/clang/Sema/IdentifierResolver.h Tue Feb 20 17:45:26 2018
@@ -15,16 +15,20 @@
 #ifndef LLVM_CLANG_SEMA_IDENTIFIERRESOLVER_H
 #define LLVM_CLANG_SEMA_IDENTIFIERRESOLVER_H
 
-#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallVector.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
 
 namespace clang {
 
-class ASTContext;
 class Decl;
-class DeclContext;
 class DeclarationName;
-class ExternalPreprocessorSource;
+class DeclContext;
+class IdentifierInfo;
+class LangOptions;
 class NamedDecl;
 class Preprocessor;
 class Scope;
@@ -33,17 +37,16 @@ class Scope;
 /// scopes.  It manages the shadowing chains of declaration names and
 /// implements efficient decl lookup based on a declaration name.
 class IdentifierResolver {
-
   /// IdDeclInfo - Keeps track of information about decls associated
   /// to a particular declaration name. IdDeclInfos are lazily
   /// constructed and assigned to a declaration name the first time a
   /// decl with that declaration name is shadowed in some scope.
   class IdDeclInfo {
   public:
-    typedef SmallVector<NamedDecl*, 2> DeclsTy;
+    using DeclsTy = SmallVector<NamedDecl *, 2>;
 
-    inline DeclsTy::iterator decls_begin() { return Decls.begin(); }
-    inline DeclsTy::iterator decls_end() { return Decls.end(); }
+    DeclsTy::iterator decls_begin() { return Decls.begin(); }
+    DeclsTy::iterator decls_end() { return Decls.end(); }
 
     void AddDecl(NamedDecl *D) { Decls.push_back(D); }
 
@@ -61,30 +64,32 @@ class IdentifierResolver {
   };
 
 public:
-
   /// iterator - Iterate over the decls of a specified declaration name.
   /// It will walk or not the parent declaration contexts depending on how
   /// it was instantiated.
   class iterator {
   public:
-    typedef NamedDecl *             value_type;
-    typedef NamedDecl *             reference;
-    typedef NamedDecl *             pointer;
-    typedef std::input_iterator_tag iterator_category;
-    typedef std::ptrdiff_t          difference_type;
+    friend class IdentifierResolver;
+
+    using value_type = NamedDecl *;
+    using reference = NamedDecl *;
+    using pointer = NamedDecl *;
+    using iterator_category = std::input_iterator_tag;
+    using difference_type = std::ptrdiff_t;
 
     /// Ptr - There are 2 forms that 'Ptr' represents:
     /// 1) A single NamedDecl. (Ptr & 0x1 == 0)
     /// 2) A IdDeclInfo::DeclsTy::iterator that traverses only the decls of the
     ///    same declaration context. (Ptr & 0x1 == 0x1)
-    uintptr_t Ptr;
-    typedef IdDeclInfo::DeclsTy::iterator BaseIter;
+    uintptr_t Ptr = 0;
+    using BaseIter = IdDeclInfo::DeclsTy::iterator;
 
     /// A single NamedDecl. (Ptr & 0x1 == 0)
     iterator(NamedDecl *D) {
       Ptr = reinterpret_cast<uintptr_t>(D);
       assert((Ptr & 0x1) == 0 && "Invalid Ptr!");
     }
+
     /// A IdDeclInfo::DeclsTy::iterator that walks or not the parent declaration
     /// contexts depending on 'LookInParentCtx'.
     iterator(BaseIter I) {
@@ -98,11 +103,10 @@ public:
       return reinterpret_cast<BaseIter>(Ptr & ~0x1);
     }
 
-    friend class IdentifierResolver;
-
     void incrementSlowCase();
+
   public:
-    iterator() : Ptr(0) {}
+    iterator() = default;
 
     NamedDecl *operator*() const {
       if (isIterator())
@@ -128,6 +132,9 @@ public:
     }
   };
 
+  explicit IdentifierResolver(Preprocessor &PP);
+  ~IdentifierResolver();
+
   /// begin - Returns an iterator for decls with the name 'Name'.
   iterator begin(DeclarationName Name);
 
@@ -170,9 +177,6 @@ public:
   /// \returns true if the declaration was added, false otherwise.
   bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name);
   
-  explicit IdentifierResolver(Preprocessor &PP);
-  ~IdentifierResolver();
-
 private:
   const LangOptions &LangOpt;
   Preprocessor &PP;
@@ -193,11 +197,10 @@ private:
     assert((reinterpret_cast<uintptr_t>(Ptr) & 0x1) == 1
           && "Ptr not a IdDeclInfo* !");
     return reinterpret_cast<IdDeclInfo*>(
-                    reinterpret_cast<uintptr_t>(Ptr) & ~0x1
-                                                            );
+                    reinterpret_cast<uintptr_t>(Ptr) & ~0x1);
   }
 };
 
-} // end namespace clang
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_SEMA_IDENTIFIERRESOLVER_H

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===--- Initialization.h - Semantic Analysis for Initializers --*- C++ -*-===//
+//===- Initialization.h - Semantic Analysis for Initializers ----*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -10,32 +10,41 @@
 // This file provides supporting data types for initialization of objects.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_SEMA_INITIALIZATION_H
 #define LLVM_CLANG_SEMA_INITIALIZATION_H
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclAccessPair.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
-#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Sema/Overload.h"
 #include "clang/Sema/Ownership.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
 #include <cassert>
+#include <cstdint>
+#include <string>
 
 namespace clang {
-  
+
+class APValue;
 class CXXBaseSpecifier;
-class DeclaratorDecl;
-class DeclaratorInfo;
-class FieldDecl;
-class FunctionDecl;
-class ParmVarDecl;
-class Sema;
-class TypeLoc;
-class VarDecl;
+class CXXConstructorDecl;
 class ObjCMethodDecl;
-  
+class Sema;
+
 /// \brief Describes an entity that is being initialized.
 class InitializedEntity {
 public:
@@ -43,51 +52,69 @@ public:
   enum EntityKind {
     /// \brief The entity being initialized is a variable.
     EK_Variable,
+
     /// \brief The entity being initialized is a function parameter.
     EK_Parameter,
+
     /// \brief The entity being initialized is the result of a function call.
     EK_Result,
+
     /// \brief The entity being initialized is an exception object that
     /// is being thrown.
     EK_Exception,
+
     /// \brief The entity being initialized is a non-static data member 
     /// subobject.
     EK_Member,
+
     /// \brief The entity being initialized is an element of an array.
     EK_ArrayElement,
+
     /// \brief The entity being initialized is an object (or array of
     /// objects) allocated via new.
     EK_New,
+
     /// \brief The entity being initialized is a temporary object.
     EK_Temporary,
+
     /// \brief The entity being initialized is a base member subobject.
     EK_Base,
+
     /// \brief The initialization is being done by a delegating constructor.
     EK_Delegating,
+
     /// \brief The entity being initialized is an element of a vector.
     /// or vector.
     EK_VectorElement,
+
     /// \brief The entity being initialized is a field of block descriptor for
     /// the copied-in c++ object.
     EK_BlockElement,
+
     /// The entity being initialized is a field of block descriptor for the
     /// copied-in lambda object that's used in the lambda to block conversion.
     EK_LambdaToBlockConversionBlockElement,
+
     /// \brief The entity being initialized is the real or imaginary part of a
     /// complex number.
     EK_ComplexElement,
+
     /// \brief The entity being initialized is the field that captures a 
     /// variable in a lambda.
     EK_LambdaCapture,
+
     /// \brief The entity being initialized is the initializer for a compound
     /// literal.
     EK_CompoundLiteralInit,
+
     /// \brief The entity being implicitly initialized back to the formal
     /// result type.
     EK_RelatedResult,
+
     /// \brief The entity being initialized is a function parameter; function
     /// is member of group of audited CF APIs.
     EK_Parameter_CF_Audited,
+
     /// \brief The entity being initialized is a structured binding of a
     /// decomposition declaration.
     EK_Binding,
@@ -103,13 +130,13 @@ private:
 
   /// \brief If non-NULL, the parent entity in which this
   /// initialization occurs.
-  const InitializedEntity *Parent;
+  const InitializedEntity *Parent = nullptr;
 
   /// \brief The type of the object or reference being initialized.
   QualType Type;
 
   /// \brief The mangling number for the next reference temporary to be created.
-  mutable unsigned ManglingNumber;
+  mutable unsigned ManglingNumber = 0;
 
   struct LN {
     /// \brief When Kind == EK_Result, EK_Exception, EK_New, the
@@ -172,20 +199,18 @@ private:
     struct C Capture;
   };
 
-  InitializedEntity() : ManglingNumber(0) {}
+  InitializedEntity() = default;
 
   /// \brief Create the initialization entity for a variable.
   InitializedEntity(VarDecl *Var, EntityKind EK = EK_Variable)
-    : Kind(EK), Parent(nullptr), Type(Var->getType()),
-      ManglingNumber(0), Variable{Var, false} { }
+      : Kind(EK), Type(Var->getType()), Variable{Var, false} {}
   
   /// \brief Create the initialization entity for the result of a
   /// function, throwing an object, performing an explicit cast, or
   /// initializing a parameter for which there is no declaration.
   InitializedEntity(EntityKind Kind, SourceLocation Loc, QualType Type,
                     bool NRVO = false)
-    : Kind(Kind), Parent(nullptr), Type(Type), ManglingNumber(0)
-  {
+      : Kind(Kind), Type(Type) {
     LocAndNRVO.Location = Loc.getRawEncoding();
     LocAndNRVO.NRVO = NRVO;
   }
@@ -193,9 +218,8 @@ private:
   /// \brief Create the initialization entity for a member subobject.
   InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent,
                     bool Implicit) 
-    : Kind(EK_Member), Parent(Parent), Type(Member->getType()),
-      ManglingNumber(0), Variable{Member, Implicit} {
-  }
+      : Kind(EK_Member), Parent(Parent), Type(Member->getType()),
+        Variable{Member, Implicit} {}
   
   /// \brief Create the initialization entity for an array element.
   InitializedEntity(ASTContext &Context, unsigned Index, 
@@ -203,9 +227,7 @@ private:
 
   /// \brief Create the initialization entity for a lambda capture.
   InitializedEntity(IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc)
-    : Kind(EK_LambdaCapture), Parent(nullptr), Type(FieldType),
-      ManglingNumber(0)
-  {
+      : Kind(EK_LambdaCapture), Type(FieldType) {
     Capture.VarID = VarID;
     Capture.Location = Loc.getRawEncoding();
   }
@@ -307,7 +329,6 @@ public:
     return Result;
   }
 
-
   /// \brief Create the initialization entity for a base class subobject.
   static InitializedEntity
   InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base,
@@ -362,7 +383,6 @@ public:
     return Result;
   }
 
-
   /// \brief Determine the kind of initialization.
   EntityKind getKind() const { return Kind; }
   
@@ -401,6 +421,7 @@ public:
     return (getKind() == EK_Parameter  ||
             getKind() == EK_Parameter_CF_Audited);
   }
+
   /// \brief Determine whether this initialization consumes the
   /// parameter.
   bool isParameterConsumed() const {
@@ -453,6 +474,7 @@ public:
            getKind() == EK_ComplexElement);
     return Index;
   }
+
   /// \brief If this is already the initializer for an array or vector
   /// element, sets the element index.
   void setElementIndex(unsigned Index) {
@@ -460,11 +482,13 @@ public:
            getKind() == EK_ComplexElement);
     this->Index = Index;
   }
+
   /// \brief For a lambda capture, return the capture's name.
   StringRef getCapturedVarName() const {
     assert(getKind() == EK_LambdaCapture && "Not a lambda capture!");
     return Capture.VarID->getName();
   }
+
   /// \brief Determine the location of the capture when initializing
   /// field from a captured variable in a lambda.
   SourceLocation getCaptureLoc() const {
@@ -493,22 +517,42 @@ class InitializationKind {
 public:
   /// \brief The kind of initialization being performed.
   enum InitKind {
-    IK_Direct,       ///< Direct initialization
-    IK_DirectList,   ///< Direct list-initialization
-    IK_Copy,         ///< Copy initialization
-    IK_Default,      ///< Default initialization
-    IK_Value         ///< Value initialization
+    /// Direct initialization
+    IK_Direct,
+
+    /// Direct list-initialization
+    IK_DirectList,
+
+    /// Copy initialization
+    IK_Copy,
+
+    /// Default initialization
+    IK_Default,
+
+    /// Value initialization
+    IK_Value
   };
   
 private:
   /// \brief The context of the initialization.
   enum InitContext {
-    IC_Normal,         ///< Normal context
-    IC_ExplicitConvs,  ///< Normal context, but allows explicit conversion funcs
-    IC_Implicit,       ///< Implicit context (value initialization)
-    IC_StaticCast,     ///< Static cast context
-    IC_CStyleCast,     ///< C-style cast context
-    IC_FunctionalCast  ///< Functional cast context
+    /// Normal context
+    IC_Normal,
+
+    /// Normal context, but allows explicit conversion functionss
+    IC_ExplicitConvs,
+
+    /// Implicit context (value initialization)
+    IC_Implicit,
+
+    /// Static cast context
+    IC_StaticCast,
+
+    /// C-style cast context
+    IC_CStyleCast,
+
+    /// Functional cast context
+    IC_FunctionalCast
   };
   
   /// \brief The kind of initialization being performed.
@@ -522,8 +566,7 @@ private:
   
   InitializationKind(InitKind Kind, InitContext Context, SourceLocation Loc1, 
                      SourceLocation Loc2, SourceLocation Loc3)
-    : Kind(Kind), Context(Context)
-  {
+      : Kind(Kind), Context(Context) {
     Locations[0] = Loc1;
     Locations[1] = Loc2;
     Locations[2] = Loc3;
@@ -711,86 +754,123 @@ public:
     /// \brief Resolve the address of an overloaded function to a specific
     /// function declaration.
     SK_ResolveAddressOfOverloadedFunction,
+
     /// \brief Perform a derived-to-base cast, producing an rvalue.
     SK_CastDerivedToBaseRValue,
+
     /// \brief Perform a derived-to-base cast, producing an xvalue.
     SK_CastDerivedToBaseXValue,
+
     /// \brief Perform a derived-to-base cast, producing an lvalue.
     SK_CastDerivedToBaseLValue,
+
     /// \brief Reference binding to an lvalue.
     SK_BindReference,
+
     /// \brief Reference binding to a temporary.
     SK_BindReferenceToTemporary,
+
     /// \brief An optional copy of a temporary object to another
     /// temporary object, which is permitted (but not required) by
     /// C++98/03 but not C++0x.
     SK_ExtraneousCopyToTemporary,
+
     /// \brief Direct-initialization from a reference-related object in the
     /// final stage of class copy-initialization.
     SK_FinalCopy,
+
     /// \brief Perform a user-defined conversion, either via a conversion
     /// function or via a constructor.
     SK_UserConversion,
+
     /// \brief Perform a qualification conversion, producing an rvalue.
     SK_QualificationConversionRValue,
+
     /// \brief Perform a qualification conversion, producing an xvalue.
     SK_QualificationConversionXValue,
+
     /// \brief Perform a qualification conversion, producing an lvalue.
     SK_QualificationConversionLValue,
+
     /// \brief Perform a conversion adding _Atomic to a type.
     SK_AtomicConversion,
+
     /// \brief Perform a load from a glvalue, producing an rvalue.
     SK_LValueToRValue,
+
     /// \brief Perform an implicit conversion sequence.
     SK_ConversionSequence,
+
     /// \brief Perform an implicit conversion sequence without narrowing.
     SK_ConversionSequenceNoNarrowing,
+
     /// \brief Perform list-initialization without a constructor.
     SK_ListInitialization,
+
     /// \brief Unwrap the single-element initializer list for a reference.
     SK_UnwrapInitList,
+
     /// \brief Rewrap the single-element initializer list for a reference.
     SK_RewrapInitList,
+
     /// \brief Perform initialization via a constructor.
     SK_ConstructorInitialization,
+
     /// \brief Perform initialization via a constructor, taking arguments from
     /// a single InitListExpr.
     SK_ConstructorInitializationFromList,
+
     /// \brief Zero-initialize the object
     SK_ZeroInitialization,
+
     /// \brief C assignment
     SK_CAssignment,
+
     /// \brief Initialization by string
     SK_StringInit,
+
     /// \brief An initialization that "converts" an Objective-C object
     /// (not a point to an object) to another Objective-C object type.
     SK_ObjCObjectConversion,
+
     /// \brief Array indexing for initialization by elementwise copy.
     SK_ArrayLoopIndex,
+
     /// \brief Array initialization by elementwise copy.
     SK_ArrayLoopInit,
+
     /// \brief Array initialization (from an array rvalue).
     SK_ArrayInit,
+
     /// \brief Array initialization (from an array rvalue) as a GNU extension.
     SK_GNUArrayInit,
+
     /// \brief Array initialization from a parenthesized initializer list.
     /// This is a GNU C++ extension.
     SK_ParenthesizedArrayInit,
+
     /// \brief Pass an object by indirect copy-and-restore.
     SK_PassByIndirectCopyRestore,
+
     /// \brief Pass an object by indirect restore.
     SK_PassByIndirectRestore,
+
     /// \brief Produce an Objective-C object pointer.
     SK_ProduceObjCObject,
+
     /// \brief Construct a std::initializer_list from an initializer list.
     SK_StdInitializerList,
+
     /// \brief Perform initialization via a constructor taking a single
     /// std::initializer_list argument.
     SK_StdInitializerListConstructorCall,
+
     /// \brief Initialize an OpenCL sampler from an integer.
     SK_OCLSamplerInit,
+
     /// \brief Initialize queue_t from 0.
     SK_OCLZeroQueue,
+
     /// \brief Passing zero to a function where OpenCL event_t is expected.
     SK_OCLZeroEvent
   };
@@ -847,79 +927,113 @@ public:
   enum FailureKind {
     /// \brief Too many initializers provided for a reference.
     FK_TooManyInitsForReference,
+
     /// \brief Reference initialized from a parenthesized initializer list.
     FK_ParenthesizedListInitForReference,
+
     /// \brief Array must be initialized with an initializer list.
     FK_ArrayNeedsInitList,
+
     /// \brief Array must be initialized with an initializer list or a 
     /// string literal.
     FK_ArrayNeedsInitListOrStringLiteral,
+
     /// \brief Array must be initialized with an initializer list or a
     /// wide string literal.
     FK_ArrayNeedsInitListOrWideStringLiteral,
+
     /// \brief Initializing a wide char array with narrow string literal.
     FK_NarrowStringIntoWideCharArray,
+
     /// \brief Initializing char array with wide string literal.
     FK_WideStringIntoCharArray,
+
     /// \brief Initializing wide char array with incompatible wide string
     /// literal.
     FK_IncompatWideStringIntoWideChar,
+
     /// \brief Array type mismatch.
     FK_ArrayTypeMismatch,
+
     /// \brief Non-constant array initializer
     FK_NonConstantArrayInit,
+
     /// \brief Cannot resolve the address of an overloaded function.
     FK_AddressOfOverloadFailed,
+
     /// \brief Overloading due to reference initialization failed.
     FK_ReferenceInitOverloadFailed,
+
     /// \brief Non-const lvalue reference binding to a temporary.
     FK_NonConstLValueReferenceBindingToTemporary,
+
     /// \brief Non-const lvalue reference binding to a bit-field.
     FK_NonConstLValueReferenceBindingToBitfield,
+
     /// \brief Non-const lvalue reference binding to a vector element.
     FK_NonConstLValueReferenceBindingToVectorElement,
+
     /// \brief Non-const lvalue reference binding to an lvalue of unrelated
     /// type.
     FK_NonConstLValueReferenceBindingToUnrelated,
+
     /// \brief Rvalue reference binding to an lvalue.
     FK_RValueReferenceBindingToLValue,
+
     /// \brief Reference binding drops qualifiers.
     FK_ReferenceInitDropsQualifiers,
+
     /// \brief Reference binding failed.
     FK_ReferenceInitFailed,
+
     /// \brief Implicit conversion failed.
     FK_ConversionFailed,
+
     /// \brief Implicit conversion failed.
     FK_ConversionFromPropertyFailed,
+
     /// \brief Too many initializers for scalar
     FK_TooManyInitsForScalar,
+
     /// \brief Scalar initialized from a parenthesized initializer list.
     FK_ParenthesizedListInitForScalar,
+
     /// \brief Reference initialization from an initializer list
     FK_ReferenceBindingToInitList,
+
     /// \brief Initialization of some unused destination type with an
     /// initializer list.
     FK_InitListBadDestinationType,
+
     /// \brief Overloading for a user-defined conversion failed.
     FK_UserConversionOverloadFailed,
+
     /// \brief Overloading for initialization by constructor failed.
     FK_ConstructorOverloadFailed,
+
     /// \brief Overloading for list-initialization by constructor failed.
     FK_ListConstructorOverloadFailed,
+
     /// \brief Default-initialization of a 'const' object.
     FK_DefaultInitOfConst,
+
     /// \brief Initialization of an incomplete type.
     FK_Incomplete,
+
     /// \brief Variable-length array must not have an initializer.
     FK_VariableLengthArrayHasInitializer,
+
     /// \brief List initialization failed at some point.
     FK_ListInitializationFailed,
+
     /// \brief Initializer has a placeholder type which cannot be
     /// resolved by initialization.
     FK_PlaceholderType,
+
     /// \brief Trying to take the address of a function that doesn't support
     /// having its address taken.
     FK_AddressOfUnaddressableFunction,
+
     /// \brief List-copy-initialization chose an explicit constructor.
     FK_ExplicitConstructor,
   };
@@ -951,7 +1065,6 @@ public:
   }
 
 private:
-  
   /// \brief Prints a follow-up note that highlights the location of
   /// the initialized entity, if it's remote.
   void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity);
@@ -1036,11 +1149,13 @@ public:
   /// \brief Determine whether the initialization sequence is invalid.
   bool Failed() const { return SequenceKind == FailedSequence; }
 
-  typedef SmallVectorImpl<Step>::const_iterator step_iterator;
+  using step_iterator = SmallVectorImpl<Step>::const_iterator;
+
   step_iterator step_begin() const { return Steps.begin(); }
   step_iterator step_end()   const { return Steps.end(); }
 
-  typedef llvm::iterator_range<step_iterator> step_range;
+  using step_range = llvm::iterator_range<step_iterator>;
+
   step_range steps() const { return {step_begin(), step_end()}; }
 
   /// \brief Determine whether this initialization is a direct reference 
@@ -1245,6 +1360,6 @@ public:
   void dump() const;
 };
   
-} // end namespace clang
+} // namespace clang
 
 #endif // LLVM_CLANG_SEMA_INITIALIZATION_H

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===--- Lookup.h - Classes for name lookup ---------------------*- C++ -*-===//
+//===- Lookup.h - Classes for name lookup -----------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -15,13 +15,28 @@
 #ifndef LLVM_CLANG_SEMA_LOOKUP_H
 #define LLVM_CLANG_SEMA_LOOKUP_H
 
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Sema/Sema.h"
-
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <utility>
 
 namespace clang {
 
+class CXXBasePaths;
+
 /// @brief Represents the results of name lookup.
 ///
 /// An instance of the LookupResult class captures the results of a
@@ -126,25 +141,15 @@ public:
     Temporary
   };
 
-  typedef UnresolvedSetImpl::iterator iterator;
+  using iterator = UnresolvedSetImpl::iterator;
 
   LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo,
                Sema::LookupNameKind LookupKind,
                Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
-    : ResultKind(NotFound),
-      Paths(nullptr),
-      NamingClass(nullptr),
-      SemaPtr(&SemaRef),
-      NameInfo(NameInfo),
-      LookupKind(LookupKind),
-      IDNS(0),
-      Redecl(Redecl != Sema::NotForRedeclaration),
-      ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
-      HideTags(true),
-      Diagnose(Redecl == Sema::NotForRedeclaration),
-      AllowHidden(false),
-      Shadowed(false)
-  {
+      : SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind),
+        Redecl(Redecl != Sema::NotForRedeclaration),
+        ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
+        Diagnose(Redecl == Sema::NotForRedeclaration) {
     configure();
   }
 
@@ -154,20 +159,10 @@ public:
   LookupResult(Sema &SemaRef, DeclarationName Name,
                SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
                Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
-    : ResultKind(NotFound),
-      Paths(nullptr),
-      NamingClass(nullptr),
-      SemaPtr(&SemaRef),
-      NameInfo(Name, NameLoc),
-      LookupKind(LookupKind),
-      IDNS(0),
-      Redecl(Redecl != Sema::NotForRedeclaration),
-      ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
-      HideTags(true),
-      Diagnose(Redecl == Sema::NotForRedeclaration),
-      AllowHidden(false),
-      Shadowed(false)
-  {
+      : SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind),
+        Redecl(Redecl != Sema::NotForRedeclaration),
+        ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
+        Diagnose(Redecl == Sema::NotForRedeclaration) {
     configure();
   }
 
@@ -175,20 +170,10 @@ public:
   /// using the information from another result.  Diagnostics are always
   /// disabled.
   LookupResult(TemporaryToken _, const LookupResult &Other)
-    : ResultKind(NotFound),
-      Paths(nullptr),
-      NamingClass(nullptr),
-      SemaPtr(Other.SemaPtr),
-      NameInfo(Other.NameInfo),
-      LookupKind(Other.LookupKind),
-      IDNS(Other.IDNS),
-      Redecl(Other.Redecl),
-      ExternalRedecl(Other.ExternalRedecl),
-      HideTags(Other.HideTags),
-      Diagnose(false),
-      AllowHidden(Other.AllowHidden),
-      Shadowed(false)
-  {}
+      : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
+        LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
+        ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
+        AllowHidden(Other.AllowHidden) {}
 
   // FIXME: Remove these deleted methods once the default build includes
   // -Wdeprecated.
@@ -213,6 +198,7 @@ public:
     Other.Paths = nullptr;
     Other.Diagnose = false;
   }
+
   LookupResult &operator=(LookupResult &&Other) {
     ResultKind = std::move(Other.ResultKind);
     Ambiguity = std::move(Other.Ambiguity);
@@ -618,15 +604,14 @@ public:
   /// filtering out results.  The results returned are possibly
   /// sugared.
   class Filter {
+    friend class LookupResult;
+
     LookupResult &Results;
     LookupResult::iterator I;
-    bool Changed;
-    bool CalledDone;
+    bool Changed = false;
+    bool CalledDone = false;
     
-    friend class LookupResult;
-    Filter(LookupResult &Results)
-      : Results(Results), I(Results.begin()), Changed(false), CalledDone(false)
-    {}
+    Filter(LookupResult &Results) : Results(Results), I(Results.begin()) {}
 
   public:
     Filter(Filter &&F)
@@ -634,6 +619,7 @@ public:
           CalledDone(F.CalledDone) {
       F.CalledDone = true;
     }
+
     ~Filter() {
       assert(CalledDone &&
              "LookupResult::Filter destroyed without done() call");
@@ -722,11 +708,11 @@ private:
   static void deletePaths(CXXBasePaths *);
 
   // Results.
-  LookupResultKind ResultKind;
+  LookupResultKind ResultKind = NotFound;
   AmbiguityKind Ambiguity; // ill-defined unless ambiguous
   UnresolvedSet<8> Decls;
-  CXXBasePaths *Paths;
-  CXXRecordDecl *NamingClass;
+  CXXBasePaths *Paths = nullptr;
+  CXXRecordDecl *NamingClass = nullptr;
   QualType BaseObjectType;
 
   // Parameters.
@@ -734,24 +720,24 @@ private:
   DeclarationNameInfo NameInfo;
   SourceRange NameContextRange;
   Sema::LookupNameKind LookupKind;
-  unsigned IDNS; // set by configure()
+  unsigned IDNS = 0; // set by configure()
 
   bool Redecl;
   bool ExternalRedecl;
 
   /// \brief True if tag declarations should be hidden if non-tags
   ///   are present
-  bool HideTags;
+  bool HideTags = true;
 
-  bool Diagnose;
+  bool Diagnose = false;
 
   /// \brief True if we should allow hidden declarations to be 'visible'.
-  bool AllowHidden;
+  bool AllowHidden = false;
 
   /// \brief True if the found declarations were shadowed by some other
   /// declaration that we skipped. This only happens when \c LookupKind
   /// is \c LookupRedeclarationWithLinkage.
-  bool Shadowed;
+  bool Shadowed = false;
 };
 
 /// \brief Consumes visible declarations found when searching for
@@ -813,13 +799,13 @@ public:
     Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
   }
 
-  typedef llvm::mapped_iterator<decltype(Decls)::iterator, select_second>
-      iterator;
+  using iterator =
+      llvm::mapped_iterator<decltype(Decls)::iterator, select_second>;
 
   iterator begin() { return iterator(Decls.begin(), select_second()); }
   iterator end() { return iterator(Decls.end(), select_second()); }
 };
 
-}
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_SEMA_LOOKUP_H

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===--- Overload.h - C++ Overloading ---------------------------*- C++ -*-===//
+//===- Overload.h - C++ Overloading -----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -16,32 +16,51 @@
 #define LLVM_CLANG_SEMA_OVERLOAD_H
 
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclAccessPair.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
-#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Sema/SemaFixItUtils.h"
 #include "clang/Sema/TemplateDeduction.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <utility>
 
 namespace clang {
-  class ASTContext;
-  class CXXConstructorDecl;
-  class CXXConversionDecl;
-  class FunctionDecl;
-  class Sema;
+
+class APValue;
+class ASTContext;
+class Sema;
 
   /// OverloadingResult - Capture the result of performing overload
   /// resolution.
   enum OverloadingResult {
-    OR_Success,             ///< Overload resolution succeeded.
-    OR_No_Viable_Function,  ///< No viable function found.
-    OR_Ambiguous,           ///< Ambiguous candidates found.
-    OR_Deleted              ///< Succeeded, but refers to a deleted function.
+    /// Overload resolution succeeded.
+    OR_Success,
+
+    /// No viable function found.
+    OR_No_Viable_Function,
+
+    /// Ambiguous candidates found.
+    OR_Ambiguous,
+
+    /// Succeeded, but refers to a deleted function.
+    OR_Deleted
   };
   
   enum OverloadCandidateDisplayKind {
@@ -58,36 +77,92 @@ namespace clang {
   /// match with Table 9 of (C++ 13.3.3.1.1) and are listed such that
   /// better conversion kinds have smaller values.
   enum ImplicitConversionKind {
-    ICK_Identity = 0,          ///< Identity conversion (no conversion)
-    ICK_Lvalue_To_Rvalue,      ///< Lvalue-to-rvalue conversion (C++ 4.1)
-    ICK_Array_To_Pointer,      ///< Array-to-pointer conversion (C++ 4.2)
-    ICK_Function_To_Pointer,   ///< Function-to-pointer (C++ 4.3)
-    ICK_Function_Conversion,   ///< Function pointer conversion (C++17 4.13)
-    ICK_Qualification,         ///< Qualification conversions (C++ 4.4)
-    ICK_Integral_Promotion,    ///< Integral promotions (C++ 4.5)
-    ICK_Floating_Promotion,    ///< Floating point promotions (C++ 4.6)
-    ICK_Complex_Promotion,     ///< Complex promotions (Clang extension)
-    ICK_Integral_Conversion,   ///< Integral conversions (C++ 4.7)
-    ICK_Floating_Conversion,   ///< Floating point conversions (C++ 4.8)
-    ICK_Complex_Conversion,    ///< Complex conversions (C99 6.3.1.6)
-    ICK_Floating_Integral,     ///< Floating-integral conversions (C++ 4.9)
-    ICK_Pointer_Conversion,    ///< Pointer conversions (C++ 4.10)
-    ICK_Pointer_Member,        ///< Pointer-to-member conversions (C++ 4.11)
-    ICK_Boolean_Conversion,    ///< Boolean conversions (C++ 4.12)
-    ICK_Compatible_Conversion, ///< Conversions between compatible types in C99
-    ICK_Derived_To_Base,       ///< Derived-to-base (C++ [over.best.ics])
-    ICK_Vector_Conversion,     ///< Vector conversions
-    ICK_Vector_Splat,          ///< A vector splat from an arithmetic type
-    ICK_Complex_Real,          ///< Complex-real conversions (C99 6.3.1.7)
-    ICK_Block_Pointer_Conversion,    ///< Block Pointer conversions 
-    ICK_TransparentUnionConversion, ///< Transparent Union Conversions
-    ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
-    ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
-    ICK_Zero_Queue_Conversion, ///< Zero constant to queue
-    ICK_C_Only_Conversion,     ///< Conversions allowed in C, but not C++
-    ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between pointers
-                                         ///  with incompatible types
-    ICK_Num_Conversion_Kinds,  ///< The number of conversion kinds
+    /// Identity conversion (no conversion)
+    ICK_Identity = 0,
+
+    /// Lvalue-to-rvalue conversion (C++ 4.1)
+    ICK_Lvalue_To_Rvalue,
+
+    /// Array-to-pointer conversion (C++ 4.2)
+    ICK_Array_To_Pointer,
+
+    /// Function-to-pointer (C++ 4.3)
+    ICK_Function_To_Pointer,
+
+    /// Function pointer conversion (C++17 4.13)
+    ICK_Function_Conversion,
+
+    /// Qualification conversions (C++ 4.4)
+    ICK_Qualification,
+
+    /// Integral promotions (C++ 4.5)
+    ICK_Integral_Promotion,
+
+    /// Floating point promotions (C++ 4.6)
+    ICK_Floating_Promotion,
+
+    /// Complex promotions (Clang extension)
+    ICK_Complex_Promotion,
+
+    /// Integral conversions (C++ 4.7)
+    ICK_Integral_Conversion,
+
+    /// Floating point conversions (C++ 4.8)
+    ICK_Floating_Conversion,
+
+    /// Complex conversions (C99 6.3.1.6)
+    ICK_Complex_Conversion,
+
+    /// Floating-integral conversions (C++ 4.9)
+    ICK_Floating_Integral,
+
+    /// Pointer conversions (C++ 4.10)
+    ICK_Pointer_Conversion,
+
+    /// Pointer-to-member conversions (C++ 4.11)
+    ICK_Pointer_Member,
+
+    /// Boolean conversions (C++ 4.12)
+    ICK_Boolean_Conversion,
+
+    /// Conversions between compatible types in C99
+    ICK_Compatible_Conversion,
+
+    /// Derived-to-base (C++ [over.best.ics])
+    ICK_Derived_To_Base,
+
+    /// Vector conversions
+    ICK_Vector_Conversion,
+
+    /// A vector splat from an arithmetic type
+    ICK_Vector_Splat,
+
+    /// Complex-real conversions (C99 6.3.1.7)
+    ICK_Complex_Real,
+
+    /// Block Pointer conversions
+    ICK_Block_Pointer_Conversion,
+
+    /// Transparent Union Conversions
+    ICK_TransparentUnionConversion,
+
+    /// Objective-C ARC writeback conversion
+    ICK_Writeback_Conversion,
+
+    /// Zero constant to event (OpenCL1.2 6.12.10)
+    ICK_Zero_Event_Conversion,
+
+    /// Zero constant to queue
+    ICK_Zero_Queue_Conversion,
+
+    /// Conversions allowed in C, but not C++
+    ICK_C_Only_Conversion,
+
+    /// C-only conversion between pointers with incompatible types
+    ICK_Incompatible_Pointer_Conversion,
+
+    /// The number of conversion kinds
+    ICK_Num_Conversion_Kinds,
   };
 
   /// ImplicitConversionRank - The rank of an implicit conversion
@@ -95,16 +170,30 @@ namespace clang {
   /// 13.3.3.1.1) and are listed such that better conversion ranks
   /// have smaller values.
   enum ImplicitConversionRank {
-    ICR_Exact_Match = 0,         ///< Exact Match
-    ICR_Promotion,               ///< Promotion
-    ICR_Conversion,              ///< Conversion
-    ICR_OCL_Scalar_Widening,     ///< OpenCL Scalar Widening
-    ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion
-    ICR_Writeback_Conversion,    ///< ObjC ARC writeback conversion
-    ICR_C_Conversion,            ///< Conversion only allowed in the C standard.
-                                 ///  (e.g. void* to char*)
-    ICR_C_Conversion_Extension   ///< Conversion not allowed by the C standard,
-                                 ///  but that we accept as an extension anyway.
+    /// Exact Match
+    ICR_Exact_Match = 0,
+
+    /// Promotion
+    ICR_Promotion,
+
+    /// Conversion
+    ICR_Conversion,
+
+    /// OpenCL Scalar Widening
+    ICR_OCL_Scalar_Widening,
+
+    /// Complex <-> Real conversion
+    ICR_Complex_Real_Conversion,
+
+    /// ObjC ARC writeback conversion
+    ICR_Writeback_Conversion,
+
+    /// Conversion only allowed in the C standard (e.g. void* to char*).
+    ICR_C_Conversion,
+
+    /// Conversion not allowed by the C standard, but that we accept as an
+    /// extension anyway.
+    ICR_C_Conversion_Extension
   };
 
   ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind);
@@ -213,10 +302,12 @@ namespace clang {
     DeclAccessPair FoundCopyConstructor;
 
     void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); }
+
     void setToType(unsigned Idx, QualType T) { 
       assert(Idx < 3 && "To type index is out of range");
       ToTypePtrs[Idx] = T.getAsOpaquePtr(); 
     }
+
     void setAllToTypes(QualType T) {
       ToTypePtrs[0] = T.getAsOpaquePtr(); 
       ToTypePtrs[1] = ToTypePtrs[0];
@@ -226,6 +317,7 @@ namespace clang {
     QualType getFromType() const {
       return QualType::getFromOpaquePtr(FromTypePtr);
     }
+
     QualType getToType(unsigned Idx) const {
       assert(Idx < 3 && "To type index is out of range");
       return QualType::getFromOpaquePtr(ToTypePtrs[Idx]);
@@ -294,7 +386,8 @@ namespace clang {
 
   /// Represents an ambiguous user-defined conversion sequence.
   struct AmbiguousConversionSequence {
-    typedef SmallVector<std::pair<NamedDecl*, FunctionDecl*>, 4> ConversionSet;
+    using ConversionSet =
+        SmallVector<std::pair<NamedDecl *, FunctionDecl *>, 4>;
 
     void *FromTypePtr;
     void *ToTypePtr;
@@ -303,9 +396,11 @@ namespace clang {
     QualType getFromType() const {
       return QualType::getFromOpaquePtr(FromTypePtr);
     }
+
     QualType getToType() const {
       return QualType::getFromOpaquePtr(ToTypePtr);
     }
+
     void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); }
     void setToType(QualType T) { ToTypePtr = T.getAsOpaquePtr(); }
 
@@ -321,11 +416,13 @@ namespace clang {
       conversions().push_back(std::make_pair(Found, D));
     }
 
-    typedef ConversionSet::iterator iterator;
+    using iterator = ConversionSet::iterator;
+
     iterator begin() { return conversions().begin(); }
     iterator end() { return conversions().end(); }
 
-    typedef ConversionSet::const_iterator const_iterator;
+    using const_iterator = ConversionSet::const_iterator;
+
     const_iterator begin() const { return conversions().begin(); }
     const_iterator end() const { return conversions().end(); }
 
@@ -362,6 +459,7 @@ namespace clang {
       init(K, From->getType(), To);
       FromExpr = From;
     }
+
     void init(FailureKind K, QualType From, QualType To) {
       Kind = K;
       FromExpr = nullptr;
@@ -376,6 +474,7 @@ namespace clang {
       FromExpr = E;
       setFromType(E->getType());
     }
+
     void setFromType(QualType T) { FromTy = T.getAsOpaquePtr(); }
     void setToType(QualType T) { ToTy = T.getAsOpaquePtr(); }
   };
@@ -442,13 +541,10 @@ namespace clang {
         : ConversionKind(Uninitialized), StdInitializerListElement(false) {
       Standard.setAsIdentityConversion();
     }
-    ~ImplicitConversionSequence() {
-      destruct();
-    }
+
     ImplicitConversionSequence(const ImplicitConversionSequence &Other)
-      : ConversionKind(Other.ConversionKind),
-        StdInitializerListElement(Other.StdInitializerListElement)
-    {
+        : ConversionKind(Other.ConversionKind),
+          StdInitializerListElement(Other.StdInitializerListElement) {
       switch (ConversionKind) {
       case Uninitialized: break;
       case StandardConversion: Standard = Other.Standard; break;
@@ -460,12 +556,16 @@ namespace clang {
     }
 
     ImplicitConversionSequence &
-        operator=(const ImplicitConversionSequence &Other) {
+    operator=(const ImplicitConversionSequence &Other) {
       destruct();
       new (this) ImplicitConversionSequence(Other);
       return *this;
     }
     
+    ~ImplicitConversionSequence() {
+      destruct();
+    }
+
     Kind getKind() const {
       assert(isInitialized() && "querying uninitialized conversion");
       return Kind(ConversionKind);
@@ -526,6 +626,7 @@ namespace clang {
     void setStandard() { setKind(StandardConversion); }
     void setEllipsis() { setKind(EllipsisConversion); }
     void setUserDefined() { setKind(UserDefinedConversion); }
+
     void setAmbiguous() {
       if (ConversionKind == AmbiguousConversion) return;
       ConversionKind = AmbiguousConversion;
@@ -621,8 +722,8 @@ namespace clang {
 
   /// A list of implicit conversion sequences for the arguments of an
   /// OverloadCandidate.
-  typedef llvm::MutableArrayRef<ImplicitConversionSequence>
-      ConversionSequenceList;
+  using ConversionSequenceList =
+      llvm::MutableArrayRef<ImplicitConversionSequence>;
 
   /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
   struct OverloadCandidate {
@@ -730,16 +831,19 @@ namespace clang {
     enum CandidateSetKind {
       /// Normal lookup.
       CSK_Normal,
+
       /// C++ [over.match.oper]:
       /// Lookup of operator function candidates in a call using operator
       /// syntax. Candidates that have no parameters of class type will be
       /// skipped unless there is a parameter of (reference to) enum type and
       /// the corresponding argument is of the same enum type.
       CSK_Operator,
+
       /// C++ [over.match.copy]:
       /// Copy-initialization of an object of class type by user-defined
       /// conversion.
       CSK_InitByUserDefinedConversion,
+
       /// C++ [over.match.ctor], [over.match.list]
       /// Initialization of an object of class type by constructor,
       /// using either a parenthesized or braced list of arguments.
@@ -759,7 +863,7 @@ namespace clang {
 
     constexpr static unsigned NumInlineBytes =
         24 * sizeof(ImplicitConversionSequence);
-    unsigned NumInlineBytesUsed;
+    unsigned NumInlineBytesUsed = 0;
     llvm::AlignedCharArray<alignof(void *), NumInlineBytes> InlineSpace;
 
     /// If we have space, allocates from inline storage. Otherwise, allocates
@@ -788,14 +892,13 @@ namespace clang {
       return reinterpret_cast<T *>(FreeSpaceStart);
     }
 
-    OverloadCandidateSet(const OverloadCandidateSet &) = delete;
-    void operator=(const OverloadCandidateSet &) = delete;
-
     void destroyCandidates();
 
   public:
     OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK)
-        : Loc(Loc), Kind(CSK), NumInlineBytesUsed(0) {}
+        : Loc(Loc), Kind(CSK) {}
+    OverloadCandidateSet(const OverloadCandidateSet &) = delete;
+    OverloadCandidateSet &operator=(const OverloadCandidateSet &) = delete;
     ~OverloadCandidateSet() { destroyCandidates(); }
 
     SourceLocation getLocation() const { return Loc; }
@@ -810,7 +913,8 @@ namespace clang {
     /// \brief Clear out all of the candidates.
     void clear(CandidateSetKind CSK);
 
-    typedef SmallVectorImpl<OverloadCandidate>::iterator iterator;
+    using iterator = SmallVectorImpl<OverloadCandidate>::iterator;
+
     iterator begin() { return Candidates.begin(); }
     iterator end() { return Candidates.end(); }
 
@@ -869,8 +973,10 @@ namespace clang {
     DeclAccessPair FoundDecl;
     CXXConstructorDecl *Constructor;
     FunctionTemplateDecl *ConstructorTmpl;
+
     explicit operator bool() const { return Constructor; }
   };
+
   // FIXME: Add an AddOverloadCandidate / AddTemplateOverloadCandidate overload
   // that takes one of these.
   inline ConstructorInfo getConstructorInfo(NamedDecl *ND) {
@@ -888,6 +994,7 @@ namespace clang {
     Info.Constructor = dyn_cast<CXXConstructorDecl>(D);
     return Info;
   }
-} // end namespace clang
+
+} // namespace clang
 
 #endif // LLVM_CLANG_SEMA_OVERLOAD_H

Modified: cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DelayedDiagnostic.cpp?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DelayedDiagnostic.cpp (original)
+++ cfe/trunk/lib/Sema/DelayedDiagnostic.cpp Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===--- DelayedDiagnostic.cpp - Delayed declarator diagnostics -*- C++ -*-===//
+//===- DelayedDiagnostic.cpp - Delayed declarator diagnostics -------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,8 +14,10 @@
 // This file also defines AccessedEntity.
 //
 //===----------------------------------------------------------------------===//
+
 #include "clang/Sema/DelayedDiagnostic.h"
-#include <string.h>
+#include <cstring>
+
 using namespace clang;
 using namespace sema;
 
@@ -37,7 +39,7 @@ DelayedDiagnostic::makeAvailability(Avai
   DD.AvailabilityData.UnknownObjCClass = UnknownObjCClass;
   DD.AvailabilityData.ObjCProperty = ObjCProperty;
   char *MessageData = nullptr;
-  if (Msg.size()) {
+  if (!Msg.empty()) {
     MessageData = new char [Msg.size()];
     memcpy(MessageData, Msg.data(), Msg.size());
   }

Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=325659&r1=325658&r2=325659&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Tue Feb 20 17:45:26 2018
@@ -1,4 +1,4 @@
-//===- IdentifierResolver.cpp - Lexical Scope Name lookup -------*- C++ -*-===//
+//===- IdentifierResolver.cpp - Lexical Scope Name lookup -----------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,10 +14,16 @@
 
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstdint>
 
 using namespace clang;
 
@@ -35,17 +41,17 @@ class IdentifierResolver::IdDeclInfoMap
   /// impossible to add something to a pre-C++0x STL container without
   /// a completely unnecessary copy.
   struct IdDeclInfoPool {
-    IdDeclInfoPool(IdDeclInfoPool *Next) : Next(Next) {}
-    
     IdDeclInfoPool *Next;
     IdDeclInfo Pool[POOL_SIZE];
+
+    IdDeclInfoPool(IdDeclInfoPool *Next) : Next(Next) {}
   };
   
-  IdDeclInfoPool *CurPool;
-  unsigned int CurIndex;
+  IdDeclInfoPool *CurPool = nullptr;
+  unsigned int CurIndex = POOL_SIZE;
 
 public:
-  IdDeclInfoMap() : CurPool(nullptr), CurIndex(POOL_SIZE) {}
+  IdDeclInfoMap() = default;
 
   ~IdDeclInfoMap() {
     IdDeclInfoPool *Cur = CurPool;
@@ -60,7 +66,6 @@ public:
   IdDeclInfo &operator[](DeclarationName Name);
 };
 
-
 //===----------------------------------------------------------------------===//
 // IdDeclInfo Implementation
 //===----------------------------------------------------------------------===//
@@ -83,9 +88,7 @@ void IdentifierResolver::IdDeclInfo::Rem
 //===----------------------------------------------------------------------===//
 
 IdentifierResolver::IdentifierResolver(Preprocessor &PP)
-  : LangOpt(PP.getLangOpts()), PP(PP),
-    IdDeclInfos(new IdDeclInfoMap) {
-}
+    : LangOpt(PP.getLangOpts()), PP(PP), IdDeclInfos(new IdDeclInfoMap) {}
 
 IdentifierResolver::~IdentifierResolver() {
   delete IdDeclInfos;
@@ -245,12 +248,14 @@ IdentifierResolver::begin(DeclarationNam
 }
 
 namespace {
-  enum DeclMatchKind {
-    DMK_Different,
-    DMK_Replace,
-    DMK_Ignore
-  };
-}
+
+enum DeclMatchKind {
+  DMK_Different,
+  DMK_Replace,
+  DMK_Ignore
+};
+
+} // namespace
 
 /// \brief Compare two declarations to see whether they are different or,
 /// if they are the same, whether the new declaration should replace the 




More information about the cfe-commits mailing list